Merge lp:~pedro.baeza/purchase-wkfl/7.0-purchase_discount into lp:~purchase-core-editors/purchase-wkfl/7.0
- 7.0-purchase_discount
- Merge into 7.0
Status: | Merged |
---|---|
Merged at revision: | 38 |
Proposed branch: | lp:~pedro.baeza/purchase-wkfl/7.0-purchase_discount |
Merge into: | lp:~purchase-core-editors/purchase-wkfl/7.0 |
Diff against target: |
867 lines (+806/-0) 11 files modified
purchase_discount/__init__.py (+21/-0) purchase_discount/__openerp__.py (+52/-0) purchase_discount/i18n/es.po (+43/-0) purchase_discount/i18n/es_ES.po (+43/-0) purchase_discount/i18n/pt_BR.po (+43/-0) purchase_discount/i18n/purchase_discount.pot (+42/-0) purchase_discount/models/purchase_discount.py (+135/-0) purchase_discount/report/order.rml (+365/-0) purchase_discount/report/purchase_discount_report.xml (+11/-0) purchase_discount/views/account_invoice_view.xml (+16/-0) purchase_discount/views/purchase_discount_view.xml (+35/-0) |
To merge this branch: | bzr merge lp:~pedro.baeza/purchase-wkfl/7.0-purchase_discount |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Guewen Baconnier @ Camptocamp | code review | Approve | |
Lorenzo Battistini (community) | code review | Approve | |
Omar (Pexego) | code review no test | Approve | |
Review via email: mp+217030@code.launchpad.net |
Commit message
Description of the change
[ADD] purchase_discount: Module that I ported some time ago to v7 and included in vauxoo-addons. I think this module deserves to be in OCA repositories to have a "standard" way for this common need.
- 32. By Pedro Manuel Baeza
-
[FIX] purchase_discount: Supplier invoice view with discount
- 33. By Pedro Manuel Baeza
-
PEP8 errors corrected
Pedro Manuel Baeza (pedro.baeza) wrote : | # |
Hi, Lorenzo, thanks for your review.
I have corrected flake8 output.
But about negative restriction in the percentage amount, I don't think it's a good idea, because you can apply a surcharge of whatever percentage you want: for example, -100% to double original price, -200% to triple it, and so on.
Regards.
Lorenzo Battistini (elbati) wrote : | # |
Ok, thanks.
What about the
amount_untaxed, amount_tax, amount_total
fields repeated 2 times?
- 34. By Pedro Manuel Baeza
-
[FIX] Duplicated field definition.
[IMP] self.pool[] instead of self.pool.get
Pedro Manuel Baeza (pedro.baeza) wrote : | # |
You're right. I don't know how can I overpassed that!
I have corrected.
Thanks. Regards.
Omar (Pexego) (omar7r) wrote : | # |
Thanks Pedro, I had long wanted to propose this module on the branch.
Lorenzo Battistini (elbati) : | # |
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
Hi,
I left some diff comments.
I'm also annoyed by the incompatibily introduced by this module (override of amount_all and amount_line), but on the other hand there is maybe no other way to do that.
Thanks Pedro
- 35. By Pedro Manuel Baeza
-
Some changes from Guewen's review
Pedro Manuel Baeza (pedro.baeza) wrote : | # |
Hi, Guewen, thanks for the review.
I have fixed your remarks.
I don't like also to overwrite function fields methods, but I assure you that there's no other way for now. I'm going to propose a hook method for purchase line base price on core to see if we can improve this module for next version.
Regards.
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
Great, thanks!
Preview Diff
1 | === added directory 'purchase_discount' | |||
2 | === added file 'purchase_discount/__init__.py' | |||
3 | --- purchase_discount/__init__.py 1970-01-01 00:00:00 +0000 | |||
4 | +++ purchase_discount/__init__.py 2014-06-20 10:14:35 +0000 | |||
5 | @@ -0,0 +1,21 @@ | |||
6 | 1 | # -*- encoding: utf-8 -*- | ||
7 | 2 | ############################################################################## | ||
8 | 3 | # | ||
9 | 4 | # OpenERP, Open Source Management Solution | ||
10 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
11 | 6 | # | ||
12 | 7 | # This program is free software: you can redistribute it and/or modify | ||
13 | 8 | # it under the terms of the GNU Affero General Public License as | ||
14 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
15 | 10 | # License, or (at your option) any later version. | ||
16 | 11 | # | ||
17 | 12 | # This program is distributed in the hope that it will be useful, | ||
18 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | 15 | # GNU Affero General Public License for more details. | ||
21 | 16 | # | ||
22 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
23 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
24 | 19 | # | ||
25 | 20 | ############################################################################## | ||
26 | 21 | from . import models | ||
27 | 0 | 22 | ||
28 | === added file 'purchase_discount/__openerp__.py' | |||
29 | --- purchase_discount/__openerp__.py 1970-01-01 00:00:00 +0000 | |||
30 | +++ purchase_discount/__openerp__.py 2014-06-20 10:14:35 +0000 | |||
31 | @@ -0,0 +1,52 @@ | |||
32 | 1 | # -*- encoding: utf-8 -*- | ||
33 | 2 | ############################################################################## | ||
34 | 3 | # | ||
35 | 4 | # OpenERP, Open Source Management Solution | ||
36 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
37 | 6 | # | ||
38 | 7 | # This program is free software: you can redistribute it and/or modify | ||
39 | 8 | # it under the terms of the GNU Affero General Public License as | ||
40 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
41 | 10 | # License, or (at your option) any later version. | ||
42 | 11 | # | ||
43 | 12 | # This program is distributed in the hope that it will be useful, | ||
44 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
45 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
46 | 15 | # GNU Affero General Public License for more details. | ||
47 | 16 | # | ||
48 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
49 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
50 | 19 | # | ||
51 | 20 | ############################################################################## | ||
52 | 21 | { | ||
53 | 22 | "name": "Purchase order lines with discounts", | ||
54 | 23 | "author": "Tiny, Acysos S.L.", | ||
55 | 24 | "description": """ | ||
56 | 25 | It allows to define a discount per line in the purchase | ||
57 | 26 | orders. This discount can be also negative, interpreting it as an increment. | ||
58 | 27 | |||
59 | 28 | **REMARK**: This module can be incompatible with other modules that modify | ||
60 | 29 | purchase prices, because it overwrites computation methods. | ||
61 | 30 | |||
62 | 31 | **Contributors**: | ||
63 | 32 | * Pedro Manuel Baeza <pedro.baeza@serviciosbaeza.com> | ||
64 | 33 | """, | ||
65 | 34 | "version": "1.0", | ||
66 | 35 | "contributors": [ | ||
67 | 36 | 'Pedro M. Baeza', | ||
68 | 37 | ], | ||
69 | 38 | "category": "Generic Modules/Sales & Purchases", | ||
70 | 39 | "depends": [ | ||
71 | 40 | "stock", | ||
72 | 41 | "purchase", | ||
73 | 42 | ], | ||
74 | 43 | "demo": [], | ||
75 | 44 | "data": [ | ||
76 | 45 | "purchase_discount_view.xml", | ||
77 | 46 | "account_invoice_view.xml", | ||
78 | 47 | "report/purchase_discount_report.xml", | ||
79 | 48 | ], | ||
80 | 49 | "license": 'AGPL-3', | ||
81 | 50 | "installable": True | ||
82 | 51 | } | ||
83 | 52 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
84 | 0 | 53 | ||
85 | === added directory 'purchase_discount/i18n' | |||
86 | === added file 'purchase_discount/i18n/es.po' | |||
87 | --- purchase_discount/i18n/es.po 1970-01-01 00:00:00 +0000 | |||
88 | +++ purchase_discount/i18n/es.po 2014-06-20 10:14:35 +0000 | |||
89 | @@ -0,0 +1,43 @@ | |||
90 | 1 | # Translation of OpenERP Server. | ||
91 | 2 | # This file contains the translation of the following modules: | ||
92 | 3 | # * purchase_discount | ||
93 | 4 | # | ||
94 | 5 | msgid "" | ||
95 | 6 | msgstr "" | ||
96 | 7 | "Project-Id-Version: OpenERP Server 5.0.11\n" | ||
97 | 8 | "Report-Msgid-Bugs-To: support@openerp.com\n" | ||
98 | 9 | "POT-Creation-Date: 2013-11-07 01:07+0000\n" | ||
99 | 10 | "PO-Revision-Date: 2013-11-08 17:57+0000\n" | ||
100 | 11 | "Last-Translator: hbto [Vauxoo] http://www.vauxoo.com " | ||
101 | 12 | "<humbertoarocha@gmail.com>\n" | ||
102 | 13 | "Language-Team: \n" | ||
103 | 14 | "MIME-Version: 1.0\n" | ||
104 | 15 | "Content-Type: text/plain; charset=UTF-8\n" | ||
105 | 16 | "Content-Transfer-Encoding: 8bit\n" | ||
106 | 17 | "X-Launchpad-Export-Date: 2014-01-29 06:04+0000\n" | ||
107 | 18 | "X-Generator: Launchpad (build 16916)\n" | ||
108 | 19 | |||
109 | 20 | #. module: purchase_discount | ||
110 | 21 | #: model:ir.model,name:purchase_discount.model_purchase_order | ||
111 | 22 | msgid "Purchase Order" | ||
112 | 23 | msgstr "Orden de Compra" | ||
113 | 24 | |||
114 | 25 | #. module: purchase_discount | ||
115 | 26 | #: model:ir.model,name:purchase_discount.model_stock_picking | ||
116 | 27 | msgid "Picking List" | ||
117 | 28 | msgstr "Albarán" | ||
118 | 29 | |||
119 | 30 | #. module: purchase_discount | ||
120 | 31 | #: sql_constraint:purchase.order.line:0 | ||
121 | 32 | msgid "Discount must be lower than 100%." | ||
122 | 33 | msgstr "El desduento debe ser menor al 100%." | ||
123 | 34 | |||
124 | 35 | #. module: purchase_discount | ||
125 | 36 | #: model:ir.model,name:purchase_discount.model_purchase_order_line | ||
126 | 37 | msgid "Purchase Order Line" | ||
127 | 38 | msgstr "LÃnea orden de compra" | ||
128 | 39 | |||
129 | 40 | #. module: purchase_discount | ||
130 | 41 | #: field:purchase.order.line,discount:0 | ||
131 | 42 | msgid "Discount (%)" | ||
132 | 43 | msgstr "(%) Descuento" | ||
133 | 0 | 44 | ||
134 | === added file 'purchase_discount/i18n/es_ES.po' | |||
135 | --- purchase_discount/i18n/es_ES.po 1970-01-01 00:00:00 +0000 | |||
136 | +++ purchase_discount/i18n/es_ES.po 2014-06-20 10:14:35 +0000 | |||
137 | @@ -0,0 +1,43 @@ | |||
138 | 1 | # Translation of OpenERP Server. | ||
139 | 2 | # This file contains the translation of the following modules: | ||
140 | 3 | # * purchase_discount | ||
141 | 4 | # | ||
142 | 5 | msgid "" | ||
143 | 6 | msgstr "" | ||
144 | 7 | "Project-Id-Version: OpenERP Server 5.0.11\n" | ||
145 | 8 | "Report-Msgid-Bugs-To: support@openerp.com\n" | ||
146 | 9 | "POT-Creation-Date: 2013-11-07 01:07+0000\n" | ||
147 | 10 | "PO-Revision-Date: 2013-11-07 04:36+0000\n" | ||
148 | 11 | "Last-Translator: Moisés López - http://www.vauxoo.com " | ||
149 | 12 | "<moylop260@vauxoo.com>\n" | ||
150 | 13 | "Language-Team: \n" | ||
151 | 14 | "MIME-Version: 1.0\n" | ||
152 | 15 | "Content-Type: text/plain; charset=UTF-8\n" | ||
153 | 16 | "Content-Transfer-Encoding: 8bit\n" | ||
154 | 17 | "X-Launchpad-Export-Date: 2014-01-29 06:04+0000\n" | ||
155 | 18 | "X-Generator: Launchpad (build 16916)\n" | ||
156 | 19 | |||
157 | 20 | #. module: purchase_discount | ||
158 | 21 | #: model:ir.model,name:purchase_discount.model_purchase_order | ||
159 | 22 | msgid "Purchase Order" | ||
160 | 23 | msgstr "" | ||
161 | 24 | |||
162 | 25 | #. module: purchase_discount | ||
163 | 26 | #: model:ir.model,name:purchase_discount.model_stock_picking | ||
164 | 27 | msgid "Picking List" | ||
165 | 28 | msgstr "" | ||
166 | 29 | |||
167 | 30 | #. module: purchase_discount | ||
168 | 31 | #: sql_constraint:purchase.order.line:0 | ||
169 | 32 | msgid "Discount must be lower than 100%." | ||
170 | 33 | msgstr "" | ||
171 | 34 | |||
172 | 35 | #. module: purchase_discount | ||
173 | 36 | #: model:ir.model,name:purchase_discount.model_purchase_order_line | ||
174 | 37 | msgid "Purchase Order Line" | ||
175 | 38 | msgstr "" | ||
176 | 39 | |||
177 | 40 | #. module: purchase_discount | ||
178 | 41 | #: field:purchase.order.line,discount:0 | ||
179 | 42 | msgid "Discount (%)" | ||
180 | 43 | msgstr "(%) Descuento" | ||
181 | 0 | 44 | ||
182 | === added file 'purchase_discount/i18n/pt_BR.po' | |||
183 | --- purchase_discount/i18n/pt_BR.po 1970-01-01 00:00:00 +0000 | |||
184 | +++ purchase_discount/i18n/pt_BR.po 2014-06-20 10:14:35 +0000 | |||
185 | @@ -0,0 +1,43 @@ | |||
186 | 1 | # Brazilian Portuguese translation for addons-vauxoo | ||
187 | 2 | # Copyright (c) 2013 Rosetta Contributors and Canonical Ltd 2013 | ||
188 | 3 | # This file is distributed under the same license as the addons-vauxoo package. | ||
189 | 4 | # FIRST AUTHOR <EMAIL@ADDRESS>, 2013. | ||
190 | 5 | # | ||
191 | 6 | msgid "" | ||
192 | 7 | msgstr "" | ||
193 | 8 | "Project-Id-Version: addons-vauxoo\n" | ||
194 | 9 | "Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n" | ||
195 | 10 | "POT-Creation-Date: 2013-11-07 01:07+0000\n" | ||
196 | 11 | "PO-Revision-Date: 2013-07-28 13:28+0000\n" | ||
197 | 12 | "Last-Translator: Claudio de Araujo Santos <claudioaraujosantos@gmail.com>\n" | ||
198 | 13 | "Language-Team: Brazilian Portuguese <pt_BR@li.org>\n" | ||
199 | 14 | "MIME-Version: 1.0\n" | ||
200 | 15 | "Content-Type: text/plain; charset=UTF-8\n" | ||
201 | 16 | "Content-Transfer-Encoding: 8bit\n" | ||
202 | 17 | "X-Launchpad-Export-Date: 2014-01-29 06:04+0000\n" | ||
203 | 18 | "X-Generator: Launchpad (build 16916)\n" | ||
204 | 19 | |||
205 | 20 | #. module: purchase_discount | ||
206 | 21 | #: model:ir.model,name:purchase_discount.model_purchase_order | ||
207 | 22 | msgid "Purchase Order" | ||
208 | 23 | msgstr "Ordem de Compra" | ||
209 | 24 | |||
210 | 25 | #. module: purchase_discount | ||
211 | 26 | #: model:ir.model,name:purchase_discount.model_stock_picking | ||
212 | 27 | msgid "Picking List" | ||
213 | 28 | msgstr "" | ||
214 | 29 | |||
215 | 30 | #. module: purchase_discount | ||
216 | 31 | #: sql_constraint:purchase.order.line:0 | ||
217 | 32 | msgid "Discount must be lower than 100%." | ||
218 | 33 | msgstr "" | ||
219 | 34 | |||
220 | 35 | #. module: purchase_discount | ||
221 | 36 | #: model:ir.model,name:purchase_discount.model_purchase_order_line | ||
222 | 37 | msgid "Purchase Order Line" | ||
223 | 38 | msgstr "" | ||
224 | 39 | |||
225 | 40 | #. module: purchase_discount | ||
226 | 41 | #: field:purchase.order.line,discount:0 | ||
227 | 42 | msgid "Discount (%)" | ||
228 | 43 | msgstr "Desconto (%)" | ||
229 | 0 | 44 | ||
230 | === added file 'purchase_discount/i18n/purchase_discount.pot' | |||
231 | --- purchase_discount/i18n/purchase_discount.pot 1970-01-01 00:00:00 +0000 | |||
232 | +++ purchase_discount/i18n/purchase_discount.pot 2014-06-20 10:14:35 +0000 | |||
233 | @@ -0,0 +1,42 @@ | |||
234 | 1 | # Translation of OpenERP Server. | ||
235 | 2 | # This file contains the translation of the following modules: | ||
236 | 3 | # * purchase_discount | ||
237 | 4 | # | ||
238 | 5 | msgid "" | ||
239 | 6 | msgstr "" | ||
240 | 7 | "Project-Id-Version: OpenERP Server 7.0\n" | ||
241 | 8 | "Report-Msgid-Bugs-To: \n" | ||
242 | 9 | "POT-Creation-Date: 2013-11-07 01:07+0000\n" | ||
243 | 10 | "PO-Revision-Date: 2013-11-07 01:07+0000\n" | ||
244 | 11 | "Last-Translator: <>\n" | ||
245 | 12 | "Language-Team: \n" | ||
246 | 13 | "MIME-Version: 1.0\n" | ||
247 | 14 | "Content-Type: text/plain; charset=UTF-8\n" | ||
248 | 15 | "Content-Transfer-Encoding: \n" | ||
249 | 16 | "Plural-Forms: \n" | ||
250 | 17 | |||
251 | 18 | #. module: purchase_discount | ||
252 | 19 | #: model:ir.model,name:purchase_discount.model_purchase_order | ||
253 | 20 | msgid "Purchase Order" | ||
254 | 21 | msgstr "" | ||
255 | 22 | |||
256 | 23 | #. module: purchase_discount | ||
257 | 24 | #: model:ir.model,name:purchase_discount.model_stock_picking | ||
258 | 25 | msgid "Picking List" | ||
259 | 26 | msgstr "" | ||
260 | 27 | |||
261 | 28 | #. module: purchase_discount | ||
262 | 29 | #: sql_constraint:purchase.order.line:0 | ||
263 | 30 | msgid "Discount must be lower than 100%." | ||
264 | 31 | msgstr "" | ||
265 | 32 | |||
266 | 33 | #. module: purchase_discount | ||
267 | 34 | #: model:ir.model,name:purchase_discount.model_purchase_order_line | ||
268 | 35 | msgid "Purchase Order Line" | ||
269 | 36 | msgstr "" | ||
270 | 37 | |||
271 | 38 | #. module: purchase_discount | ||
272 | 39 | #: field:purchase.order.line,discount:0 | ||
273 | 40 | msgid "Discount (%)" | ||
274 | 41 | msgstr "" | ||
275 | 42 | |||
276 | 0 | 43 | ||
277 | === added directory 'purchase_discount/models' | |||
278 | === added file 'purchase_discount/models/purchase_discount.py' | |||
279 | --- purchase_discount/models/purchase_discount.py 1970-01-01 00:00:00 +0000 | |||
280 | +++ purchase_discount/models/purchase_discount.py 2014-06-20 10:14:35 +0000 | |||
281 | @@ -0,0 +1,135 @@ | |||
282 | 1 | # -*- encoding: utf-8 -*- | ||
283 | 2 | ############################################################################## | ||
284 | 3 | # | ||
285 | 4 | # OpenERP, Open Source Management Solution | ||
286 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
287 | 6 | # | ||
288 | 7 | # This program is free software: you can redistribute it and/or modify | ||
289 | 8 | # it under the terms of the GNU Affero General Public License as | ||
290 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
291 | 10 | # License, or (at your option) any later version. | ||
292 | 11 | # | ||
293 | 12 | # This program is distributed in the hope that it will be useful, | ||
294 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
295 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
296 | 15 | # GNU Affero General Public License for more details. | ||
297 | 16 | # | ||
298 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
299 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
300 | 19 | # | ||
301 | 20 | ############################################################################## | ||
302 | 21 | from openerp.osv import fields, orm | ||
303 | 22 | import openerp.addons.decimal_precision as dp | ||
304 | 23 | |||
305 | 24 | |||
306 | 25 | class PurchaseOrderLine(orm.Model): | ||
307 | 26 | _inherit = "purchase.order.line" | ||
308 | 27 | |||
309 | 28 | def _amount_line(self, cr, uid, ids, field_name, arg, context=None): | ||
310 | 29 | res = {} | ||
311 | 30 | cur_obj = self.pool['res.currency'] | ||
312 | 31 | tax_obj = self.pool['account.tax'] | ||
313 | 32 | for line in self.browse(cr, uid, ids, context=context): | ||
314 | 33 | discount = line.discount or 0.0 | ||
315 | 34 | new_price_unit = line.price_unit * (1 - discount / 100.0) | ||
316 | 35 | taxes = tax_obj.compute_all(cr, uid, line.taxes_id, new_price_unit, | ||
317 | 36 | line.product_qty, line.product_id, | ||
318 | 37 | line.order_id.partner_id) | ||
319 | 38 | currency = line.order_id.pricelist_id.currency_id | ||
320 | 39 | res[line.id] = cur_obj.round(cr, uid, currency, taxes['total']) | ||
321 | 40 | return res | ||
322 | 41 | |||
323 | 42 | _columns = { | ||
324 | 43 | 'discount': fields.float('Discount (%)', dp.get_precision('Discount'), | ||
325 | 44 | 'price_subtotal': fields.function( | ||
326 | 45 | _amount_line, string='Subtotal', | ||
327 | 46 | digits_compute=dp.get_precision('Account')), | ||
328 | 47 | } | ||
329 | 48 | |||
330 | 49 | _defaults = { | ||
331 | 50 | 'discount': 0.0, | ||
332 | 51 | } | ||
333 | 52 | |||
334 | 53 | _sql_constraints = [ | ||
335 | 54 | ('discount_limit', 'CHECK (discount <= 100.0)', | ||
336 | 55 | 'Discount must be lower than 100%.'), | ||
337 | 56 | ] | ||
338 | 57 | |||
339 | 58 | |||
340 | 59 | class PurchaseOrder(orm.Model): | ||
341 | 60 | _inherit = "purchase.order" | ||
342 | 61 | |||
343 | 62 | def _amount_all(self, cr, uid, ids, field_name, arg, context=None): | ||
344 | 63 | res = {} | ||
345 | 64 | cur_obj = self.pool['res.currency'] | ||
346 | 65 | tax_obj = self.pool['account.tax'] | ||
347 | 66 | for order in self.browse(cr, uid, ids, context=context): | ||
348 | 67 | val = {} | ||
349 | 68 | amount_taxed = amount_untaxed = 0.0 | ||
350 | 69 | currency = order.pricelist_id.currency_id | ||
351 | 70 | for line in order.order_line: | ||
352 | 71 | amount_untaxed += line.price_subtotal | ||
353 | 72 | discount = line.discount or 0.0 | ||
354 | 73 | new_price_unit = line.price_unit * (1 - discount / 100.0) | ||
355 | 74 | for c in tax_obj.compute_all(cr, uid, line.taxes_id, | ||
356 | 75 | new_price_unit, | ||
357 | 76 | line.product_qty, | ||
358 | 77 | line.product_id.id, | ||
359 | 78 | order.partner_id)['taxes']: | ||
360 | 79 | amount_taxed += c.get('amount', 0.0) | ||
361 | 80 | val['amount_tax'] = cur_obj.round(cr, uid, currency, amount_taxed) | ||
362 | 81 | val['amount_untaxed'] = cur_obj.round(cr, uid, currency, | ||
363 | 82 | amount_untaxed) | ||
364 | 83 | val['amount_total'] = (val['amount_untaxed'] + val['amount_tax']) | ||
365 | 84 | res[order.id] = val | ||
366 | 85 | return res | ||
367 | 86 | |||
368 | 87 | def _prepare_inv_line(self, cr, uid, account_id, order_line, | ||
369 | 88 | context=None): | ||
370 | 89 | result = super(PurchaseOrder, self)._prepare_inv_line(cr, uid, | ||
371 | 90 | account_id, | ||
372 | 91 | order_line, | ||
373 | 92 | context) | ||
374 | 93 | result['discount'] = order_line.discount or 0.0 | ||
375 | 94 | return result | ||
376 | 95 | |||
377 | 96 | def _get_order(self, cr, uid, ids, context=None): | ||
378 | 97 | result = set() | ||
379 | 98 | po_line_obj = self.pool['purchase.order.line'] | ||
380 | 99 | for line in po_line_obj.browse(cr, uid, ids, context=context): | ||
381 | 100 | result.add(line.order_id.id) | ||
382 | 101 | return list(result) | ||
383 | 102 | |||
384 | 103 | _columns = { | ||
385 | 104 | 'amount_untaxed': fields.function( | ||
386 | 105 | _amount_all, digits_compute=dp.get_precision('Account'), | ||
387 | 106 | string='Untaxed Amount', | ||
388 | 107 | store={ | ||
389 | 108 | 'purchase.order.line': (_get_order, None, 10), | ||
390 | 109 | }, multi="sums", help="The amount without tax"), | ||
391 | 110 | 'amount_tax': fields.function( | ||
392 | 111 | _amount_all, digits_compute=dp.get_precision('Account'), | ||
393 | 112 | string='Taxes', | ||
394 | 113 | store={ | ||
395 | 114 | 'purchase.order.line': (_get_order, None, 10), | ||
396 | 115 | }, multi="sums", help="The tax amount"), | ||
397 | 116 | 'amount_total': fields.function( | ||
398 | 117 | _amount_all, digits_compute=dp.get_precision('Account'), | ||
399 | 118 | string='Total', | ||
400 | 119 | store={ | ||
401 | 120 | 'purchase.order.line': (_get_order, None, 10), | ||
402 | 121 | }, multi="sums", help="The total amount"), | ||
403 | 122 | } | ||
404 | 123 | |||
405 | 124 | |||
406 | 125 | class StockPicking(orm.Model): | ||
407 | 126 | _inherit = 'stock.picking' | ||
408 | 127 | |||
409 | 128 | def _invoice_line_hook(self, cr, uid, move_line, invoice_line_id): | ||
410 | 129 | if move_line.purchase_line_id: | ||
411 | 130 | line = {'discount': move_line.purchase_line_id.discount} | ||
412 | 131 | self.pool['account.invoice.line'].write(cr, uid, | ||
413 | 132 | [invoice_line_id], line) | ||
414 | 133 | return super(StockPicking, self)._invoice_line_hook(cr, uid, | ||
415 | 134 | move_line, | ||
416 | 135 | invoice_line_id) | ||
417 | 0 | 136 | ||
418 | === added directory 'purchase_discount/report' | |||
419 | === added file 'purchase_discount/report/order.rml' | |||
420 | --- purchase_discount/report/order.rml 1970-01-01 00:00:00 +0000 | |||
421 | +++ purchase_discount/report/order.rml 2014-06-20 10:14:35 +0000 | |||
422 | @@ -0,0 +1,365 @@ | |||
423 | 1 | <?xml version="1.0"?> | ||
424 | 2 | <document filename="test.pdf"> | ||
425 | 3 | <template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20"> | ||
426 | 4 | <pageTemplate id="first"> | ||
427 | 5 | <frame id="first" x1="18.0" y1="42.0" width="535" height="758"/> | ||
428 | 6 | </pageTemplate> | ||
429 | 7 | </template> | ||
430 | 8 | <stylesheet> | ||
431 | 9 | <blockTableStyle id="Standard_Outline"> | ||
432 | 10 | <blockAlignment value="LEFT"/> | ||
433 | 11 | <blockValign value="TOP"/> | ||
434 | 12 | </blockTableStyle> | ||
435 | 13 | <blockTableStyle id="Tableau1"> | ||
436 | 14 | <blockAlignment value="LEFT"/> | ||
437 | 15 | <blockValign value="TOP"/> | ||
438 | 16 | </blockTableStyle> | ||
439 | 17 | <blockTableStyle id="Tableau2"> | ||
440 | 18 | <blockAlignment value="LEFT"/> | ||
441 | 19 | <blockValign value="TOP"/> | ||
442 | 20 | </blockTableStyle> | ||
443 | 21 | <blockTableStyle id="Header_Order_Reference_Tbl"> | ||
444 | 22 | <blockAlignment value="LEFT"/> | ||
445 | 23 | <blockValign value="TOP"/> | ||
446 | 24 | <lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="0,0" stop="0,-1"/> | ||
447 | 25 | <lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="0,0" stop="0,0"/> | ||
448 | 26 | <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,-1" stop="0,-1"/> | ||
449 | 27 | <lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="1,0" stop="1,-1"/> | ||
450 | 28 | <lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="1,0" stop="1,0"/> | ||
451 | 29 | <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="1,-1" stop="1,-1"/> | ||
452 | 30 | <lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="2,0" stop="2,-1"/> | ||
453 | 31 | <lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="2,0" stop="2,0"/> | ||
454 | 32 | <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="2,-1" stop="2,-1"/> | ||
455 | 33 | <lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="3,0" stop="3,-1"/> | ||
456 | 34 | <lineStyle kind="LINEAFTER" colorName="#e6e6e6" start="3,0" stop="3,-1"/> | ||
457 | 35 | <lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="3,0" stop="3,0"/> | ||
458 | 36 | <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="3,-1" stop="3,-1"/> | ||
459 | 37 | </blockTableStyle> | ||
460 | 38 | <blockTableStyle id="Content_Order_Reference_Table"> | ||
461 | 39 | <blockAlignment value="LEFT"/> | ||
462 | 40 | <blockValign value="TOP"/> | ||
463 | 41 | <lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="0,0" stop="0,-1"/> | ||
464 | 42 | <lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="0,0" stop="0,0"/> | ||
465 | 43 | <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,-1" stop="0,-1"/> | ||
466 | 44 | <lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="1,0" stop="1,-1"/> | ||
467 | 45 | <lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="1,0" stop="1,0"/> | ||
468 | 46 | <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="1,-1" stop="1,-1"/> | ||
469 | 47 | <lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="2,0" stop="2,-1"/> | ||
470 | 48 | <lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="2,0" stop="2,0"/> | ||
471 | 49 | <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="2,-1" stop="2,-1"/> | ||
472 | 50 | <lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="3,0" stop="3,-1"/> | ||
473 | 51 | <lineStyle kind="LINEAFTER" colorName="#e6e6e6" start="3,0" stop="3,-1"/> | ||
474 | 52 | <lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="3,0" stop="3,0"/> | ||
475 | 53 | <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="3,-1" stop="3,-1"/> | ||
476 | 54 | </blockTableStyle> | ||
477 | 55 | <blockTableStyle id="Table_Header_Pur_ord_Line"> | ||
478 | 56 | <blockAlignment value="LEFT"/> | ||
479 | 57 | <blockValign value="TOP"/> | ||
480 | 58 | <lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/> | ||
481 | 59 | <lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/> | ||
482 | 60 | <lineStyle kind="LINEBELOW" colorName="#000000" start="2,-1" stop="2,-1"/> | ||
483 | 61 | <lineStyle kind="LINEBELOW" colorName="#000000" start="3,-1" stop="3,-1"/> | ||
484 | 62 | <lineStyle kind="LINEBELOW" colorName="#000000" start="4,-1" stop="4,-1"/> | ||
485 | 63 | <lineStyle kind="LINEBELOW" colorName="#000000" start="5,-1" stop="5,-1"/> | ||
486 | 64 | <lineStyle kind="LINEBELOW" colorName="#000000" start="6,-1" stop="6,-1"/> | ||
487 | 65 | </blockTableStyle> | ||
488 | 66 | <blockTableStyle id="Table_Order_Pur_line_Content"> | ||
489 | 67 | <blockAlignment value="LEFT"/> | ||
490 | 68 | <blockValign value="TOP"/> | ||
491 | 69 | <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,-1" stop="0,-1"/> | ||
492 | 70 | <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="1,-1" stop="1,-1"/> | ||
493 | 71 | <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="2,-1" stop="2,-1"/> | ||
494 | 72 | <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="3,-1" stop="3,-1"/> | ||
495 | 73 | <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="4,-1" stop="4,-1"/> | ||
496 | 74 | <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="5,-1" stop="5,-1"/> | ||
497 | 75 | <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="6,-1" stop="6,-1"/> | ||
498 | 76 | <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,-1" stop="0,-1"/> | ||
499 | 77 | <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="1,-1" stop="1,-1"/> | ||
500 | 78 | <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="2,-1" stop="2,-1"/> | ||
501 | 79 | <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="3,-1" stop="3,-1"/> | ||
502 | 80 | <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="4,-1" stop="4,-1"/> | ||
503 | 81 | <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="5,-1" stop="5,-1"/> | ||
504 | 82 | <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="6,-1" stop="6,-1"/> | ||
505 | 83 | </blockTableStyle> | ||
506 | 84 | <blockTableStyle id="Table_All_Total_Detail"> | ||
507 | 85 | <blockAlignment value="LEFT"/> | ||
508 | 86 | <blockValign value="TOP"/> | ||
509 | 87 | <lineStyle kind="LINEABOVE" colorName="#ffffff" start="0,0" stop="0,0"/> | ||
510 | 88 | <lineStyle kind="LINEABOVE" colorName="#000000" start="1,0" stop="1,0"/> | ||
511 | 89 | <lineStyle kind="LINEABOVE" colorName="#000000" start="2,0" stop="2,0"/> | ||
512 | 90 | <lineStyle kind="LINEABOVE" colorName="#000000" start="1,2" stop="1,2"/> | ||
513 | 91 | <lineStyle kind="LINEABOVE" colorName="#000000" start="2,2" stop="2,2"/> | ||
514 | 92 | </blockTableStyle> | ||
515 | 93 | <blockTableStyle id="Table_Outer_Notes"> | ||
516 | 94 | <blockAlignment value="LEFT"/> | ||
517 | 95 | <blockValign value="TOP"/> | ||
518 | 96 | </blockTableStyle> | ||
519 | 97 | <initialize> | ||
520 | 98 | <paraStyle name="all" alignment="justify"/> | ||
521 | 99 | </initialize> | ||
522 | 100 | <paraStyle name="Standard" fontName="Helvetica"/> | ||
523 | 101 | <paraStyle name="Text body" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/> | ||
524 | 102 | <paraStyle name="Header" fontName="Helvetica" fontSize="14.0" leading="17" spaceBefore="12.0" spaceAfter="6.0"/> | ||
525 | 103 | <paraStyle name="List" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/> | ||
526 | 104 | <paraStyle name="Table Contents" fontName="Helvetica"/> | ||
527 | 105 | <paraStyle name="Table Heading" fontName="Helvetica" alignment="CENTER"/> | ||
528 | 106 | <paraStyle name="Caption" fontName="Helvetica" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/> | ||
529 | 107 | <paraStyle name="Index" fontName="Helvetica"/> | ||
530 | 108 | <paraStyle name="Footer" fontName="Helvetica"/> | ||
531 | 109 | <paraStyle name="Horizontal Line" fontName="Helvetica" fontSize="6.0" leading="8" spaceBefore="0.0" spaceAfter="14.0"/> | ||
532 | 110 | <paraStyle name="terp_header" fontName="Helvetica-Bold" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/> | ||
533 | 111 | <paraStyle name="Heading 9" fontName="Helvetica-Bold" fontSize="75%" leading="NaN" spaceBefore="12.0" spaceAfter="6.0"/> | ||
534 | 112 | <paraStyle name="terp_tblheader_General" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="6.0" spaceAfter="6.0"/> | ||
535 | 113 | <paraStyle name="terp_tblheader_Details" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="6.0" spaceAfter="6.0"/> | ||
536 | 114 | <paraStyle name="terp_default_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> | ||
537 | 115 | <paraStyle name="terp_default_Bold_8" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> | ||
538 | 116 | <paraStyle name="terp_tblheader_General_Centre" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="6.0" spaceAfter="6.0"/> | ||
539 | 117 | <paraStyle name="terp_tblheader_General_Right" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="6.0" spaceAfter="6.0"/> | ||
540 | 118 | <paraStyle name="terp_tblheader_Details_Centre" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="6.0" spaceAfter="6.0"/> | ||
541 | 119 | <paraStyle name="terp_tblheader_Details_Right" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="6.0" spaceAfter="6.0"/> | ||
542 | 120 | <paraStyle name="terp_default_Right_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/> | ||
543 | 121 | <paraStyle name="terp_default_Centre_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/> | ||
544 | 122 | <paraStyle name="terp_header_Right" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/> | ||
545 | 123 | <paraStyle name="terp_header_Centre" fontName="Helvetica-Bold" fontSize="12.0" leading="15" alignment="CENTER" spaceBefore="12.0" spaceAfter="6.0"/> | ||
546 | 124 | <paraStyle name="terp_default_address" fontName="Helvetica" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> | ||
547 | 125 | <paraStyle name="terp_default_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> | ||
548 | 126 | <paraStyle name="terp_default_Bold_9" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> | ||
549 | 127 | <paraStyle name="terp_default_Centre_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/> | ||
550 | 128 | <paraStyle name="terp_default_Right_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/> | ||
551 | 129 | <paraStyle name="terp_default_Bold_9_Right" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/> | ||
552 | 130 | <paraStyle name="terp_default_8_Italic" fontName="Helvetica-Oblique" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> | ||
553 | 131 | <paraStyle name="terp_default_2" fontName="Helvetica" fontSize="2.0" leading="3" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> | ||
554 | 132 | <images/> | ||
555 | 133 | </stylesheet> | ||
556 | 134 | <story> | ||
557 | 135 | <para style="terp_default_8">[[repeatIn(objects,'o')]]</para> | ||
558 | 136 | <para style="terp_default_8">[[ setLang(o.partner_id.lang) ]]</para> | ||
559 | 137 | <para style="terp_default_9"> | ||
560 | 138 | <font color="white"> </font> | ||
561 | 139 | </para> | ||
562 | 140 | <blockTable colWidths="253.0,59.0,223.0" style="Tableau1"> | ||
563 | 141 | <tr> | ||
564 | 142 | <td> | ||
565 | 143 | <blockTable colWidths="253.0" style="Tableau2"> | ||
566 | 144 | <tr> | ||
567 | 145 | <td> | ||
568 | 146 | <para style="terp_default_9"> | ||
569 | 147 | <font color="white"> </font> | ||
570 | 148 | </para> | ||
571 | 149 | </td> | ||
572 | 150 | </tr> | ||
573 | 151 | <tr> | ||
574 | 152 | <td> | ||
575 | 153 | <para style="terp_default_9">[[ repeatIn(o.dest_address_id and [o.dest_address_id] or [],'addr') ]]</para> | ||
576 | 154 | <para style="terp_default_Bold_9">Shipping address :</para> | ||
577 | 155 | <para style="terp_default_9">[[ (o.dest_address_id and o.dest_address_id.name) or (o.warehouse_id and o.warehouse_id.name) or '']] </para> | ||
578 | 156 | <para style="terp_default_9">[[ (o.dest_address_id and display_address(o.dest_address_id)) or (o.warehouse_id and display_address(o.warehouse_id.partner_address_id)) or '']]</para> | ||
579 | 157 | </td> | ||
580 | 158 | </tr> | ||
581 | 159 | </blockTable> | ||
582 | 160 | <para style="terp_default_9"> | ||
583 | 161 | <font color="white"> </font> | ||
584 | 162 | </para> | ||
585 | 163 | </td> | ||
586 | 164 | <td> | ||
587 | 165 | <para style="terp_default_9"> | ||
588 | 166 | <font color="white"> </font> | ||
589 | 167 | </para> | ||
590 | 168 | </td> | ||
591 | 169 | <td> | ||
592 | 170 | <para style="terp_default_9">[[ (o.partner_id and o.partner_id.title and o.partner_id.title.name) or '' ]] [[ (o.partner_id and o.partner_id.name) or '' ]] </para> | ||
593 | 171 | <para style="terp_default_9">[[ o.partner_id and display_address(o.partner_id) ]] </para> | ||
594 | 172 | <para style="terp_default_9">Tél. : [[ (o.partner_address_id and o.partner_address_id.phone) or removeParentNode('para') ]]</para> | ||
595 | 173 | <para style="terp_default_9">Fax : [[ (o.partner_address_id and o.partner_address_id.fax) or removeParentNode('para') ]]</para> | ||
596 | 174 | <para style="terp_default_9">TVAÂ : [[ (o.partner_id and o.partner_id.vat) or removeParentNode('para') ]]</para> | ||
597 | 175 | </td> | ||
598 | 176 | </tr> | ||
599 | 177 | </blockTable> | ||
600 | 178 | <para style="terp_default_9"> | ||
601 | 179 | <font color="white"> </font> | ||
602 | 180 | </para> | ||
603 | 181 | <para style="terp_header">[[ o.state=='draft' and removeParentNode('para') ]] Purchase Order Confirmation N° [[ o.name ]]</para> | ||
604 | 182 | <para style="terp_header">[[ o.state<>'draft' and removeParentNode('para') ]] Request for Quotation N° [[ o.name ]]</para> | ||
605 | 183 | <para style="terp_default_8"> | ||
606 | 184 | <font color="white"> </font> | ||
607 | 185 | </para> | ||
608 | 186 | <blockTable colWidths="136.0,132.0,133.0,133.0" style="Header_Order_Reference_Tbl"> | ||
609 | 187 | <tr> | ||
610 | 188 | <td> | ||
611 | 189 | <para style="terp_tblheader_General_Centre">Our Order Reference</para> | ||
612 | 190 | </td> | ||
613 | 191 | <td> | ||
614 | 192 | <para style="terp_tblheader_General_Centre">Your Order Reference</para> | ||
615 | 193 | </td> | ||
616 | 194 | <td> | ||
617 | 195 | <para style="terp_tblheader_General_Centre">Order Date</para> | ||
618 | 196 | </td> | ||
619 | 197 | <td> | ||
620 | 198 | <para style="terp_tblheader_General_Centre">Validated By</para> | ||
621 | 199 | </td> | ||
622 | 200 | </tr> | ||
623 | 201 | </blockTable> | ||
624 | 202 | <blockTable colWidths="136.0,132.0,133.0,133.0" style="Content_Order_Reference_Table"> | ||
625 | 203 | <tr> | ||
626 | 204 | <td> | ||
627 | 205 | <para style="terp_default_Centre_8">[[ o.name or '' ]]</para> | ||
628 | 206 | </td> | ||
629 | 207 | <td> | ||
630 | 208 | <para style="terp_default_Centre_8">[[ o.partner_ref or '' ]]</para> | ||
631 | 209 | </td> | ||
632 | 210 | <td> | ||
633 | 211 | <para style="terp_default_Centre_8">[[formatLang(o.date_order,date=True) ]]</para> | ||
634 | 212 | </td> | ||
635 | 213 | <td> | ||
636 | 214 | <para style="terp_default_Centre_8">[[ (o.validator and o.validator.name) or '' ]]</para> | ||
637 | 215 | </td> | ||
638 | 216 | </tr> | ||
639 | 217 | </blockTable> | ||
640 | 218 | <para style="terp_default_9"> | ||
641 | 219 | <font color="white"> </font> | ||
642 | 220 | </para> | ||
643 | 221 | <blockTable colWidths="163.0,77.0,64.0,64.0,51.0,54.0,61.0" repeatRows="1" style="Table_Header_Pur_ord_Line"> | ||
644 | 222 | <tr> | ||
645 | 223 | <td> | ||
646 | 224 | <para style="terp_tblheader_Details">Description</para> | ||
647 | 225 | </td> | ||
648 | 226 | <td> | ||
649 | 227 | <para style="terp_tblheader_Details">Taxes</para> | ||
650 | 228 | </td> | ||
651 | 229 | <td> | ||
652 | 230 | <para style="terp_tblheader_Details_Centre">Date Req.</para> | ||
653 | 231 | </td> | ||
654 | 232 | <td> | ||
655 | 233 | <para style="terp_tblheader_Details_Centre">Qty</para> | ||
656 | 234 | </td> | ||
657 | 235 | <td> | ||
658 | 236 | <para style="terp_tblheader_Details_Right">Unit Price</para> | ||
659 | 237 | </td> | ||
660 | 238 | <td> | ||
661 | 239 | <para style="terp_tblheader_Details_Right">% Discount</para> | ||
662 | 240 | </td> | ||
663 | 241 | <td> | ||
664 | 242 | <para style="terp_tblheader_Details_Right">Net Price</para> | ||
665 | 243 | </td> | ||
666 | 244 | </tr> | ||
667 | 245 | </blockTable> | ||
668 | 246 | <section> | ||
669 | 247 | <para style="terp_default_8">[[repeatIn(o.order_line,'line')]]</para> | ||
670 | 248 | <blockTable colWidths="162.0,77.0,64.0,64.0,51.0,54.0,61.0" style="Table_Order_Pur_line_Content"> | ||
671 | 249 | <tr> | ||
672 | 250 | <td> | ||
673 | 251 | <para style="terp_default_9">[[ line.name ]]</para> | ||
674 | 252 | </td> | ||
675 | 253 | <td> | ||
676 | 254 | <para style="terp_default_9">[[ ', '.join(map(lambda x: x.name, line.taxes_id)) ]]</para> | ||
677 | 255 | </td> | ||
678 | 256 | <td> | ||
679 | 257 | <para style="terp_default_Centre_9">[[ formatLang( line.date_planned, date=True) ]]</para> | ||
680 | 258 | </td> | ||
681 | 259 | <td> | ||
682 | 260 | <para style="terp_default_Right_9">[[ formatLang(line.product_qty ) ]] [[ line.product_uom.name ]] </para> | ||
683 | 261 | </td> | ||
684 | 262 | <td> | ||
685 | 263 | <para style="terp_default_Right_9">[[ formatLang(line.price_unit, digits=get_digits(dp='Account') ) ]]</para> | ||
686 | 264 | </td> | ||
687 | 265 | <td> | ||
688 | 266 | <para style="terp_default_Right_9">[[ formatLang(line.discount, digits=get_digits(dp='Discount')) ]]</para> | ||
689 | 267 | </td> | ||
690 | 268 | <td> | ||
691 | 269 | <para style="terp_default_Right_9">[[ formatLang(line.price_subtotal, digits=get_digits(dp='Account') ) ]] [[ o.pricelist_id.currency_id.symbol ]]</para> | ||
692 | 270 | </td> | ||
693 | 271 | </tr> | ||
694 | 272 | <tr> | ||
695 | 273 | <td> | ||
696 | 274 | <para style="terp_default_8_Italic">[[ line.notes or removeParentNode('tr') ]]</para> | ||
697 | 275 | </td> | ||
698 | 276 | <td> | ||
699 | 277 | <para style="terp_default_9"> | ||
700 | 278 | <font color="white"> </font> | ||
701 | 279 | </para> | ||
702 | 280 | </td> | ||
703 | 281 | <td> | ||
704 | 282 | <para style="terp_default_Centre_9"> | ||
705 | 283 | <font color="white"> </font> | ||
706 | 284 | </para> | ||
707 | 285 | </td> | ||
708 | 286 | <td> | ||
709 | 287 | <para style="terp_default_Right_9"> | ||
710 | 288 | <font color="white"> </font> | ||
711 | 289 | </para> | ||
712 | 290 | </td> | ||
713 | 291 | <td> | ||
714 | 292 | <para style="terp_default_Right_9"> | ||
715 | 293 | <font color="white"> </font> | ||
716 | 294 | </para> | ||
717 | 295 | </td> | ||
718 | 296 | <td> | ||
719 | 297 | <para style="terp_default_Right_9"> | ||
720 | 298 | <font color="white"> </font> | ||
721 | 299 | </para> | ||
722 | 300 | </td> | ||
723 | 301 | <td> | ||
724 | 302 | <para style="terp_default_Right_9"> | ||
725 | 303 | <font color="white"> </font> | ||
726 | 304 | </para> | ||
727 | 305 | </td> | ||
728 | 306 | </tr> | ||
729 | 307 | </blockTable> | ||
730 | 308 | </section> | ||
731 | 309 | <blockTable colWidths="394.0,55.0,85.0" style="Table_All_Total_Detail"> | ||
732 | 310 | <tr> | ||
733 | 311 | <td> | ||
734 | 312 | <para style="terp_default_9"> | ||
735 | 313 | <font color="white"> </font> | ||
736 | 314 | </para> | ||
737 | 315 | </td> | ||
738 | 316 | <td> | ||
739 | 317 | <para style="terp_default_9">Net Total :</para> | ||
740 | 318 | </td> | ||
741 | 319 | <td> | ||
742 | 320 | <para style="terp_default_Right_9">[[ formatLang(o.amount_untaxed, digits=get_digits(dp='Account') ) ]] [[ o.pricelist_id.currency_id. symbol ]]</para> | ||
743 | 321 | </td> | ||
744 | 322 | </tr> | ||
745 | 323 | <tr> | ||
746 | 324 | <td> | ||
747 | 325 | <para style="terp_default_9"> | ||
748 | 326 | <font color="white"> </font> | ||
749 | 327 | </para> | ||
750 | 328 | </td> | ||
751 | 329 | <td> | ||
752 | 330 | <para style="terp_default_9">Taxes :</para> | ||
753 | 331 | </td> | ||
754 | 332 | <td> | ||
755 | 333 | <para style="terp_default_Right_9">[[ formatLang(o.amount_tax, digits=get_digits(dp='Account')) ]] [[ o.pricelist_id.currency_id. symbol ]]</para> | ||
756 | 334 | </td> | ||
757 | 335 | </tr> | ||
758 | 336 | <tr> | ||
759 | 337 | <td> | ||
760 | 338 | <para style="terp_default_9"> | ||
761 | 339 | <font color="white"> </font> | ||
762 | 340 | </para> | ||
763 | 341 | </td> | ||
764 | 342 | <td> | ||
765 | 343 | <para style="terp_default_Bold_9">Total :</para> | ||
766 | 344 | </td> | ||
767 | 345 | <td> | ||
768 | 346 | <para style="terp_default_Bold_9_Right">[[ formatLang(o.amount_total, digits=get_digits(dp='Account') ) ]] [[ o.pricelist_id.currency_id. symbol ]]</para> | ||
769 | 347 | </td> | ||
770 | 348 | </tr> | ||
771 | 349 | </blockTable> | ||
772 | 350 | <para style="terp_default_8"> | ||
773 | 351 | <font color="white"> </font> | ||
774 | 352 | </para> | ||
775 | 353 | <blockTable colWidths="535.0" style="Table_Outer_Notes"> | ||
776 | 354 | <tr> | ||
777 | 355 | <td> | ||
778 | 356 | <para style="terp_default_9">[[ format(o.notes or '') ]]</para> | ||
779 | 357 | </td> | ||
780 | 358 | </tr> | ||
781 | 359 | </blockTable> | ||
782 | 360 | <para style="terp_default_9"> | ||
783 | 361 | <font color="white"> </font> | ||
784 | 362 | </para> | ||
785 | 363 | </story> | ||
786 | 364 | </document> | ||
787 | 365 | |||
788 | 0 | 366 | ||
789 | === added file 'purchase_discount/report/order.sxw' | |||
790 | 1 | Binary files purchase_discount/report/order.sxw 1970-01-01 00:00:00 +0000 and purchase_discount/report/order.sxw 2014-06-20 10:14:35 +0000 differ | 367 | Binary files purchase_discount/report/order.sxw 1970-01-01 00:00:00 +0000 and purchase_discount/report/order.sxw 2014-06-20 10:14:35 +0000 differ |
791 | === added file 'purchase_discount/report/purchase_discount_report.xml' | |||
792 | --- purchase_discount/report/purchase_discount_report.xml 1970-01-01 00:00:00 +0000 | |||
793 | +++ purchase_discount/report/purchase_discount_report.xml 2014-06-20 10:14:35 +0000 | |||
794 | @@ -0,0 +1,11 @@ | |||
795 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
796 | 2 | <openerp> | ||
797 | 3 | <data> | ||
798 | 4 | <report id="purchase.report_purchase_order" | ||
799 | 5 | name="purchase.order" | ||
800 | 6 | string="Print Orders" | ||
801 | 7 | model="purchase.order" | ||
802 | 8 | rml="purchase_discount/report/order.rml" | ||
803 | 9 | /> | ||
804 | 10 | </data> | ||
805 | 11 | </openerp> | ||
806 | 0 | 12 | ||
807 | === added directory 'purchase_discount/views' | |||
808 | === added file 'purchase_discount/views/account_invoice_view.xml' | |||
809 | --- purchase_discount/views/account_invoice_view.xml 1970-01-01 00:00:00 +0000 | |||
810 | +++ purchase_discount/views/account_invoice_view.xml 2014-06-20 10:14:35 +0000 | |||
811 | @@ -0,0 +1,16 @@ | |||
812 | 1 | <openerp> | ||
813 | 2 | <data> | ||
814 | 3 | |||
815 | 4 | <record id="invoice_supplier_form_discount" model="ir.ui.view"> | ||
816 | 5 | <field name="name">account.invoice.supplier.form.discount</field> | ||
817 | 6 | <field name="model">account.invoice</field> | ||
818 | 7 | <field name="inherit_id" ref="account.invoice_supplier_form"/> | ||
819 | 8 | <field name="arch" type="xml"> | ||
820 | 9 | <field name="price_unit" position="after"> | ||
821 | 10 | <field name="discount"/> | ||
822 | 11 | </field> | ||
823 | 12 | </field> | ||
824 | 13 | </record> | ||
825 | 14 | |||
826 | 15 | </data> | ||
827 | 16 | </openerp> | ||
828 | 0 | 17 | ||
829 | === added file 'purchase_discount/views/purchase_discount_view.xml' | |||
830 | --- purchase_discount/views/purchase_discount_view.xml 1970-01-01 00:00:00 +0000 | |||
831 | +++ purchase_discount/views/purchase_discount_view.xml 2014-06-20 10:14:35 +0000 | |||
832 | @@ -0,0 +1,35 @@ | |||
833 | 1 | <openerp> | ||
834 | 2 | <data> | ||
835 | 3 | <record model="ir.ui.view" id="purchase_discount_order_line_form"> | ||
836 | 4 | <field name="name">purchase_discount.order.line.form</field> | ||
837 | 5 | <field name="model">purchase.order.line</field> | ||
838 | 6 | <field name="inherit_id" ref="purchase.purchase_order_line_form"/> | ||
839 | 7 | <field name="arch" type="xml"> | ||
840 | 8 | <field name="price_unit" position="after"> | ||
841 | 9 | <field name="discount"/> | ||
842 | 10 | </field> | ||
843 | 11 | </field> | ||
844 | 12 | </record> | ||
845 | 13 | <record model="ir.ui.view" id="purchase_discount_order_line_tree"> | ||
846 | 14 | <field name="name">purchase_discount.order.line.tree</field> | ||
847 | 15 | <field name="model">purchase.order.line</field> | ||
848 | 16 | <field name="inherit_id" ref="purchase.purchase_order_line_tree"/> | ||
849 | 17 | <field name="arch" type="xml"> | ||
850 | 18 | <field name="price_unit" position="after"> | ||
851 | 19 | <field name="discount"/> | ||
852 | 20 | </field> | ||
853 | 21 | </field> | ||
854 | 22 | </record> | ||
855 | 23 | |||
856 | 24 | <record model="ir.ui.view" id="purchase_discount_order_form"> | ||
857 | 25 | <field name="name">purchase.discount.order.form</field> | ||
858 | 26 | <field name="model">purchase.order</field> | ||
859 | 27 | <field name="inherit_id" ref="purchase.purchase_order_form"/> | ||
860 | 28 | <field name="arch" type="xml"> | ||
861 | 29 | <xpath expr="//field[@name='order_line']/tree/field[@name='price_unit']" position="after"> | ||
862 | 30 | <field name="discount"/> | ||
863 | 31 | </xpath> | ||
864 | 32 | </field> | ||
865 | 33 | </record> | ||
866 | 34 | </data> | ||
867 | 35 | </openerp> |
Thanks Pedro,
line 349: I think discount should not be < -100 too
line 399: amount_untaxed and following fields are present 2 times
some PEP8:
purchase_ discount/ __openerp_ _.py:21: 1: O603 Manifest "license" key is missing discount/ __openerp_ _.py:29: 5: O600 Warning unknown Manifest key ('contributors') discount/ __openerp_ _.py:43: 5: O600 Warning unknown Manifest key ('active') discount/ purchase_ discount. py:21:1: O603 Manifest "license" key is missing discount/ purchase_ discount. py:24:1: E302 expected 2 blank lines, found 1 discount/ purchase_ discount. py:29:5: O600 Warning unknown Manifest key ('contributors') discount/ purchase_ discount. py:35:75: W291 trailing whitespace discount/ purchase_ discount. py:43:5: O600 Warning unknown Manifest key ('active') discount/ purchase_ discount. py:43:75: W291 trailing whitespace discount/ purchase_ discount. py:44:33: E128 continuation line under-indented for visual indent discount/ purchase_ discount. py:52:56: W291 trailing whitespace discount/ purchase_ discount. py:86:29: E127 continuation line over-indented for visual indent discount/ purchase_ discount. py:103: 13: E128 continuation line under-indented for visual indent discount/ purchase_ discount. py:104: 13: E128 continuation line under-indented for visual indent discount/ purchase_ discount. py:105: 13: E128 continuation line under-indented for visual indent discount/ purchase_ discount. py:109: 13: E128 continuation line under-indented for visual indent discount/ purchase_ discount. py:110: 13: E128 continuation line under-indented for visual indent discount/ purchase_ discount. py:114: 17: E128 continuation line under-indented for visual indent discount/ purchase_ discount. py:115: 13: E128 continuation line under-indented for visual indent discount/ purchase_ discount. py:118: 55: W291 trailing whitespace discount/ purchase_ discount. py:119: 13: E128 continuation line under-indented for visual indent discount/ purchase_ discount. py:119: 28: E251 unexpected spaces around keyword / parameter equals discount/ purchase_ discount. py:119: 57: W291 trailing whitespace discount/ purchase_ discount. py:120: 13: E128 continuation line under-indented for visual indent discount/ purchase_ discount. py:121: 13: E128 continuation line under-indented for visual indent discount/ purchase_ discount. py:123: 60: W291 trailing whitespace discount/ purchase_ discount. py:125: 51: W291 trailing whitespace discount/ purchase_ discount. py:126: 13: E128 continuation line under-indented for visual indent discount/ purchase_ discount. py:126: 28: E251 unexpected spaces around keyword / parameter equals discount/ purchase_ discount. py:127: 13: E128 continuation line under-indented for visual indent discount/ purchase_ discount. py:130: 53: W291 trailing whitespace discount/ purchase_ discount. py:131: 13: E128 continuation line under-indented for visual indent discount/ purchase_ discount. py:131: 28: E251 unexpected spaces around keyword / parameter equals discount/ purch.. .
purchase_
purchase_
purchase_
purchase_
purchase_
purchase_
purchase_
purchase_
purchase_
purchase_
purchase_
purchase_
purchase_
purchase_
purchase_
purchase_
purchase_
purchase_
purchase_
purchase_
purchase_
purchase_
purchase_
purchase_
purchase_
purchase_
purchase_
purchase_
purchase_
purchase_
purchase_
purchase_
purchase_