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
1=== added directory 'l10n_mx_sale_payment_method'
2=== added file 'l10n_mx_sale_payment_method/__init__.py'
3--- l10n_mx_sale_payment_method/__init__.py 1970-01-01 00:00:00 +0000
4+++ l10n_mx_sale_payment_method/__init__.py 2012-10-23 23:08:19 +0000
5@@ -0,0 +1,27 @@
6+# -*- encoding: utf-8 -*-
7+###########################################################################
8+# Module Writen to OpenERP, Open Source Management Solution
9+#
10+# Copyright (c) 2010 Vauxoo - http://www.vauxoo.com/
11+# All Rights Reserved.
12+# info Vauxoo (info@vauxoo.com)
13+############################################################################
14+# Coded by: Luis Torres (luis_t@vauxoo.com)
15+############################################################################
16+#
17+# This program is free software: you can redistribute it and/or modify
18+# it under the terms of the GNU Affero General Public License as
19+# published by the Free Software Foundation, either version 3 of the
20+# License, or (at your option) any later version.
21+#
22+# This program is distributed in the hope that it will be useful,
23+# but WITHOUT ANY WARRANTY; without even the implied warranty of
24+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25+# GNU Affero General Public License for more details.
26+#
27+# You should have received a copy of the GNU Affero General Public License
28+# along with this program. If not, see <http://www.gnu.org/licenses/>.
29+#
30+##############################################################################
31+import sale
32+import stock
33
34=== added file 'l10n_mx_sale_payment_method/__openerp__.py'
35--- l10n_mx_sale_payment_method/__openerp__.py 1970-01-01 00:00:00 +0000
36+++ l10n_mx_sale_payment_method/__openerp__.py 2012-10-23 23:08:19 +0000
37@@ -0,0 +1,46 @@
38+# -*- encoding: utf-8 -*-
39+###########################################################################
40+# Module Writen to OpenERP, Open Source Management Solution
41+#
42+# Copyright (c) 2010 Vauxoo - http://www.vauxoo.com/
43+# All Rights Reserved.
44+# info Vauxoo (info@vauxoo.com)
45+############################################################################
46+# Coded by: Luis Torres (luis_t@vauxoo.com)
47+############################################################################
48+#
49+# This program is free software: you can redistribute it and/or modify
50+# it under the terms of the GNU Affero General Public License as
51+# published by the Free Software Foundation, either version 3 of the
52+# License, or (at your option) any later version.
53+#
54+# This program is distributed in the hope that it will be useful,
55+# but WITHOUT ANY WARRANTY; without even the implied warranty of
56+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57+# GNU Affero General Public License for more details.
58+#
59+# You should have received a copy of the GNU Affero General Public License
60+# along with this program. If not, see <http://www.gnu.org/licenses/>.
61+#
62+##############################################################################
63+
64+{
65+ "name" : "Sale payment method",
66+ "version" : "1.0",
67+ "author" : "Vauxoo",
68+ "category" : "Generic Modules",
69+ "description" : """
70+ This module add fields acc_payment & pay_method_id, and to the generate invoice adds
71+ """,
72+ "website" : "http://www.vauxoo.com/",
73+ "license" : "AGPL-3",
74+ "depends" : ["sale",
75+ ],
76+ "init_xml" : [],
77+ "demo_xml" : [],
78+ "update_xml" : [
79+ "sale_view.xml",
80+ ],
81+ "installable" : True,
82+ "active" : False,
83+}
84
85=== added file 'l10n_mx_sale_payment_method/sale.py'
86--- l10n_mx_sale_payment_method/sale.py 1970-01-01 00:00:00 +0000
87+++ l10n_mx_sale_payment_method/sale.py 2012-10-23 23:08:19 +0000
88@@ -0,0 +1,56 @@
89+# -*- encoding: utf-8 -*-
90+###########################################################################
91+# Module Writen to OpenERP, Open Source Management Solution
92+#
93+# Copyright (c) 2010 Vauxoo - http://www.vauxoo.com/
94+# All Rights Reserved.
95+# info Vauxoo (info@vauxoo.com)
96+############################################################################
97+# Coded by: Luis Torres (luis_t@vauxoo.com)
98+############################################################################
99+#
100+# This program is free software: you can redistribute it and/or modify
101+# it under the terms of the GNU Affero General Public License as
102+# published by the Free Software Foundation, either version 3 of the
103+# License, or (at your option) any later version.
104+#
105+# This program is distributed in the hope that it will be useful,
106+# but WITHOUT ANY WARRANTY; without even the implied warranty of
107+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
108+# GNU Affero General Public License for more details.
109+#
110+# You should have received a copy of the GNU Affero General Public License
111+# along with this program. If not, see <http://www.gnu.org/licenses/>.
112+#
113+##############################################################################
114+from osv import osv
115+from osv import osv, fields
116+
117+class sale_order(osv.osv):
118+ _inherit = 'sale.order'
119+
120+ def onchange_partner_id(self, cr, uid, ids, part):
121+ res=super(sale_order, self).onchange_partner_id(cr, uid, ids, part)
122+ partner = self.pool.get('res.partner')
123+ if part:
124+ partner_bank_obj=self.pool.get('res.partner.bank')
125+ bank_partner_id=partner_bank_obj.search(cr, uid, [('partner_id','=',part)])
126+ pay_method_id=partner.browse(cr,uid,part).pay_method_id.id
127+ res['value'].update({'acc_payment': bank_partner_id and bank_partner_id[0] or False,'pay_method_id':pay_method_id or False})
128+ return res
129+
130+ _columns = {
131+ '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".'),
132+ '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”.'),
133+ }
134+
135+ def action_invoice_create(self, cr, uid, ids, grouped=False, states=['confirmed', 'done', 'exception'], date_inv = False, context=None):
136+ res=super(sale_order,self).action_invoice_create(cr, uid, ids, grouped=grouped, states=states, date_inv = date_inv, context=context)
137+ invoice_obj = self.pool.get('account.invoice')
138+ sale_order_id=self.browse(cr, uid, ids, context=context)[0]
139+ if sale_order_id:
140+ acc_payment_id=sale_order_id.acc_payment and sale_order_id.acc_payment.id or False
141+ payment_method_id=sale_order_id.pay_method_id and sale_order_id.pay_method_id.id or False
142+ invoice_obj.write(cr, uid, [res], {'acc_payment': acc_payment_id, 'pay_method_id': payment_method_id}, context=context)
143+sale_order()
144+
145
146=== added file 'l10n_mx_sale_payment_method/sale_view.xml'
147--- l10n_mx_sale_payment_method/sale_view.xml 1970-01-01 00:00:00 +0000
148+++ l10n_mx_sale_payment_method/sale_view.xml 2012-10-23 23:08:19 +0000
149@@ -0,0 +1,17 @@
150+<?xml version="1.0" encoding="utf-8"?>
151+<openerp>
152+ <data>
153+ <record model="ir.ui.view" id="view_sale_order_inherit_bank_form">
154+ <field name="name">view.sale.order.inherit.bank.form</field>
155+ <field name="model">sale.order</field>
156+ <field name="type">form</field>
157+ <field name="inherit_id" ref="sale.view_order_form"/>
158+ <field name="arch" type="xml">
159+ <xpath expr="/form/notebook/page[@string='Sales Order']/field[@name='partner_shipping_id']" position="after">
160+ <field name="acc_payment"/>
161+ <field name="pay_method_id" widget="selection"/>
162+ </xpath>
163+ </field>
164+ </record>
165+ </data>
166+</openerp>
167
168=== added file 'l10n_mx_sale_payment_method/stock.py'
169--- l10n_mx_sale_payment_method/stock.py 1970-01-01 00:00:00 +0000
170+++ l10n_mx_sale_payment_method/stock.py 2012-10-23 23:08:19 +0000
171@@ -0,0 +1,50 @@
172+# -*- encoding: utf-8 -*-
173+###########################################################################
174+# Module Writen to OpenERP, Open Source Management Solution
175+#
176+# Copyright (c) 2010 Vauxoo - http://www.vauxoo.com/
177+# All Rights Reserved.
178+# info Vauxoo (info@vauxoo.com)
179+############################################################################
180+# Coded by: Luis Torres (luis_t@vauxoo.com)
181+############################################################################
182+#
183+# This program is free software: you can redistribute it and/or modify
184+# it under the terms of the GNU Affero General Public License as
185+# published by the Free Software Foundation, either version 3 of the
186+# License, or (at your option) any later version.
187+#
188+# This program is distributed in the hope that it will be useful,
189+# but WITHOUT ANY WARRANTY; without even the implied warranty of
190+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
191+# GNU Affero General Public License for more details.
192+#
193+# You should have received a copy of the GNU Affero General Public License
194+# along with this program. If not, see <http://www.gnu.org/licenses/>.
195+#
196+##############################################################################
197+from osv import osv
198+
199+class stock_picking(osv.osv):
200+ _inherit = 'stock.picking'
201+
202+ def action_invoice_create(self, cursor, user, ids, journal_id=False,
203+ group=False, type='out_invoice', context=None):
204+ if context is None:
205+ context = {}
206+ invoice_obj = self.pool.get('account.invoice')
207+ sale_obj=self.pool.get('sale.order')
208+ picking_id__invoice_id_dict = super(stock_picking, self).action_invoice_create(cursor, user,
209+ ids, journal_id=journal_id, group=group, type=type,
210+ context=context)
211+ for picking_id in picking_id__invoice_id_dict.keys():
212+ picking_obj = self.browse(cursor, user, picking_id)
213+ invoice_id = picking_id__invoice_id_dict[ picking_id ]
214+ sale_id = picking_obj.sale_id and picking_obj.sale_id.id or False
215+ if sale_id:
216+ sale_order_id=sale_obj.browse(cursor, user, sale_id)
217+ acc_payment_id=sale_order_id.acc_payment and sale_order_id.acc_payment.id or False
218+ payment_method_id=sale_order_id.pay_method_id and sale_order_id.pay_method_id.id or False
219+ invoice_obj.write(cursor, user, [invoice_id], {'acc_payment': acc_payment_id, 'pay_method_id': payment_method_id}, context=context)
220+ return picking_id__invoice_id_dict
221+stock_picking()