Merge lp:~vauxoo/openerp-mexico-localization/sale_payment_method_dev_luis into lp:openerp-mexico-localization

Proposed by Luis Torres - http://www.vauxoo.com
Status: Rejected
Rejected by: Moisés López - http://www.vauxoo.com
Proposed branch: lp:~vauxoo/openerp-mexico-localization/sale_payment_method_dev_luis
Merge into: lp:openerp-mexico-localization
Diff against target: 221 lines (+196/-0)
5 files modified
l10n_mx_sale_payment_method/__init__.py (+27/-0)
l10n_mx_sale_payment_method/__openerp__.py (+46/-0)
l10n_mx_sale_payment_method/sale.py (+56/-0)
l10n_mx_sale_payment_method/sale_view.xml (+17/-0)
l10n_mx_sale_payment_method/stock.py (+50/-0)
To merge this branch: bzr merge lp:~vauxoo/openerp-mexico-localization/sale_payment_method_dev_luis
Reviewer Review Type Date Requested Status
Moisés López - http://www.vauxoo.com Disapprove
Luis Torres - http://www.vauxoo.com (community) Needs Resubmitting
Rodolfo Lopez Pending
Isaac López Zúñiga Pending
Review via email: mp+131109@code.launchpad.net

Description of the change

Se agregaron los campos del número de cuenta y el metodo de pago a la sale, estos los toma de los datos del cliente

To post a comment you must log in.
Revision history for this message
Moisés López - http://www.vauxoo.com (moylop260) wrote :

Luis,

En esta línea va a marcar error cuando no tenga sale asociada.
+ sale_id = self.browse(cursor, user, picking_id, context=context).sale_id.id
Cambiar por
+ sale_obj = self.browse(cursor, user, picking_id, context=context)
+ sale_id = sale_obj.sale_id and sale_obj.sale_id.id or False

Los write los puedes mandar a un solo write, solo para que quede más eficiente.
219 + invoice_obj.write(cursor, user, [invoice_id], {'acc_payment': acc_payment_id}, context=context)
220 + invoice_obj.write(cursor, user, [invoice_id], {'pay_method_id': payment_method_id}, context=context)

Cambiar a
219 + invoice_obj.write(cursor, user, [invoice_id], {'acc_payment': acc_payment_id, 'pay_method_id': payment_method_id}, context=context)

209. By Luis Torres - http://www.vauxoo.com

[IMP][l10n_mx_sale_payment_method]Add a validation for False & improvement code

Revision history for this message
Luis Torres - http://www.vauxoo.com (luis-cleto-) wrote :

Se agrego una validacion para cuando no haya sale_order
y se recorto la linea de los write

review: Needs Resubmitting
Revision history for this message
Moisés López - http://www.vauxoo.com (moylop260) wrote :

mp applied in other mp

review: Disapprove

Unmerged revisions

209. By Luis Torres - http://www.vauxoo.com

[IMP][l10n_mx_sale_payment_method]Add a validation for False & improvement code

208. By Luis Torres - http://www.vauxoo.com

