Merge lp:~vauxoo/addons-vauxoo/7.0-invoice-discount-luist into lp:addons-vauxoo/7.0

Proposed by Luis Torres - http://www.vauxoo.com
Status: Merged
Merged at revision: 1142
Proposed branch: lp:~vauxoo/addons-vauxoo/7.0-invoice-discount-luist
Merge into: lp:addons-vauxoo/7.0
Diff against target: 486 lines (+438/-0)
9 files modified
invoice_discount/__init__.py (+26/-0)
invoice_discount/__openerp__.py (+50/-0)
invoice_discount/i18n/es.po (+68/-0)
invoice_discount/i18n/es_MX.po (+17/-0)
invoice_discount/model/__init__.py (+27/-0)
invoice_discount/model/config_settings.py (+43/-0)
invoice_discount/model/invoice.py (+159/-0)
invoice_discount/view/config_settings_action.xml (+6/-0)
invoice_discount/view/invoice_view.xml (+42/-0)
To merge this branch: bzr merge lp:~vauxoo/addons-vauxoo/7.0-invoice-discount-luist
Reviewer Review Type Date Requested Status
Luis Torres - http://www.vauxoo.com Needs Resubmitting
Moisés López - http://www.vauxoo.com Needs Fixing
Jorge Angel Naranjo Rogel - http://www.vauxoo.com Pending
Review via email: mp+235550@code.launchpad.net

Description of the change

Se agregaron fields function para obtener los montos de la cantidad sin descuento y el monto del descuento para las facturas y las lineas de las facturas.

To post a comment you must log in.
1135. By Luis Torres - http://www.vauxoo.com

[IMP][invoice_discount]Was added that active the action to set the discount on lines of invoice

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

LuisT,
Agrega los campos a la vista tree de account.invoice.line, también, por favor.
(con invisible=True, por ahora).

Pon los nombres de string y traducción de los mismos, mas descriptivas, ya que se repiten con los originales.

review: Needs Fixing
1136. By Luis Torres - http://www.vauxoo.com

[IMP][invoice_discount]Was completed the string and help in fields, added fields to view tree of account_invoice_line

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

Se cambio el string a los campos agregados, y se coloco ayuda a estos

review: Needs Resubmitting
Revision history for this message
Jorge Angel Naranjo Rogel - http://www.vauxoo.com (jorge-nr) wrote :

@Luis
Puedes realizar las correcciones que te comento abajo, no son de funcionalidad.

1137. By Jorge Angel Naranjo Rogel - http://www.vauxoo.com

