openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #05665
[Merge] lp:~camptocamp/sale-financial/7.0-port-sale_floor_price into lp:sale-financial
Yannick Vaucher @ Camptocamp has proposed merging lp:~camptocamp/sale-financial/7.0-port-sale_floor_price into lp:sale-financial.
Requested reviews:
Pedro Manuel Baeza (pedro.baeza)
For more details, see:
https://code.launchpad.net/~camptocamp/sale-financial/7.0-port-sale_floor_price/+merge/214059
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
--
https://code.launchpad.net/~camptocamp/sale-financial/7.0-port-sale_floor_price/+merge/214059
Your team Sale Core Editors is subscribed to branch lp:sale-financial.
=== modified file 'sale_floor_price/__init__.py'
--- sale_floor_price/__init__.py 2012-05-29 07:06:32 +0000
+++ sale_floor_price/__init__.py 2014-04-04 13:58:16 +0000
@@ -1,27 +1,25 @@
# -*- coding: utf-8 -*-
##############################################################################
#
-# Copyright (c) 2011 Camptocamp SA (http://www.camptocamp.com)
-# All Right Reserved
-#
-# Author : Joel Grand-Guillaume (Camptocamp)
+# Author: Joël Grand-Guillaume
+# Copyright 2012 Camptocamp SA
#
# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
+# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
-import product
-import floor_sale
+from . import product
+from . import floor_sale
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
=== modified file 'sale_floor_price/__openerp__.py'
--- sale_floor_price/__openerp__.py 2013-11-14 08:16:22 +0000
+++ sale_floor_price/__openerp__.py 2014-04-04 13:58:16 +0000
@@ -22,17 +22,24 @@
'version' : '5.1',
'author' : 'Camptocamp',
'maintainer': 'Camptocamp',
- 'category': 'Tool',
- 'complexity': "normal", # easy, normal, expert
- 'depends' : ['stock','product','sale', 'sale_line_watcher'],
- 'description': """Set a minimal price on product and raise a warning if sale price is too low""",
+ 'category': 'Sales Management',
+ 'complexity': "normal",
+ 'depends' : [
+ 'stock','product','sale',
+ 'sale_line_watcher'
+ ],
+ 'description': """
+Floor price on product
+======================
+
+Set a minimal price on product and raise a warning if sale price is too low
+""",
'website': 'http://www.camptocamp.com',
- 'init_xml': [],
- 'update_xml': ['product_view.xml'],
- 'demo_xml': [],
- 'tests': [],
- 'installable': False,
+ 'data': ['product_view.xml',
+ 'sale_view.xml',
+ ],
+ 'test': [],
+ 'installable': True,
'auto_install': False,
'license': 'AGPL-3',
'application': True}
-
=== modified file 'sale_floor_price/floor_sale.py'
--- sale_floor_price/floor_sale.py 2012-06-06 13:14:12 +0000
+++ sale_floor_price/floor_sale.py 2014-04-04 13:58:16 +0000
@@ -1,35 +1,35 @@
# -*- coding: utf-8 -*-
##############################################################################
#
-# Copyright (c) 2011 Camptocamp SA (http://www.camptocamp.com)
-# All Right Reserved
-#
-# Author : Joel Grand-Guillaume (Camptocamp)
+# Author: Joël Grand-Guillaume
+# Copyright 2012 Camptocamp SA
#
# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
+# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
-from osv.orm import Model
-from tools.translate import _
+from openerp.osv.orm import Model
+from openerp.tools.translate import _
+
class SaleOrderLine(Model):
_inherit = 'sale.order.line'
def _reach_floor_price(self, cr, uid, floor_price, discount, price_unit):
sell_price = price_unit * (1 - (discount or 0.0) / 100.0)
- precision = self.pool.get('decimal.precision').precision_get(cr, uid, 'Sale Price')
+ precision_obj = self.pool['decimal.precision']
+ precision = precision_obj.precision_get(cr, uid, 'Sale Price')
sell_price = round(sell_price, precision)
if (sell_price < floor_price):
return True
@@ -48,61 +48,76 @@
return res
def product_id_change(self, cr, uid, ids, *args, **kwargs):
- '''
+ """
Overload method:
- Empty the discount when changing.
- '''
- res = super(SaleOrderLine, self).product_id_change(cr, uid, ids, *args, **kwargs)
+ """
+ res = super(SaleOrderLine, self
+ ).product_id_change(cr, uid, ids, *args, **kwargs)
res['value']['discount'] = 0.0
return res
-
- def onchange_price_unit(self, cr, uid, ids, price_unit, product_id, discount, product_uom,
- pricelist, **kwargs):
- '''
- If price unit change, check that it is not < floor_price_limit of related product.
- If override_unit_price is True, we put in price_unit the min possible value, otherwise
- we leave it empty...
- '''
+ def onchange_price_unit(self, cr, uid, ids, context=None, **kwargs):
+ """
+ If price unit change, check that it is not < floor_price_limit of
+ related product.
+ If override_unit_price is True, we put in price_unit the min possible
+ value, otherwise we leave it empty...
+ """
override_unit_price = kwargs.pop('override_unit_price', True)
- res = super(SaleOrderLine, self).onchange_price_unit(cr, uid, ids, price_unit,
- product_id, discount, product_uom,
- pricelist, **kwargs)
- self._check_floor_price(cr, uid, res, price_unit, product_id, discount, override_unit_price)
+ res = super(SaleOrderLine, self
+ ).onchange_price_unit(cr, uid, ids, context=context, **kwargs)
+ price_unit = context.get('price_unit')
+ product_id = context.get('product_id')
+ discount = context.get('discount')
+ self._check_floor_price(cr, uid, res, price_unit, product_id, discount,
+ override_unit_price)
return res
+ def onchange_discount(self, cr, uid, ids, context=None):
+ """
+ If discount change, check that final price is not < floor_price_limit
+ of related product
- def onchange_discount(self, cr, uid, ids, price_unit, product_id, discount, product_uom, pricelist, **kwargs):
- '''
- If discount change, check that final price is not < floor_price_limit of related product
- '''
- res = super(SaleOrderLine, self).onchange_discount(cr, uid, ids, price_unit, product_id,
- discount, product_uom, pricelist)
+ context price_unit, product_id, discount
+ """
+ if context is None:
+ context = {}
+ res = super(SaleOrderLine, self
+ ).onchange_discount(cr, uid, ids, context=context)
+ price_unit = context.get('price_unit')
+ product_id = context.get('product_id')
+ discount = context.get('discount')
self._check_floor_price(cr, uid, res, price_unit, product_id, discount)
return res
- def _check_floor_price(self, cr, uid, result, price_unit, product_id, discount, override_unit_price=True):
+ def _check_floor_price(self, cr, uid, result, price_unit, product_id,
+ discount, override_unit_price=True):
"""
result is a partially filled result dictionary, modified in place
"""
if 'value' not in result:
result['value'] = {}
if product_id and price_unit > 0.0:
- product_obj = self.pool.get('product.product')
+ product_obj = self.pool['product.product']
prod = product_obj.browse(cr, uid, product_id)
- if self._reach_floor_price(cr, uid, prod.floor_price_limit, discount, price_unit):
+ if self._reach_floor_price(cr, uid, prod.floor_price_limit,
+ discount, price_unit):
if override_unit_price:
- result['value']['price_unit'] = self._compute_lowest_price(cr, uid, prod.floor_price_limit, discount)
+ result['value']['price_unit'] = self._compute_lowest_price(
+ cr, uid, prod.floor_price_limit, discount)
else:
result['value']['price_unit'] = price_unit
- substs = {'price_unit':price_unit,
+ substs = {'price_unit': price_unit,
'discount': discount,
'floor_price': prod.floor_price_limit,
'min_price': result['value']['price_unit']}
- warn_msg = _("You selected a unit price of %(price_unit)d.- with %(discount).2f discount.\n"
- "The floor price has been set to %(floor_price)d.-,"
- "so the mininum allowed value is %(min_price)d.")
+ warn_msg = _("You selected a unit price of %(price_unit)d.-"
+ "with %(discount).2f discount.\n"
+ "The floor price has been set to "
+ "%(floor_price)d.-, so the mininum allowed value "
+ "is %(min_price)d.")
warning = {'title': _('Floor price reached !'),
'message': warn_msg % substs}
=== added directory 'sale_floor_price/i18n'
=== added file 'sale_floor_price/i18n/fr.po'
--- sale_floor_price/i18n/fr.po 1970-01-01 00:00:00 +0000
+++ sale_floor_price/i18n/fr.po 2014-04-04 13:58:16 +0000
@@ -0,0 +1,45 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+# * sale_floor_price
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2014-04-03 15:19+0000\n"
+"PO-Revision-Date: 2014-04-03 17:22+0100\n"
+"Last-Translator: Yannick Vaucher <yannick.vaucher@xxxxxxxxxxxxxx>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: \n"
+
+#. module: sale_floor_price
+#: field:product.product,floor_price_limit:0
+msgid "Floor Price"
+msgstr "Prix planché"
+
+#. module: sale_floor_price
+#: help:product.product,floor_price_limit:0
+msgid "Floor price for this product: salesmen will not be able to make a discount in SO below that price."
+msgstr "Prix planché pour ce produit: les vendeurs ne pouront pas faire de remise dans les commandes de vente en dessous de ce prix."
+
+#. module: sale_floor_price
+#: code:_description:0
+#: model:ir.model,name:sale_floor_price.model_product_product
+#, python-format
+msgid "Product"
+msgstr ""
+
+#. module: sale_floor_price
+#: model:ir.model,name:sale_floor_price.model_sale_order_line
+msgid "Sale Order line"
+msgstr ""
+
+#. module: sale_floor_price
+#: code:_description:0
+#, python-format
+msgid "Sales Order Line"
+msgstr ""
+
=== added file 'sale_floor_price/i18n/sale_floor_price.pot'
--- sale_floor_price/i18n/sale_floor_price.pot 1970-01-01 00:00:00 +0000
+++ sale_floor_price/i18n/sale_floor_price.pot 2014-04-04 13:58:16 +0000
@@ -0,0 +1,45 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+# * sale_floor_price
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2014-04-03 15:19+0000\n"
+"PO-Revision-Date: 2014-04-03 17:22+0100\n"
+"Last-Translator: Yannick Vaucher <yannick.vaucher@xxxxxxxxxxxxxx>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: \n"
+
+#. module: sale_floor_price
+#: field:product.product,floor_price_limit:0
+msgid "Floor Price"
+msgstr ""
+
+#. module: sale_floor_price
+#: help:product.product,floor_price_limit:0
+msgid "Floor price for this product: salesmen will not be able to make a discount in SO below that price."
+msgstr ""
+
+#. module: sale_floor_price
+#: code:_description:0
+#: model:ir.model,name:sale_floor_price.model_product_product
+#, python-format
+msgid "Product"
+msgstr ""
+
+#. module: sale_floor_price
+#: model:ir.model,name:sale_floor_price.model_sale_order_line
+msgid "Sale Order line"
+msgstr ""
+
+#. module: sale_floor_price
+#: code:_description:0
+#, python-format
+msgid "Sales Order Line"
+msgstr ""
+
=== modified file 'sale_floor_price/product.py'
--- sale_floor_price/product.py 2012-05-15 09:37:26 +0000
+++ sale_floor_price/product.py 2014-04-04 13:58:16 +0000
@@ -19,15 +19,19 @@
#
##############################################################################
-from osv import fields
-from osv.orm import Model
+from openerp.osv import orm, fields
import decimal_precision as dp
-class Product(Model):
+
+class Product(orm.Model):
"""Add floor price to product"""
+
_inherit = 'product.product'
- _columns = {'floor_price_limit': fields.float('Floor Price',
- digits_compute=dp.get_precision('Sale Price'),
- help="Floor price for this product:"
- "salesmen will not be able to make"
- "a discount in SO below that price.")}
+
+ _columns = {
+ 'floor_price_limit': fields.float(
+ 'Floor Price',
+ digits_compute=dp.get_precision('Sale Price'),
+ help="Floor price for this product: salesmen will not be able to "
+ "make a discount in SO below that price.")
+ }
=== modified file 'sale_floor_price/product_view.xml'
--- sale_floor_price/product_view.xml 2012-05-29 07:06:32 +0000
+++ sale_floor_price/product_view.xml 2014-04-04 13:58:16 +0000
@@ -1,16 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
- <data>
- <record id="sale_floor_price_product_normal_form_view" model="ir.ui.view">
- <field name="name">product.normal.form.floor_price</field>
- <field name="model">product.product</field>
- <field name="type">form</field>
- <field name="inherit_id" ref="product.product_normal_form_view"/>
- <field name="arch" type="xml">
- <field name="list_price" position="after">
- <field groups="base.group_sale_manager" name="floor_price_limit"/>
- </field>
- </field>
- </record>
- </data>
+ <data>
+ <record id="sale_floor_price_product_normal_form_view" model="ir.ui.view">
+ <field name="name">product.normal.form.floor_price</field>
+ <field name="model">product.product</field>
+ <field name="inherit_id" ref="product.product_normal_form_view"/>
+ <field name="arch" type="xml">
+ <field name="list_price" position="after">
+ <field groups="base.group_sale_manager" name="floor_price_limit"/>
+ </field>
+ </field>
+ </record>
+ </data>
</openerp>
=== added file 'sale_floor_price/sale_view.xml'
--- sale_floor_price/sale_view.xml 1970-01-01 00:00:00 +0000
+++ sale_floor_price/sale_view.xml 2014-04-04 13:58:16 +0000
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+ <!-- set context for on_change using web_context_tunnel -->
+ <record model="ir.ui.view" id="sale_watcher_sale_order_line_form2">
+ <field name="name">sales_line_watcher.view.form2</field>
+ <field name="model">sale.order.line</field>
+ <field name="inherit_id" ref="sale.view_order_line_form2" />
+ <field name="arch" type="xml">
+ <xpath expr="//field[@name='price_unit']" position="attributes">
+ <attribute name="context_floor_price">{'price_unit': price_unit, 'product_id': product_id, 'discount': discount}</attribute>
+ </xpath>
+ </field>
+ </record>
+
+ <record model="ir.ui.view" id="sale_watcher_sale_order_line_form3">
+ <field name="name">sales_line_watcher.view.form3</field>
+ <field name="model">sale.order.line</field>
+ <field name="inherit_id" ref="sale.view_order_line_form2" />
+ <field name="arch" type="xml">
+ <xpath expr="//field[@name='discount']" position="attributes">
+ <attribute name="context_floor_price">{'price_unit': price_unit, 'product_id': product_id, 'discount': discount}</attribute>
+ </xpath>
+ </field>
+ </record>
+
+ <record id="sale_watcher_order_form1" model="ir.ui.view">
+ <field name="name">sales_line_watcher.form.floorprice</field>
+ <field name="model">sale.order</field>
+ <field name="inherit_id" ref="sale.view_order_form" />
+ <field name="arch" type="xml">
+ <field name="discount" position="attributes">
+ <attribute name="context_floor_price">{'price_unit': price_unit, 'product_id': product_id, 'discount': discount}</attribute>
+ </field>
+ </field>
+ </record>
+
+ <record id="sale_watcher_order_form2" model="ir.ui.view">
+ <field name="name">sales_line_watcher.form.floorprice</field>
+ <field name="model">sale.order</field>
+ <field name="inherit_id" ref="sale.view_order_form" />
+ <field name="arch" type="xml">
+ <field name="price_unit" position="attributes">
+ <attribute name="context_floor_price">{'price_unit': price_unit, 'product_id': product_id, 'discount': discount}</attribute>
+ <attribute name="on_change">onchange_price_unit(context)</attribute>
+ </field>
+ </field>
+ </record>
+ </data>
+</openerp>
Follow ups