From 02fd5b9d04002c0c552d0b068d6d3a08a27b7a09 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Wed, 22 Jul 2015 09:45:01 +0200 Subject: [PATCH] [WIP][PORT] Copy module from 7.0 serie; --- pos_order_pricelist_change/__init__.py | 23 +++ pos_order_pricelist_change/__openerp__.py | 56 ++++++ pos_order_pricelist_change/demo/demo.xml | 47 +++++ pos_order_pricelist_change/i18n/fr.po | 33 +++ .../i18n/pos_order_pricelist_change.pot | 56 ++++++ pos_order_pricelist_change/model/__init__.py | 23 +++ pos_order_pricelist_change/model/pos_order.py | 52 +++++ .../static/src/img/icon.png | Bin 0 -> 8773 bytes pos_order_pricelist_change/tests/__init__.py | 27 +++ .../tests/test_pos_order_pricelist_change.py | 188 ++++++++++++++++++ pos_order_pricelist_change/view/view.xml | 38 ++++ 11 files changed, 543 insertions(+) create mode 100644 pos_order_pricelist_change/__init__.py create mode 100644 pos_order_pricelist_change/__openerp__.py create mode 100644 pos_order_pricelist_change/demo/demo.xml create mode 100644 pos_order_pricelist_change/i18n/fr.po create mode 100644 pos_order_pricelist_change/i18n/pos_order_pricelist_change.pot create mode 100644 pos_order_pricelist_change/model/__init__.py create mode 100644 pos_order_pricelist_change/model/pos_order.py create mode 100644 pos_order_pricelist_change/static/src/img/icon.png create mode 100644 pos_order_pricelist_change/tests/__init__.py create mode 100644 pos_order_pricelist_change/tests/test_pos_order_pricelist_change.py create mode 100644 pos_order_pricelist_change/view/view.xml diff --git a/pos_order_pricelist_change/__init__.py b/pos_order_pricelist_change/__init__.py new file mode 100644 index 00000000..28dc79fa --- /dev/null +++ b/pos_order_pricelist_change/__init__.py @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Point Of Sale - Order Pricelist Change for Odoo +# Copyright (C) 2014 GRAP (http://www.grap.coop) +# @author Sylvain LE GAL (https://twitter.com/legalsylvain) +# +# This program is free software: you can redistribute it and/or modify +# 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 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 . +# +############################################################################## + +from . import model diff --git a/pos_order_pricelist_change/__openerp__.py b/pos_order_pricelist_change/__openerp__.py new file mode 100644 index 00000000..d1498ce1 --- /dev/null +++ b/pos_order_pricelist_change/__openerp__.py @@ -0,0 +1,56 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Point Of Sale - Order Pricelist Change for Odoo +# Copyright (C) 2014 GRAP (http://www.grap.coop) +# @author Sylvain LE GAL (https://twitter.com/legalsylvain) +# +# This program is free software: you can redistribute it and/or modify +# 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 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 . +# +############################################################################## +{ + 'name': 'Point Of Sale - Order Pricelist Change', + 'summary': """Fix an incorrect behaviour when changing pricelist on""" + """ pos order""", + 'version': '1.0', + 'category': 'Point Of Sale', + 'description': """ +Fix an incorrect behaviour when changing pricelist on pos order +=============================================================== + +Features: +--------- + * On a POS order, when changing a pricelist, warn the user as in sale""" + """ module, when doing a quotation; + * On a POS order, provide a 'Recompute With pricelist' button to update""" + """ when pricelist has changed; + +Copyright, Authors and Licence: +------------------------------- + * Copyright: 2014, GRAP: Groupement Régional Alimentaire de Proximité; + * Author: + * Sylvain LE GAL (https://twitter.com/legalsylvain);""", + 'author': "GRAP,Odoo Community Association (OCA)", + 'website': 'http://www.grap.coop', + 'license': 'AGPL-3', + 'depends': [ + 'point_of_sale', + ], + 'data': [ + 'view/view.xml', + ], + 'demo': [ + 'demo/demo.xml', + ], +} diff --git a/pos_order_pricelist_change/demo/demo.xml b/pos_order_pricelist_change/demo/demo.xml new file mode 100644 index 00000000..8d838ced --- /dev/null +++ b/pos_order_pricelist_change/demo/demo.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + Surcharge Pricelist + sale + + + + Surcharge Pricelist Version + + + + + 10 + Surcharge Pricelist Line + + + + + Surcharge Customer + + + + + + diff --git a/pos_order_pricelist_change/i18n/fr.po b/pos_order_pricelist_change/i18n/fr.po new file mode 100644 index 00000000..790c4980 --- /dev/null +++ b/pos_order_pricelist_change/i18n/fr.po @@ -0,0 +1,33 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * pos_order_pricelist_change +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-07-16 13:01+0000\n" +"PO-Revision-Date: 2014-07-16 13:01+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: pos_order_pricelist_change +#: code:addons/pos_order_pricelist_change/model/pos_order.py:47 +#, python-format +msgid "If you change the pricelist of this order, prices of existing order lines will not be updated. Please click on the 'Recompute With Pricelist'." +msgstr "Si vous changez la liste de prix de cette vente, les prix des lignes existantes ne seront pas mis à jour. Merci de cliquer sur le bouton 'Recalculer avec la liste de prix." + +#. module: pos_order_pricelist_change +#: code:addons/pos_order_pricelist_change/model/pos_order.py:46 +#, python-format +msgid "Pricelist Warning!" +msgstr "Attention à la liste de Prix !" + +#. module: pos_order_pricelist_change +#: view:pos.order:0 +msgid "Recompute With Pricelist" +msgstr "Recalculer avec la Liste de Prix" diff --git a/pos_order_pricelist_change/i18n/pos_order_pricelist_change.pot b/pos_order_pricelist_change/i18n/pos_order_pricelist_change.pot new file mode 100644 index 00000000..b4f31842 --- /dev/null +++ b/pos_order_pricelist_change/i18n/pos_order_pricelist_change.pot @@ -0,0 +1,56 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * pos_order_pricelist_change +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-11-16 02:05+0000\n" +"PO-Revision-Date: 2014-11-16 02:05+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: pos_order_pricelist_change +#: code:addons/pos_order_pricelist_change/model/pos_order.py:47 +#, python-format +msgid "If you change the pricelist of this order, prices of existing order lines will not be updated. Please click on the 'Recompute With Pricelist'." +msgstr "" + +#. module: pos_order_pricelist_change +#: code:_description:0 +#: model:ir.model,name:pos_order_pricelist_change.model_pos_order +#, python-format +msgid "Point of Sale" +msgstr "" + +#. module: pos_order_pricelist_change +#: code:addons/pos_order_pricelist_change/model/pos_order.py:46 +#, python-format +msgid "Pricelist Warning!" +msgstr "" + +#. module: pos_order_pricelist_change +#: view:pos.order:0 +msgid "Recompute With Pricelist" +msgstr "" + +#. module: pos_order_pricelist_change +#: model:product.pricelist,name:pos_order_pricelist_change.pricelist_surcharge +msgid "Surcharge Pricelist" +msgstr "" + +#. module: pos_order_pricelist_change +#: model:product.pricelist.version,name:pos_order_pricelist_change.pricelist_version_surcharge +msgid "Surcharge Pricelist Version" +msgstr "" + +#. module: pos_order_pricelist_change +#: view:pos.order:0 +msgid "onchange_pricelist_id(pricelist_id, lines)" +msgstr "" + diff --git a/pos_order_pricelist_change/model/__init__.py b/pos_order_pricelist_change/model/__init__.py new file mode 100644 index 00000000..ef8a11b2 --- /dev/null +++ b/pos_order_pricelist_change/model/__init__.py @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Point Of Sale - Order Pricelist Change for Odoo +# Copyright (C) 2014 GRAP (http://www.grap.coop) +# @author Sylvain LE GAL (https://twitter.com/legalsylvain) +# +# This program is free software: you can redistribute it and/or modify +# 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 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 . +# +############################################################################## + +from . import pos_order diff --git a/pos_order_pricelist_change/model/pos_order.py b/pos_order_pricelist_change/model/pos_order.py new file mode 100644 index 00000000..e182af9d --- /dev/null +++ b/pos_order_pricelist_change/model/pos_order.py @@ -0,0 +1,52 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Point Of Sale - Order Pricelist Change for Odoo +# Copyright (C) 2014 GRAP (http://www.grap.coop) +# @author Sylvain LE GAL (https://twitter.com/legalsylvain) +# +# This program is free software: you can redistribute it and/or modify +# 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 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 . +# +############################################################################## + +from openerp.osv.orm import Model +from openerp.tools.translate import _ + + +class pos_order(Model): + _inherit = 'pos.order' + + def action_recompute_pricelist(self, cr, uid, ids, context=None): + pol_obj = self.pool.get('pos.order.line') + for po in self.browse(cr, uid, ids, context=context): + for pol in po.lines: + res = pol_obj.onchange_product_id( + cr, uid, [pol.id], po.pricelist_id.id, pol.product_id.id, + pol.qty, po.partner_id.id) + if res['value']['price_unit'] != pol.price_unit: + pol_obj.write( + cr, uid, [pol.id], res['value'], context=context) + + def onchange_pricelist_id( + self, cr, uid, ids, pricelist_id, lines, context=None): + if not pricelist_id or not lines: + return {} + warning = { + 'title': _('Pricelist Warning!'), + 'message': _( + """If you change the pricelist of this order,""" + """ prices of existing order lines will not be updated.""" + """ Please click on the 'Recompute With Pricelist'.""") + } + return {'warning': warning} diff --git a/pos_order_pricelist_change/static/src/img/icon.png b/pos_order_pricelist_change/static/src/img/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..6a10188bda4e131c5bf6bf3ca600fe1645894f6e GIT binary patch literal 8773 zcmaiabyQSe)HbCcAR$P%iZlZZh@^B5JxKRZ(%q$Wi-5E+QiF6ig0z%~BMdO~(2X>F z_qW#f{`s!=tb6CIduP_1bNAWLv-f_^jn&dndQ3=1h=qmqSVdW02k688I|&{FpM6r6 zqdr3Va4#>UkO z#-ieEX$RARS=#u!55pv|uvoBE-m4J=guX84&+<=Ji^1tBpWo=P7RyKrz;4KjDe-=W zjr_!t%*^kCoVTL?-QM1bmNqYd$Y^Y_ETy6C8$a8Ti-CEKi;aKU|6J`&r~Gg2Fhaq< zN+<^`bz!vs6R&tZr6M1qF!tL?oZ|(SK z-bkq`V+Cv|ROxB=x|GcG4{RK9z2AauSHi#Ii$3P@yst0jwjSm|)B zt?^aYgifgv&7(NPmvXK)L=i%DK2b?qp5w{e4g?4AH=}B5o7n^3aq%y^&D$8ENOy_k zPE7u&d}Wjag5_uvbj9QLZ94t6c<5Yo_z&zmYJFqIEm1yP^dOO3#vCIUB8LQfIh$;) zvePTBI#RF_;7A|~ky~yzo8%+uTwMnzW7VN~l9>G$#B#s3z-P8;{i}noPlw=Z96l%~nee_t^zJT71wKPfXX!fyct@?w-@ZVXb;CL@o~ ziYX$C#UrAut{hZzky zCt*f9Te@nhMwb1y{Q#3f1U;U6CbI&0-}f*U0ISo%seBO^0K`LpzW5Z4T0WuKC0UCYq%HXQ{8#nGkEvzMtxv zx_s#?-r*1tJKT^92JxQWUL5r0xUb)qnt5D_!+h}hLeL6DLC=XqFGwEg?Xx%6zn*D6 zzQ54^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644 index 00000000..c2dcc170 --- /dev/null +++ b/pos_order_pricelist_change/tests/__init__.py @@ -0,0 +1,27 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Point Of Sale - Order Pricelist Change for Odoo +# Copyright (C) 2013-2014 GRAP (http://www.grap.coop) +# @author Sylvain LE GAL (https://twitter.com/legalsylvain) +# +# This program is free software: you can redistribute it and/or modify +# 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 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 . +# +############################################################################## + +from . import test_pos_order_pricelist_change + +fast_suite = [ + test_pos_order_pricelist_change, +] diff --git a/pos_order_pricelist_change/tests/test_pos_order_pricelist_change.py b/pos_order_pricelist_change/tests/test_pos_order_pricelist_change.py new file mode 100644 index 00000000..2431a5d8 --- /dev/null +++ b/pos_order_pricelist_change/tests/test_pos_order_pricelist_change.py @@ -0,0 +1,188 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Point Of Sale - Order Pricelist Change for Odoo +# Copyright (C) 2014 GRAP (http://www.grap.coop) +# @author Sylvain LE GAL (https://twitter.com/legalsylvain) +# +# This program is free software: you can redistribute it and/or modify +# 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 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 . +# +############################################################################## + +from openerp.tests.common import TransactionCase + + +class TestPosOrderPricelistChange(TransactionCase): + """Tests for Point Of Sale - Order Pricelist Change Module""" + + def setUp(self): + super(TestPosOrderPricelistChange, self).setUp() + self.imd_obj = self.registry('ir.model.data') + self.pp_obj = self.registry('product.product') + self.ppl_obj = self.registry('product.pricelist') + self.po_obj = self.registry('pos.order') + self.pol_obj = self.registry('pos.order.line') + self.pc_obj = self.registry('pos.config') + self.ps_obj = self.registry('pos.session') + + # Test Section + def test_01_default_price_list(self): + """[Regression Test] Sale with default Pricelist""" + cr, uid = self.cr, self.uid + # Getting object + pc_id = self.imd_obj.get_object_reference( + cr, uid, 'point_of_sale', 'pos_config_main')[1] + rp_c2c_id = self.imd_obj.get_object_reference( + cr, uid, 'base', 'res_partner_12')[1] + ppl_c2c_id = self.imd_obj.get_object_reference( + cr, uid, 'product', 'list0')[1] + pp_usb_id = self.imd_obj.get_object_reference( + cr, uid, 'product', 'product_product_48')[1] + + # Opening Session + self.ps_obj.create(cr, uid, { + 'config_id': pc_id, + }) + + # create Pos Order + po_id = self.po_obj.create(cr, uid, { + 'partner_id': rp_c2c_id, + 'pricelist_id': ppl_c2c_id, + 'lines': [[0, False, { + 'product_id': pp_usb_id, + 'qty': 1, + }]], + }) + pp_usb = self.pp_obj.browse(cr, uid, pp_usb_id) + po = self.po_obj.browse(cr, uid, po_id) + + res = self.pol_obj.onchange_product_id( + cr, uid, po.lines[0].id, po.pricelist_id.id, + po.lines[0].product_id.id, po.lines[0].qty) + + self.assertEquals( + res['value']['price_subtotal'], pp_usb.list_price, + "Incorrect price for default pricelist!") + + def test_02_partner_with_price_list_before(self): + """[Regression Test] Sale with specific Pricelist""" + cr, uid = self.cr, self.uid + # Getting object + pc_id = self.imd_obj.get_object_reference( + cr, uid, 'point_of_sale', 'pos_config_main')[1] + rp_spe_id = self.imd_obj.get_object_reference( + cr, uid, 'pos_order_pricelist_change', 'partner_surcharge')[1] + ppl_spe_id = self.imd_obj.get_object_reference( + cr, uid, 'pos_order_pricelist_change', 'pricelist_surcharge')[1] + pp_usb_id = self.imd_obj.get_object_reference( + cr, uid, 'product', 'product_product_48')[1] + + # Opening Session + self.ps_obj.create(cr, uid, { + 'config_id': pc_id, + }) + + # create Pos Order + po_id = self.po_obj.create(cr, uid, { + 'partner_id': rp_spe_id, + 'pricelist_id': ppl_spe_id, + 'lines': [[0, False, { + 'product_id': pp_usb_id, + 'qty': 1, + }]], + }) + pp_usb = self.pp_obj.browse(cr, uid, pp_usb_id) + po = self.po_obj.browse(cr, uid, po_id) + + res = self.pol_obj.onchange_product_id( + cr, uid, po.lines[0].id, po.pricelist_id.id, + po.lines[0].product_id.id, po.lines[0].qty) + self.assertEquals( + res['value']['price_subtotal'], pp_usb.list_price + 10, + "Incorrect price for specific pricelist!") + + def test_03_partner_with_price_list_after(self): + """[Functional Test] Change pricelist after have set lines.""" + cr, uid = self.cr, self.uid + # Getting object + pc_id = self.imd_obj.get_object_reference( + cr, uid, 'point_of_sale', 'pos_config_main')[1] + ppl_spe_id = self.imd_obj.get_object_reference( + cr, uid, 'pos_order_pricelist_change', 'pricelist_surcharge')[1] + ppl_c2c_id = self.imd_obj.get_object_reference( + cr, uid, 'product', 'list0')[1] + pp_usb_id = self.imd_obj.get_object_reference( + cr, uid, 'product', 'product_product_48')[1] + + # Opening Session + self.ps_obj.create(cr, uid, { + 'config_id': pc_id, + }) + + # create Pos Order + po_id = self.po_obj.create(cr, uid, { + 'pricelist_id': ppl_c2c_id, + 'lines': [[0, False, { + 'product_id': pp_usb_id, + 'qty': 1, + }]], + }) + po = self.po_obj.browse(cr, uid, po_id) + + res = self.po_obj.onchange_pricelist_id( + cr, uid, po.id, ppl_spe_id, po.lines) + self.assertNotEquals( + res.get('warning', False), False, + "Need warning!") + pp_usb = self.pp_obj.browse(cr, uid, pp_usb_id) + + # Change now pricelist + self.po_obj.write(cr, uid, [po_id], {'pricelist_id': ppl_spe_id}) + self.po_obj.action_recompute_pricelist(cr, uid, [po.id]) + po = self.po_obj.browse(cr, uid, po_id) + self.assertEquals( + po.amount_total, pp_usb.list_price + 10, + "Recompute with pricelist error") + + def test_04_partner_without_price_list_after(self): + """[Functional Test] Unset pricelist after have set lines.""" + cr, uid = self.cr, self.uid + # Getting object + pc_id = self.imd_obj.get_object_reference( + cr, uid, 'point_of_sale', 'pos_config_main')[1] + pp_usb_id = self.imd_obj.get_object_reference( + cr, uid, 'product', 'product_product_48')[1] + ppl_c2c_id = self.imd_obj.get_object_reference( + cr, uid, 'product', 'list0')[1] + + # Opening Session + self.ps_obj.create(cr, uid, { + 'config_id': pc_id, + }) + + # create Pos Order + po_id = self.po_obj.create(cr, uid, { + 'pricelist_id': ppl_c2c_id, + 'lines': [[0, False, { + 'product_id': pp_usb_id, + 'qty': 1, + }]], + }) + po = self.po_obj.browse(cr, uid, po_id) + + res = self.po_obj.onchange_pricelist_id( + cr, uid, po.id, False, po.lines) + self.assertEquals( + res.get('warning', False), False, + "Doesn't need warning!") diff --git a/pos_order_pricelist_change/view/view.xml b/pos_order_pricelist_change/view/view.xml new file mode 100644 index 00000000..783a5526 --- /dev/null +++ b/pos_order_pricelist_change/view/view.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + pos.order.form + pos.order + + +
+
+ + onchange_pricelist_id(pricelist_id, lines) + +
+
+ +
+