[IMP][invoice_discount] Changed some translations, changed noupdate 0 to 1 and changed in credits 2010 to 2014

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'invoice_discount'
2=== added file 'invoice_discount/__init__.py'
3--- invoice_discount/__init__.py 1970-01-01 00:00:00 +0000
4+++ invoice_discount/__init__.py 2014-10-02 16:52:39 +0000
5@@ -0,0 +1,26 @@
6+# -*- encoding: utf-8 -*-
7+###########################################################################
8+# Module Writen to OpenERP, Open Source Management Solution
9+#
10+# Copyright (c) 2014 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 model
32
33=== added file 'invoice_discount/__openerp__.py'
34--- invoice_discount/__openerp__.py 1970-01-01 00:00:00 +0000
35+++ invoice_discount/__openerp__.py 2014-10-02 16:52:39 +0000
36@@ -0,0 +1,50 @@
37+# -*- encoding: utf-8 -*-
38+###########################################################################
39+# Module Writen to OpenERP, Open Source Management Solution
40+#
41+# Copyright (c) 2014 Vauxoo - http://www.vauxoo.com/
42+# All Rights Reserved.
43+# info Vauxoo (info@vauxoo.com)
44+############################################################################
45+# Coded by: Luis Torres (luis_t@vauxoo.com)
46+############################################################################
47+#
48+# This program is free software: you can redistribute it and/or modify
49+# it under the terms of the GNU Affero General Public License as
50+# published by the Free Software Foundation, either version 3 of the
51+# License, or (at your option) any later version.
52+#
53+# This program is distributed in the hope that it will be useful,
54+# but WITHOUT ANY WARRANTY; without even the implied warranty of
55+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
56+# GNU Affero General Public License for more details.
57+#
58+# You should have received a copy of the GNU Affero General Public License
59+# along with this program. If not, see <http://www.gnu.org/licenses/>.
60+#
61+##############################################################################
62+
63+{
64+ "name": "Invoice Discount",
65+ "version": "1.0",
66+ "author": "Vauxoo",
67+ "category": "Generic Modules",
68+ "description": """
69+ Fields to get the amount without discount and discount in lines to
70+ invoice.
71+ """,
72+ "website": "http://www.vauxoo.com/",
73+ "license": "AGPL-3",
74+ "depends": [
75+ "account",
76+ "sale",
77+ ],
78+ "demo": [],
79+ "data": [
80+ "view/invoice_view.xml",
81+ 'view/config_settings_action.xml',
82+ ],
83+ "test": [],
84+ "installable": True,
85+ "active": False,
86+}
87
88=== added directory 'invoice_discount/i18n'
89=== added file 'invoice_discount/i18n/es.po'
90--- invoice_discount/i18n/es.po 1970-01-01 00:00:00 +0000
91+++ invoice_discount/i18n/es.po 2014-10-02 16:52:39 +0000
92@@ -0,0 +1,68 @@
93+# Translation of OpenERP Server.
94+# This file contains the translation of the following modules:
95+# * invoice_discount
96+#
97+msgid ""
98+msgstr ""
99+"Project-Id-Version: OpenERP Server 7.0\n"
100+"Report-Msgid-Bugs-To: \n"
101+"POT-Creation-Date: 2014-09-25 21:17+0000\n"
102+"PO-Revision-Date: 2014-09-25 21:17+0000\n"
103+"Last-Translator: <>\n"
104+"Language-Team: \n"
105+"MIME-Version: 1.0\n"
106+"Content-Type: text/plain; charset=UTF-8\n"
107+"Content-Transfer-Encoding: \n"
108+"Plural-Forms: \n"
109+
110+#. module: invoice_discount
111+#: help:account.invoice,subtotal_wo_discount:0
112+msgid "Amount without apply the discount of the lines of the invoice."
113+msgstr "Monto sin aplicar el descuento de las líneas de la factura."
114+
115+#. module: invoice_discount
116+#: field:account.invoice.line,discount_amount:0
117+msgid "Discount Amount"
118+msgstr "Monto descuento"
119+
120+#. module: invoice_discount
121+#: help:account.invoice.line,subtotal_wo_discount:0
122+msgid "Amount without apply the discount of the line, is calculated as Qty * Price Unit"
123+msgstr "Monto sin aplicar el descuento de la línea, es calculado con Cantidad * Precio Unitario"
124+
125+#. module: invoice_discount
126+#: model:ir.model,name:invoice_discount.model_sale_config_settings
127+msgid "sale.config.settings"
128+msgstr "Configuración de las ventas"
129+
130+#. module: invoice_discount
131+#: help:account.invoice,discount_amount:0
132+msgid "Total of discount apply in each line of the invoice."
133+msgstr "Descuento total aplicado en cada una de las líneas de la factura."
134+
135+#. module: invoice_discount
136+#: model:ir.model,name:invoice_discount.model_account_invoice_line
137+msgid "Invoice Line"
138+msgstr "Línea de factura"
139+
140+#. module: invoice_discount
141+#: field:account.invoice,subtotal_wo_discount:0
142+#: field:account.invoice.line,subtotal_wo_discount:0
143+msgid "SubTotal w/o Discount"
144+msgstr "SubTotal sin descuento"
145+
146+#. module: invoice_discount
147+#: field:account.invoice,discount_amount:0
148+msgid "Discount"
149+msgstr "Descuento"
150+
151+#. module: invoice_discount
152+#: help:account.invoice.line,discount_amount:0
153+msgid "Amount total of the discount, is calculated as Discount * SubTotal w/o Discount / 100."
154+msgstr "Monto total de el descuento, es calculado con Descuento * SubTotal sin Descuento / 100."
155+
156+#. module: invoice_discount
157+#: model:ir.model,name:invoice_discount.model_account_invoice
158+msgid "Invoice"
159+msgstr "Factura"
160+
161
162=== added file 'invoice_discount/i18n/es_MX.po'
163--- invoice_discount/i18n/es_MX.po 1970-01-01 00:00:00 +0000
164+++ invoice_discount/i18n/es_MX.po 2014-10-02 16:52:39 +0000
165@@ -0,0 +1,17 @@
166+# Translation of OpenERP Server.
167+# This file contains the translation of the following modules:
168+# * invoice_discount
169+#
170+msgid ""
171+msgstr ""
172+"Project-Id-Version: OpenERP Server 7.0\n"
173+"Report-Msgid-Bugs-To: \n"
174+"POT-Creation-Date: 2014-09-25 21:17+0000\n"
175+"PO-Revision-Date: 2014-09-25 21:17+0000\n"
176+"Last-Translator: <>\n"
177+"Language-Team: \n"
178+"MIME-Version: 1.0\n"
179+"Content-Type: text/plain; charset=UTF-8\n"
180+"Content-Transfer-Encoding: \n"
181+"Plural-Forms: \n"
182+
183
184=== added directory 'invoice_discount/model'
185=== added file 'invoice_discount/model/__init__.py'
186--- invoice_discount/model/__init__.py 1970-01-01 00:00:00 +0000
187+++ invoice_discount/model/__init__.py 2014-10-02 16:52:39 +0000
188@@ -0,0 +1,27 @@
189+# -*- encoding: utf-8 -*-
190+###########################################################################
191+# Module Writen to OpenERP, Open Source Management Solution
192+#
193+# Copyright (c) 2014 Vauxoo - http://www.vauxoo.com/
194+# All Rights Reserved.
195+# info Vauxoo (info@vauxoo.com)
196+############################################################################
197+# Coded by: Luis Torres (luis_t@vauxoo.com)
198+############################################################################
199+#
200+# This program is free software: you can redistribute it and/or modify
201+# it under the terms of the GNU Affero General Public License as
202+# published by the Free Software Foundation, either version 3 of the
203+# License, or (at your option) any later version.
204+#
205+# This program is distributed in the hope that it will be useful,
206+# but WITHOUT ANY WARRANTY; without even the implied warranty of
207+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
208+# GNU Affero General Public License for more details.
209+#
210+# You should have received a copy of the GNU Affero General Public License
211+# along with this program. If not, see <http://www.gnu.org/licenses/>.
212+#
213+##############################################################################
214+import config_settings
215+import invoice
216
217=== added file 'invoice_discount/model/config_settings.py'
218--- invoice_discount/model/config_settings.py 1970-01-01 00:00:00 +0000
219+++ invoice_discount/model/config_settings.py 2014-10-02 16:52:39 +0000
220@@ -0,0 +1,43 @@
221+# -*- encoding: utf-8 -*-
222+###########################################################################
223+# Module Writen to OpenERP, Open Source Management Solution
224+#
225+# Copyright (c) 2014 Vauxoo - http://www.vauxoo.com/
226+# All Rights Reserved.
227+# info Vauxoo (info@vauxoo.com)
228+############################################################################
229+# Coded by: Luis Torres (luis_t@vauxoo.com)
230+############################################################################
231+#
232+# This program is free software: you can redistribute it and/or modify
233+# it under the terms of the GNU Affero General Public License as
234+# published by the Free Software Foundation, either version 3 of the
235+# License, or (at your option) any later version.
236+#
237+# This program is distributed in the hope that it will be useful,
238+# but WITHOUT ANY WARRANTY; without even the implied warranty of
239+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
240+# GNU Affero General Public License for more details.
241+#
242+# You should have received a copy of the GNU Affero General Public License
243+# along with this program. If not, see <http://www.gnu.org/licenses/>.
244+#
245+##############################################################################
246+'''
247+File to add functionalitity in account.invoice.line to get the amount without
248+discount and the value of the discount
249+'''
250+from openerp.osv import osv
251+
252+
253+class sale_config_settings(osv.TransientModel):
254+ _inherit = 'sale.config.settings'
255+
256+ def get_default_sale_config_settings(self, cr, uid, fields, context=None):
257+ return {'group_discount_per_so_line': True}
258+
259+ def action_sale_config_settings(self, cr, uid, context=None):
260+ res = self.create(cr, uid, {'group_discount_per_so_line': True},
261+ context=context)
262+ self.execute(cr, uid, [res], context=context)
263+ return True
264
265=== added file 'invoice_discount/model/invoice.py'
266--- invoice_discount/model/invoice.py 1970-01-01 00:00:00 +0000
267+++ invoice_discount/model/invoice.py 2014-10-02 16:52:39 +0000
268@@ -0,0 +1,159 @@
269+# -*- encoding: utf-8 -*-
270+###########################################################################
271+# Module Writen to OpenERP, Open Source Management Solution
272+#
273+# Copyright (c) 2014 Vauxoo - http://www.vauxoo.com/
274+# All Rights Reserved.
275+# info Vauxoo (info@vauxoo.com)
276+############################################################################
277+# Coded by: Luis Torres (luis_t@vauxoo.com)
278+############################################################################
279+#
280+# This program is free software: you can redistribute it and/or modify
281+# it under the terms of the GNU Affero General Public License as
282+# published by the Free Software Foundation, either version 3 of the
283+# License, or (at your option) any later version.
284+#
285+# This program is distributed in the hope that it will be useful,
286+# but WITHOUT ANY WARRANTY; without even the implied warranty of
287+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
288+# GNU Affero General Public License for more details.
289+#
290+# You should have received a copy of the GNU Affero General Public License
291+# along with this program. If not, see <http://www.gnu.org/licenses/>.
292+#
293+##############################################################################
294+'''
295+File to add functionalitity in account.invoice.line to get the amount without
296+discount and the value of the discount
297+'''
298+from openerp.osv import osv, fields
299+
300+
301+class account_invoice_line(osv.osv):
302+
303+ '''
304+ Inherit from account.invoice.line to get by line the amount without
305+ discount and the amount of this
306+ '''
307+ _inherit = 'account.invoice.line'
308+
309+ def _get_subtotal_without_discount(self, cr, uid, ids, args, field_name,
310+ context=None):
311+ '''
312+ Method to get the subtotal of the amount without discount
313+ @param self: The object pointer.
314+ @param cr: A database cursor
315+ @param uid: ID of the user currently logged in
316+ @param ids: list of ids for which name should be read
317+ @param field_name: field that call the method
318+ @param arg: Extra arguments
319+ @param context: A standard dictionary
320+ @return : Dict with values
321+ '''
322+ context = context or {}
323+ res = {}
324+ for line in self.browse(cr, uid, ids, context=context):
325+ res[line.id] = (line.quantity * line.price_unit)
326+ return res
327+
328+ def _get_discount(self, cr, uid, ids, args, field_name, context=None):
329+ '''
330+ Method to get the amount of discount, is used subtraction by rounding
331+ @param self: The object pointer.
332+ @param cr: A database cursor
333+ @param uid: ID of the user currently logged in
334+ @param ids: list of ids for which name should be read
335+ @param field_name: field that call the method
336+ @param arg: Extra arguments
337+ @param context: A standard dictionary
338+ @return : Dict with values
339+ '''
340+ context = context or {}
341+ res = {}
342+ for line in self.browse(cr, uid, ids, context=context):
343+ res[line.id] = line.discount * line.subtotal_wo_discount / 100
344+ return res
345+
346+ _columns = {
347+ 'subtotal_wo_discount': fields.function(_get_subtotal_without_discount,
348+ string='SubTotal w/o Discount',
349+ store=True, type='float',
350+ help='Amount without apply \
351+ the discount of the line, is \
352+ calculated as Qty * Price Unit'
353+ ),
354+ 'discount_amount': fields.function(_get_discount,
355+ string='Discount Amount',
356+ store=False, type='float',
357+ help='Amount total of the discount,\
358+ is calculated as Discount * \
359+ SubTotal w/o Discount / 100.'),
360+ }
361+
362+
363+class account_invoice(osv.osv):
364+
365+ '''
366+ Inherit from account.invoice to get the amount total without discount and
367+ the amount total of this, of all invoice lines.
368+ '''
369+ _inherit = 'account.invoice'
370+
371+ def _get_subtotal_without_discount(self, cr, uid, ids, args, field_name,
372+ context=None):
373+ '''
374+ Method to get the subtotal of the amount without discount of the sum of
375+ invoice lines.
376+ @param self: The object pointer.
377+ @param cr: A database cursor
378+ @param uid: ID of the user currently logged in
379+ @param ids: list of ids for which name should be read
380+ @param field_name: field that call the method
381+ @param arg: Extra arguments
382+ @param context: A standard dictionary
383+ @return : Dict with values
384+ '''
385+ context = context or {}
386+ total = 0.0
387+ res = {}
388+ for inv in self.browse(cr, uid, ids, context=context):
389+ for line in inv.invoice_line:
390+ total += line.subtotal_wo_discount
391+ res[inv.id] = total
392+ return res
393+
394+ def _get_discount(self, cr, uid, ids, args, field_name, context=None):
395+ '''
396+ Method to get the amount total of discount in the invoice lines.
397+ @param self: The object pointer.
398+ @param cr: A database cursor
399+ @param uid: ID of the user currently logged in
400+ @param ids: list of ids for which name should be read
401+ @param field_name: field that call the method
402+ @param arg: Extra arguments
403+ @param context: A standard dictionary
404+ @return : Dict with values
405+ '''
406+ context = context or {}
407+ total = 0.0
408+ res = {}
409+ for inv in self.browse(cr, uid, ids, context=context):
410+ for line in inv.invoice_line:
411+ total += line.discount_amount
412+ res[inv.id] = total
413+ return res
414+
415+ _columns = {
416+ 'subtotal_wo_discount': fields.function(_get_subtotal_without_discount,
417+ string='SubTotal w/o Discount',
418+ store=True, type='float',
419+ help='Amount without apply the\
420+ discount of the lines of the \
421+ invoice.'),
422+ 'discount_amount': fields.function(_get_discount, string='Discount',
423+ store=False, type='float',
424+ help='Total of discount apply in \
425+ each line of the invoice.'),
426+ }
427+
428
429=== added directory 'invoice_discount/view'
430=== added file 'invoice_discount/view/config_settings_action.xml'
431--- invoice_discount/view/config_settings_action.xml 1970-01-01 00:00:00 +0000
432+++ invoice_discount/view/config_settings_action.xml 2014-10-02 16:52:39 +0000
433@@ -0,0 +1,6 @@
434+<?xml version="1.0" encoding="utf-8"?>
435+<openerp>
436+ <data noupdate="1">
437+ <function model="sale.config.settings" name="action_sale_config_settings"/>
438+ </data>
439+</openerp>
440
441=== added file 'invoice_discount/view/invoice_view.xml'
442--- invoice_discount/view/invoice_view.xml 1970-01-01 00:00:00 +0000
443+++ invoice_discount/view/invoice_view.xml 2014-10-02 16:52:39 +0000
444@@ -0,0 +1,42 @@
445+<?xml version="1.0" encoding="utf-8"?>
446+<openerp>
447+ <data>
448+
449+ <record model="ir.ui.view" id="view_account_invoice_form_inh_discount">
450+ <field name="name">view.account.invoice.form.inh.discount</field>
451+ <field name="model">account.invoice</field>
452+ <field name="inherit_id" ref="account.invoice_form"/>
453+ <field name="arch" type="xml">
454+ <xpath expr="//field[@name='invoice_line_tax_id']" position="after">
455+ <field name="subtotal_wo_discount" invisible='1'/>
456+ <field name="discount_amount" invisible='1'/>
457+ </xpath>
458+ </field>
459+ </record>
460+
461+ <record model="ir.ui.view" id="view_account_invoice_form_inh_discount_total">
462+ <field name="name">view.account.invoice.form.inh.discount.total</field>
463+ <field name="model">account.invoice</field>
464+ <field name="inherit_id" ref="account.invoice_form"/>
465+ <field name="arch" type="xml">
466+ <xpath expr="//field[@name='residual']" position="after">
467+ <field name="subtotal_wo_discount" invisible='1'/>
468+ <field name="discount_amount" invisible='1'/>
469+ </xpath>
470+ </field>
471+ </record>
472+
473+ <record model="ir.ui.view" id="view_account_invoice_tree_inh_discount">
474+ <field name="name">view.account.invoice.tree.inh.discount</field>
475+ <field name="model">account.invoice.line</field>
476+ <field name="inherit_id" ref="account.view_invoice_line_tree"/>
477+ <field name="arch" type="xml">
478+ <xpath expr="//field[@name='price_subtotal']" position="after">
479+ <field name="subtotal_wo_discount" invisible='1'/>
480+ <field name="discount_amount" invisible='1'/>
481+ </xpath>
482+ </field>
483+ </record>
484+
485+ </data>
486+</openerp>