Merge lp:~camptocamp/sale-financial/7.0-port-sale_floor_price into lp:~sale-core-editors/sale-financial/7.0

Proposed by Yannick Vaucher @ Camptocamp
Status: Needs review
Proposed branch: lp:~camptocamp/sale-financial/7.0-port-sale_floor_price
Merge into: lp:~sale-core-editors/sale-financial/7.0
Diff against target: 462 lines (+250/-81)
8 files modified
sale_floor_price/__init__.py (+8/-10)
sale_floor_price/__openerp__.py (+23/-10)
sale_floor_price/floor_sale.py (+55/-40)
sale_floor_price/i18n/fr.po (+45/-0)
sale_floor_price/i18n/sale_floor_price.pot (+45/-0)
sale_floor_price/product.py (+12/-8)
sale_floor_price/product_view.xml (+12/-13)
sale_floor_price/sale_view.xml (+50/-0)
To merge this branch: bzr merge lp:~camptocamp/sale-financial/7.0-port-sale_floor_price
Reviewer Review Type Date Requested Status
Alexandre Fayolle - camptocamp Needs Resubmitting
Raphaël Valyi - http://www.akretion.com Approve
Pedro Manuel Baeza Needs Fixing
Review via email: mp+214059@code.launchpad.net

Commit message

Portage to v7 of module sale_floor_price

Description of the change

Portage of sale_floor_price

Requires sale_line_watcher ported in

https://code.launchpad.net/~camptocamp/sale-financial/7.0-port-sale_line_watcher/+merge/214058

To post a comment you must log in.
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

See comments on the other MP that can affect this one. Please also mark this MP as dependent of the other. I set it as Needs fixing to take this into account.

Thanks. Regards.

review: Needs Fixing
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

Pedro I've rewritten that module according to your comments

Thanks for the review

25. By Yannick Vaucher @ Camptocamp on 2014-04-04

improve description

Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote :

It's a pragmatic approval for now because it's already a working improvement. See https://code.launchpad.net/~camptocamp/sale-financial/7.0-port-sale_line_watcher/+merge/214058/comments/534749

review: Approve
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

Hello,

The management of the project has moved to Github: https://github.com/OCA/sale-financial

Please migrate your merge proposal to Github. You may want to check https://github.com/OCA/maintainers-tools/wiki/How-to-move-a-Merge-Proposal-to-GitHub for an explanation on how to proceed.

Thanks for contributing to the project

review: Needs Resubmitting

Unmerged revisions

25. By Yannick Vaucher @ Camptocamp on 2014-04-04

improve description

24. By Yannick Vaucher @ Camptocamp on 2014-04-04

Rewrite onchange to use web_context_tunnel module

23. By Yannick Vaucher @ Camptocamp on 2014-04-03

change imports to standards

22. By Yannick Vaucher @ Camptocamp on 2014-04-03

change module category

21. By Yannick Vaucher @ Camptocamp on 2014-04-03