[ADD][l10n_mx_sale_payment_method]Add fields to acc_payment & payment_method in sale

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory 'l10n_mx_sale_payment_method'
=== added file 'l10n_mx_sale_payment_method/__init__.py'
--- l10n_mx_sale_payment_method/__init__.py 1970-01-01 00:00:00 +0000
+++ l10n_mx_sale_payment_method/__init__.py 2012-10-23 23:08:19 +0000
@@ -0,0 +1,27 @@
1# -*- encoding: utf-8 -*-
2###########################################################################
3# Module Writen to OpenERP, Open Source Management Solution
4#
5# Copyright (c) 2010 Vauxoo - http://www.vauxoo.com/
6# All Rights Reserved.
7# info Vauxoo (info@vauxoo.com)
8############################################################################
9# Coded by: Luis Torres (luis_t@vauxoo.com)
10############################################################################
11#
12# This program is free software: you can redistribute it and/or modify
13# it under the terms of the GNU Affero General Public License as
14# published by the Free Software Foundation, either version 3 of the
15# License, or (at your option) any later version.
16#
17# This program is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20# GNU Affero General Public License for more details.
21#
22# You should have received a copy of the GNU Affero General Public License
23# along with this program. If not, see <http://www.gnu.org/licenses/>.
24#
25##############################################################################
26import sale
27import stock
028
=== added file 'l10n_mx_sale_payment_method/__openerp__.py'
--- l10n_mx_sale_payment_method/__openerp__.py 1970-01-01 00:00:00 +0000
+++ l10n_mx_sale_payment_method/__openerp__.py 2012-10-23 23:08:19 +0000
@@ -0,0 +1,46 @@
1# -*- encoding: utf-8 -*-
2###########################################################################
3# Module Writen to OpenERP, Open Source Management Solution
4#
5# Copyright (c) 2010 Vauxoo - http://www.vauxoo.com/
6# All Rights Reserved.
7# info Vauxoo (info@vauxoo.com)
8############################################################################
9# Coded by: Luis Torres (luis_t@vauxoo.com)
10############################################################################
11#
12# This program is free software: you can redistribute it and/or modify
13# it under the terms of the GNU Affero General Public License as
14# published by the Free Software Foundation, either version 3 of the
15# License, or (at your option) any later version.
16#
17# This program is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20# GNU Affero General Public License for more details.
21#
22# You should have received a copy of the GNU Affero General Public License
23# along with this program. If not, see <http://www.gnu.org/licenses/>.
24#
25##############################################################################
26
27{
28 "name" : "Sale payment method",
29 "version" : "1.0",
30 "author" : "Vauxoo",
31 "category" : "Generic Modules",
32 "description" : """
33 This module add fields acc_payment & pay_method_id, and to the generate invoice adds
34 """,
35 "website" : "http://www.vauxoo.com/",
36 "license" : "AGPL-3",
37 "depends" : ["sale",
38 ],
39 "init_xml" : [],
40 "demo_xml" : [],
41 "update_xml" : [
42 "sale_view.xml",
43 ],
44 "installable" : True,
45 "active" : False,
46}
047
=== added file 'l10n_mx_sale_payment_method/sale.py'
--- l10n_mx_sale_payment_method/sale.py 1970-01-01 00:00:00 +0000
+++ l10n_mx_sale_payment_method/sale.py 2012-10-23 23:08:19 +0000
@@ -0,0 +1,56 @@
1# -*- encoding: utf-8 -*-
2###########################################################################
3# Module Writen to OpenERP, Open Source Management Solution
4#
5# Copyright (c) 2010 Vauxoo - http://www.vauxoo.com/
6# All Rights Reserved.
7# info Vauxoo (info@vauxoo.com)
8############################################################################
9# Coded by: Luis Torres (luis_t@vauxoo.com)
10############################################################################
11#
12# This program is free software: you can redistribute it and/or modify
13# it under the terms of the GNU Affero General Public License as
14# published by the Free Software Foundation, either version 3 of the
15# License, or (at your option) any later version.
16#
17# This program is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20# GNU Affero General Public License for more details.
21#
22# You should have received a copy of the GNU Affero General Public License
23# along with this program. If not, see <http://www.gnu.org/licenses/>.
24#
25##############################################################################
26from osv import osv
27from osv import osv, fields
28
29class sale_order(osv.osv):
30 _inherit = 'sale.order'
31
32 def onchange_partner_id(self, cr, uid, ids, part):
33 res=super(sale_order, self).onchange_partner_id(cr, uid, ids, part)
34 partner = self.pool.get('res.partner')
35 if part:
36 partner_bank_obj=self.pool.get('res.partner.bank')
37 bank_partner_id=partner_bank_obj.search(cr, uid, [('partner_id','=',part)])
38 pay_method_id=partner.browse(cr,uid,part).pay_method_id.id
39 res['value'].update({'acc_payment': bank_partner_id and bank_partner_id[0] or False,'pay_method_id':pay_method_id or False})
40 return res
41
42 _columns = {
43 'acc_payment': fields.many2one ('res.partner.bank', 'Numero de cuenta', readonly=True, states={'draft':[('readonly',False)]},help = 'Es la cuenta con la que el cliente pagará la factura, si no se sabe con cual cuenta se va pagar dejarlo vacío y en el xml aparecerá "No identificado".'),
44 'pay_method_id': fields.many2one('pay.method', 'Metodo de Pago', readonly=True, states={'draft':[('readonly',False)]}, help = 'Indica la forma en que se pagó o se pagará la factura, donde las opciones pueden ser: cheque, transferencia bancaria, depósito en cuenta bancaria, tarjeta de crédito, efectivo etc. Si no se sabe como va ser pagada la factura, dejarlo vacío y en el xml aparecerá “No identificado”.'),
45 }
46
47 def action_invoice_create(self, cr, uid, ids, grouped=False, states=['confirmed', 'done', 'exception'], date_inv = False, context=None):
48 res=super(sale_order,self).action_invoice_create(cr, uid, ids, grouped=grouped, states=states, date_inv = date_inv, context=context)
49 invoice_obj = self.pool.get('account.invoice')
50 sale_order_id=self.browse(cr, uid, ids, context=context)[0]
51 if sale_order_id:
52 acc_payment_id=sale_order_id.acc_payment and sale_order_id.acc_payment.id or False
53 payment_method_id=sale_order_id.pay_method_id and sale_order_id.pay_method_id.id or False
54 invoice_obj.write(cr, uid, [res], {'acc_payment': acc_payment_id, 'pay_method_id': payment_method_id}, context=context)
55sale_order()
56
057
=== added file 'l10n_mx_sale_payment_method/sale_view.xml'
--- l10n_mx_sale_payment_method/sale_view.xml 1970-01-01 00:00:00 +0000
+++ l10n_mx_sale_payment_method/sale_view.xml 2012-10-23 23:08:19 +0000
@@ -0,0 +1,17 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4 <record model="ir.ui.view" id="view_sale_order_inherit_bank_form">
5 <field name="name">view.sale.order.inherit.bank.form</field>
6 <field name="model">sale.order</field>
7 <field name="type">form</field>
8 <field name="inherit_id" ref="sale.view_order_form"/>
9 <field name="arch" type="xml">
10 <xpath expr="/form/notebook/page[@string='Sales Order']/field[@name='partner_shipping_id']" position="after">
11 <field name="acc_payment"/>
12 <field name="pay_method_id" widget="selection"/>
13 </xpath>
14 </field>
15 </record>
16 </data>
17</openerp>
018
=== added file 'l10n_mx_sale_payment_method/stock.py'
--- l10n_mx_sale_payment_method/stock.py 1970-01-01 00:00:00 +0000
+++ l10n_mx_sale_payment_method/stock.py 2012-10-23 23:08:19 +0000
@@ -0,0 +1,50 @@
1# -*- encoding: utf-8 -*-
2###########################################################################
3# Module Writen to OpenERP, Open Source Management Solution
4#
5# Copyright (c) 2010 Vauxoo - http://www.vauxoo.com/
6# All Rights Reserved.
7# info Vauxoo (info@vauxoo.com)
8############################################################################
9# Coded by: Luis Torres (luis_t@vauxoo.com)
10############################################################################
11#
12# This program is free software: you can redistribute it and/or modify
13# it under the terms of the GNU Affero General Public License as
14# published by the Free Software Foundation, either version 3 of the
15# License, or (at your option) any later version.
16#
17# This program is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20# GNU Affero General Public License for more details.
21#
22# You should have received a copy of the GNU Affero General Public License
23# along with this program. If not, see <http://www.gnu.org/licenses/>.
24#
25##############################################################################
26from osv import osv
27
28class stock_picking(osv.osv):
29 _inherit = 'stock.picking'
30
31 def action_invoice_create(self, cursor, user, ids, journal_id=False,
32 group=False, type='out_invoice', context=None):
33 if context is None:
34 context = {}
35 invoice_obj = self.pool.get('account.invoice')
36 sale_obj=self.pool.get('sale.order')
37 picking_id__invoice_id_dict = super(stock_picking, self).action_invoice_create(cursor, user,
38 ids, journal_id=journal_id, group=group, type=type,
39 context=context)
40 for picking_id in picking_id__invoice_id_dict.keys():
41 picking_obj = self.browse(cursor, user, picking_id)
42 invoice_id = picking_id__invoice_id_dict[ picking_id ]
43 sale_id = picking_obj.sale_id and picking_obj.sale_id.id or False
44 if sale_id:
45 sale_order_id=sale_obj.browse(cursor, user, sale_id)
46 acc_payment_id=sale_order_id.acc_payment and sale_order_id.acc_payment.id or False
47 payment_method_id=sale_order_id.pay_method_id and sale_order_id.pay_method_id.id or False
48 invoice_obj.write(cursor, user, [invoice_id], {'acc_payment': acc_payment_id, 'pay_method_id': payment_method_id}, context=context)
49 return picking_id__invoice_id_dict
50stock_picking()