Portage to v7 of module sale_floor_price

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'sale_floor_price/__init__.py'
2--- sale_floor_price/__init__.py 2012-05-29 07:06:32 +0000
3+++ sale_floor_price/__init__.py 2014-04-04 14:32:26 +0000
4@@ -1,27 +1,25 @@
5 # -*- coding: utf-8 -*-
6 ##############################################################################
7 #
8-# Copyright (c) 2011 Camptocamp SA (http://www.camptocamp.com)
9-# All Right Reserved
10-#
11-# Author : Joel Grand-Guillaume (Camptocamp)
12+# Author: Joël Grand-Guillaume
13+# Copyright 2012 Camptocamp SA
14 #
15 # This program is free software: you can redistribute it and/or modify
16-# it under the terms of the GNU General Public License as published by
17-# the Free Software Foundation, either version 3 of the License, or
18-# (at your option) any later version.
19+# it under the terms of the GNU Affero General Public License as
20+# published by the Free Software Foundation, either version 3 of the
21+# License, or (at your option) any later version.
22 #
23 # This program is distributed in the hope that it will be useful,
24 # but WITHOUT ANY WARRANTY; without even the implied warranty of
25 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26-# GNU General Public License for more details.
27+# GNU Affero General Public License for more details.
28 #
29 # You should have received a copy of the GNU Affero General Public License
30 # along with this program. If not, see <http://www.gnu.org/licenses/>.
31 #
32 ##############################################################################
33
34-import product
35-import floor_sale
36+from . import product
37+from . import floor_sale
38
39 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
40
41=== modified file 'sale_floor_price/__openerp__.py'
42--- sale_floor_price/__openerp__.py 2013-11-14 08:16:22 +0000
43+++ sale_floor_price/__openerp__.py 2014-04-04 14:32:26 +0000
44@@ -22,17 +22,30 @@
45 'version' : '5.1',
46 'author' : 'Camptocamp',
47 'maintainer': 'Camptocamp',
48- 'category': 'Tool',
49- 'complexity': "normal", # easy, normal, expert
50- 'depends' : ['stock','product','sale', 'sale_line_watcher'],
51- 'description': """Set a minimal price on product and raise a warning if sale price is too low""",
52+ 'category': 'Sales Management',
53+ 'complexity': "normal",
54+ 'depends' : [
55+ 'stock','product','sale',
56+ 'sale_line_watcher'
57+ ],
58+ 'description': """
59+Floor price on product
60+======================
61+
62+Set a minimal price on product and raise a warning if sale price is too low.
63+
64+Contributors
65+------------
66+
67+* Joël Grand-Guillaume <joel.grandguillaume@camptocamp.com>
68+* Yannick Vaucher <yannick.vaucher@camptocamp.com>
69+""",
70 'website': 'http://www.camptocamp.com',
71- 'init_xml': [],
72- 'update_xml': ['product_view.xml'],
73- 'demo_xml': [],
74- 'tests': [],
75- 'installable': False,
76+ 'data': ['product_view.xml',
77+ 'sale_view.xml',
78+ ],
79+ 'test': [],
80+ 'installable': True,
81 'auto_install': False,
82 'license': 'AGPL-3',
83 'application': True}
84-
85
86=== modified file 'sale_floor_price/floor_sale.py'
87--- sale_floor_price/floor_sale.py 2012-06-06 13:14:12 +0000
88+++ sale_floor_price/floor_sale.py 2014-04-04 14:32:26 +0000
89@@ -1,35 +1,35 @@
90 # -*- coding: utf-8 -*-
91 ##############################################################################
92 #
93-# Copyright (c) 2011 Camptocamp SA (http://www.camptocamp.com)
94-# All Right Reserved
95-#
96-# Author : Joel Grand-Guillaume (Camptocamp)
97+# Author: Joël Grand-Guillaume
98+# Copyright 2012 Camptocamp SA
99 #
100 # This program is free software: you can redistribute it and/or modify
101-# it under the terms of the GNU General Public License as published by
102-# the Free Software Foundation, either version 3 of the License, or
103-# (at your option) any later version.
104+# it under the terms of the GNU Affero General Public License as
105+# published by the Free Software Foundation, either version 3 of the
106+# License, or (at your option) any later version.
107 #
108 # This program is distributed in the hope that it will be useful,
109 # but WITHOUT ANY WARRANTY; without even the implied warranty of
110 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
111-# GNU General Public License for more details.
112+# GNU Affero General Public License for more details.
113 #
114 # You should have received a copy of the GNU Affero General Public License
115 # along with this program. If not, see <http://www.gnu.org/licenses/>.
116 #
117 ##############################################################################
118
119-from osv.orm import Model
120-from tools.translate import _
121+from openerp.osv.orm import Model
122+from openerp.tools.translate import _
123+
124
125 class SaleOrderLine(Model):
126 _inherit = 'sale.order.line'
127
128 def _reach_floor_price(self, cr, uid, floor_price, discount, price_unit):
129 sell_price = price_unit * (1 - (discount or 0.0) / 100.0)
130- precision = self.pool.get('decimal.precision').precision_get(cr, uid, 'Sale Price')
131+ precision_obj = self.pool['decimal.precision']
132+ precision = precision_obj.precision_get(cr, uid, 'Sale Price')
133 sell_price = round(sell_price, precision)
134 if (sell_price < floor_price):
135 return True
136@@ -48,61 +48,76 @@
137 return res
138
139 def product_id_change(self, cr, uid, ids, *args, **kwargs):
140- '''
141+ """
142 Overload method:
143 - Empty the discount when changing.
144- '''
145- res = super(SaleOrderLine, self).product_id_change(cr, uid, ids, *args, **kwargs)
146+ """
147+ res = super(SaleOrderLine, self
148+ ).product_id_change(cr, uid, ids, *args, **kwargs)
149 res['value']['discount'] = 0.0
150 return res
151
152-
153- def onchange_price_unit(self, cr, uid, ids, price_unit, product_id, discount, product_uom,
154- pricelist, **kwargs):
155- '''
156- If price unit change, check that it is not < floor_price_limit of related product.
157- If override_unit_price is True, we put in price_unit the min possible value, otherwise
158- we leave it empty...
159- '''
160+ def onchange_price_unit(self, cr, uid, ids, context=None, **kwargs):
161+ """
162+ If price unit change, check that it is not < floor_price_limit of
163+ related product.
164+ If override_unit_price is True, we put in price_unit the min possible
165+ value, otherwise we leave it empty...
166+ """
167 override_unit_price = kwargs.pop('override_unit_price', True)
168- res = super(SaleOrderLine, self).onchange_price_unit(cr, uid, ids, price_unit,
169- product_id, discount, product_uom,
170- pricelist, **kwargs)
171- self._check_floor_price(cr, uid, res, price_unit, product_id, discount, override_unit_price)
172+ res = super(SaleOrderLine, self
173+ ).onchange_price_unit(cr, uid, ids, context=context, **kwargs)
174+ price_unit = context.get('price_unit')
175+ product_id = context.get('product_id')
176+ discount = context.get('discount')
177+ self._check_floor_price(cr, uid, res, price_unit, product_id, discount,
178+ override_unit_price)
179 return res
180
181+ def onchange_discount(self, cr, uid, ids, context=None):
182+ """
183+ If discount change, check that final price is not < floor_price_limit
184+ of related product
185
186- def onchange_discount(self, cr, uid, ids, price_unit, product_id, discount, product_uom, pricelist, **kwargs):
187- '''
188- If discount change, check that final price is not < floor_price_limit of related product
189- '''
190- res = super(SaleOrderLine, self).onchange_discount(cr, uid, ids, price_unit, product_id,
191- discount, product_uom, pricelist)
192+ context price_unit, product_id, discount
193+ """
194+ if context is None:
195+ context = {}
196+ res = super(SaleOrderLine, self
197+ ).onchange_discount(cr, uid, ids, context=context)
198+ price_unit = context.get('price_unit')
199+ product_id = context.get('product_id')
200+ discount = context.get('discount')
201
202 self._check_floor_price(cr, uid, res, price_unit, product_id, discount)
203 return res
204
205- def _check_floor_price(self, cr, uid, result, price_unit, product_id, discount, override_unit_price=True):
206+ def _check_floor_price(self, cr, uid, result, price_unit, product_id,
207+ discount, override_unit_price=True):
208 """
209 result is a partially filled result dictionary, modified in place
210 """
211 if 'value' not in result:
212 result['value'] = {}
213 if product_id and price_unit > 0.0:
214- product_obj = self.pool.get('product.product')
215+ product_obj = self.pool['product.product']
216 prod = product_obj.browse(cr, uid, product_id)
217- if self._reach_floor_price(cr, uid, prod.floor_price_limit, discount, price_unit):
218+ if self._reach_floor_price(cr, uid, prod.floor_price_limit,
219+ discount, price_unit):
220 if override_unit_price:
221- result['value']['price_unit'] = self._compute_lowest_price(cr, uid, prod.floor_price_limit, discount)
222+ result['value']['price_unit'] = self._compute_lowest_price(
223+ cr, uid, prod.floor_price_limit, discount)
224 else:
225 result['value']['price_unit'] = price_unit
226- substs = {'price_unit':price_unit,
227+ substs = {'price_unit': price_unit,
228 'discount': discount,
229 'floor_price': prod.floor_price_limit,
230 'min_price': result['value']['price_unit']}
231- warn_msg = _("You selected a unit price of %(price_unit)d.- with %(discount).2f discount.\n"
232- "The floor price has been set to %(floor_price)d.-,"
233- "so the mininum allowed value is %(min_price)d.")
234+ warn_msg = _("You selected a unit price of %(price_unit)d.-"
235+ "with %(discount).2f discount.\n"
236+ "The floor price has been set to "
237+ "%(floor_price)d.-, so the mininum allowed value "
238+ "is %(min_price)d.")
239
240 warning = {'title': _('Floor price reached !'),
241 'message': warn_msg % substs}
242
243=== added directory 'sale_floor_price/i18n'
244=== added file 'sale_floor_price/i18n/fr.po'
245--- sale_floor_price/i18n/fr.po 1970-01-01 00:00:00 +0000
246+++ sale_floor_price/i18n/fr.po 2014-04-04 14:32:26 +0000
247@@ -0,0 +1,45 @@
248+# Translation of OpenERP Server.
249+# This file contains the translation of the following modules:
250+# * sale_floor_price
251+#
252+msgid ""
253+msgstr ""
254+"Project-Id-Version: OpenERP Server 7.0\n"
255+"Report-Msgid-Bugs-To: \n"
256+"POT-Creation-Date: 2014-04-03 15:19+0000\n"
257+"PO-Revision-Date: 2014-04-03 17:22+0100\n"
258+"Last-Translator: Yannick Vaucher <yannick.vaucher@camptocamp.com>\n"
259+"Language-Team: \n"
260+"MIME-Version: 1.0\n"
261+"Content-Type: text/plain; charset=UTF-8\n"
262+"Content-Transfer-Encoding: 8bit\n"
263+"Plural-Forms: \n"
264+
265+#. module: sale_floor_price
266+#: field:product.product,floor_price_limit:0
267+msgid "Floor Price"
268+msgstr "Prix planché"
269+
270+#. module: sale_floor_price
271+#: help:product.product,floor_price_limit:0
272+msgid "Floor price for this product: salesmen will not be able to make a discount in SO below that price."
273+msgstr "Prix planché pour ce produit: les vendeurs ne pouront pas faire de remise dans les commandes de vente en dessous de ce prix."
274+
275+#. module: sale_floor_price
276+#: code:_description:0
277+#: model:ir.model,name:sale_floor_price.model_product_product
278+#, python-format
279+msgid "Product"
280+msgstr ""
281+
282+#. module: sale_floor_price
283+#: model:ir.model,name:sale_floor_price.model_sale_order_line
284+msgid "Sale Order line"
285+msgstr ""
286+
287+#. module: sale_floor_price
288+#: code:_description:0
289+#, python-format
290+msgid "Sales Order Line"
291+msgstr ""
292+
293
294=== added file 'sale_floor_price/i18n/sale_floor_price.pot'
295--- sale_floor_price/i18n/sale_floor_price.pot 1970-01-01 00:00:00 +0000
296+++ sale_floor_price/i18n/sale_floor_price.pot 2014-04-04 14:32:26 +0000
297@@ -0,0 +1,45 @@
298+# Translation of OpenERP Server.
299+# This file contains the translation of the following modules:
300+# * sale_floor_price
301+#
302+msgid ""
303+msgstr ""
304+"Project-Id-Version: OpenERP Server 7.0\n"
305+"Report-Msgid-Bugs-To: \n"
306+"POT-Creation-Date: 2014-04-03 15:19+0000\n"
307+"PO-Revision-Date: 2014-04-03 17:22+0100\n"
308+"Last-Translator: Yannick Vaucher <yannick.vaucher@camptocamp.com>\n"
309+"Language-Team: \n"
310+"MIME-Version: 1.0\n"
311+"Content-Type: text/plain; charset=UTF-8\n"
312+"Content-Transfer-Encoding: 8bit\n"
313+"Plural-Forms: \n"
314+
315+#. module: sale_floor_price
316+#: field:product.product,floor_price_limit:0
317+msgid "Floor Price"
318+msgstr ""
319+
320+#. module: sale_floor_price
321+#: help:product.product,floor_price_limit:0
322+msgid "Floor price for this product: salesmen will not be able to make a discount in SO below that price."
323+msgstr ""
324+
325+#. module: sale_floor_price
326+#: code:_description:0
327+#: model:ir.model,name:sale_floor_price.model_product_product
328+#, python-format
329+msgid "Product"
330+msgstr ""
331+
332+#. module: sale_floor_price
333+#: model:ir.model,name:sale_floor_price.model_sale_order_line
334+msgid "Sale Order line"
335+msgstr ""
336+
337+#. module: sale_floor_price
338+#: code:_description:0
339+#, python-format
340+msgid "Sales Order Line"
341+msgstr ""
342+
343
344=== modified file 'sale_floor_price/product.py'
345--- sale_floor_price/product.py 2012-05-15 09:37:26 +0000
346+++ sale_floor_price/product.py 2014-04-04 14:32:26 +0000
347@@ -19,15 +19,19 @@
348 #
349 ##############################################################################
350
351-from osv import fields
352-from osv.orm import Model
353+from openerp.osv import orm, fields
354 import decimal_precision as dp
355
356-class Product(Model):
357+
358+class Product(orm.Model):
359 """Add floor price to product"""
360+
361 _inherit = 'product.product'
362- _columns = {'floor_price_limit': fields.float('Floor Price',
363- digits_compute=dp.get_precision('Sale Price'),
364- help="Floor price for this product:"
365- "salesmen will not be able to make"
366- "a discount in SO below that price.")}
367+
368+ _columns = {
369+ 'floor_price_limit': fields.float(
370+ 'Floor Price',
371+ digits_compute=dp.get_precision('Sale Price'),
372+ help="Floor price for this product: salesmen will not be able to "
373+ "make a discount in SO below that price.")
374+ }
375
376=== modified file 'sale_floor_price/product_view.xml'
377--- sale_floor_price/product_view.xml 2012-05-29 07:06:32 +0000
378+++ sale_floor_price/product_view.xml 2014-04-04 14:32:26 +0000
379@@ -1,16 +1,15 @@
380 <?xml version="1.0" encoding="utf-8"?>
381 <openerp>
382- <data>
383- <record id="sale_floor_price_product_normal_form_view" model="ir.ui.view">
384- <field name="name">product.normal.form.floor_price</field>
385- <field name="model">product.product</field>
386- <field name="type">form</field>
387- <field name="inherit_id" ref="product.product_normal_form_view"/>
388- <field name="arch" type="xml">
389- <field name="list_price" position="after">
390- <field groups="base.group_sale_manager" name="floor_price_limit"/>
391- </field>
392- </field>
393- </record>
394- </data>
395+ <data>
396+ <record id="sale_floor_price_product_normal_form_view" model="ir.ui.view">
397+ <field name="name">product.normal.form.floor_price</field>
398+ <field name="model">product.product</field>
399+ <field name="inherit_id" ref="product.product_normal_form_view"/>
400+ <field name="arch" type="xml">
401+ <field name="list_price" position="after">
402+ <field groups="base.group_sale_manager" name="floor_price_limit"/>
403+ </field>
404+ </field>
405+ </record>
406+ </data>
407 </openerp>
408
409=== added file 'sale_floor_price/sale_view.xml'
410--- sale_floor_price/sale_view.xml 1970-01-01 00:00:00 +0000
411+++ sale_floor_price/sale_view.xml 2014-04-04 14:32:26 +0000
412@@ -0,0 +1,50 @@
413+<?xml version="1.0" encoding="utf-8"?>
414+<openerp>
415+ <data>
416+ <!-- set context for on_change using web_context_tunnel -->
417+ <record model="ir.ui.view" id="sale_watcher_sale_order_line_form2">
418+ <field name="name">sales_line_watcher.view.form2</field>
419+ <field name="model">sale.order.line</field>
420+ <field name="inherit_id" ref="sale.view_order_line_form2" />
421+ <field name="arch" type="xml">
422+ <xpath expr="//field[@name='price_unit']" position="attributes">
423+ <attribute name="context_floor_price">{'price_unit': price_unit, 'product_id': product_id, 'discount': discount}</attribute>
424+ </xpath>
425+ </field>
426+ </record>
427+
428+ <record model="ir.ui.view" id="sale_watcher_sale_order_line_form3">
429+ <field name="name">sales_line_watcher.view.form3</field>
430+ <field name="model">sale.order.line</field>
431+ <field name="inherit_id" ref="sale.view_order_line_form2" />
432+ <field name="arch" type="xml">
433+ <xpath expr="//field[@name='discount']" position="attributes">
434+ <attribute name="context_floor_price">{'price_unit': price_unit, 'product_id': product_id, 'discount': discount}</attribute>
435+ </xpath>
436+ </field>
437+ </record>
438+
439+ <record id="sale_watcher_order_form1" model="ir.ui.view">
440+ <field name="name">sales_line_watcher.form.floorprice</field>
441+ <field name="model">sale.order</field>
442+ <field name="inherit_id" ref="sale.view_order_form" />
443+ <field name="arch" type="xml">
444+ <field name="discount" position="attributes">
445+ <attribute name="context_floor_price">{'price_unit': price_unit, 'product_id': product_id, 'discount': discount}</attribute>
446+ </field>
447+ </field>
448+ </record>
449+
450+ <record id="sale_watcher_order_form2" model="ir.ui.view">
451+ <field name="name">sales_line_watcher.form.floorprice</field>
452+ <field name="model">sale.order</field>
453+ <field name="inherit_id" ref="sale.view_order_form" />
454+ <field name="arch" type="xml">
455+ <field name="price_unit" position="attributes">
456+ <attribute name="context_floor_price">{'price_unit': price_unit, 'product_id': product_id, 'discount': discount}</attribute>
457+ <attribute name="on_change">onchange_price_unit(context)</attribute>
458+ </field>
459+ </field>
460+ </record>
461+ </data>
462+</openerp>

Subscribers

People subscribed via source and target branches

to all changes: