From 16fae70238880002f2cfa3afd5d363b484ca8b44 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Mon, 5 Mar 2018 19:22:12 +0100 Subject: [PATCH] [8.0][fix] pos_pricelist (#252) * In backoffice, set correct sale taxes on pos order lines * PoS order created from PoS UI doesn't have the correct pricelist_id defined * Possibility to see and change pricelist when creating / updating a customer in Front UI --- pos_pricelist/__openerp__.py | 2 +- pos_pricelist/i18n/fr.po | 91 ++++++++++++++++++--------- pos_pricelist/models/__init__.py | 1 + pos_pricelist/models/point_of_sale.py | 17 +++++ pos_pricelist/models/res_partner.py | 20 ++++++ pos_pricelist/static/src/js/models.js | 18 ++++++ pos_pricelist/static/src/xml/pos.xml | 34 +++++++++- 7 files changed, 151 insertions(+), 32 deletions(-) create mode 100644 pos_pricelist/models/res_partner.py diff --git a/pos_pricelist/__openerp__.py b/pos_pricelist/__openerp__.py index 569330b9..d5856440 100644 --- a/pos_pricelist/__openerp__.py +++ b/pos_pricelist/__openerp__.py @@ -5,7 +5,7 @@ { 'name': 'POS Pricelist', - 'version': '8.0.1.4.0', + 'version': '8.0.1.5.0', 'category': 'Point Of Sale', 'sequence': 1, 'author': "Adil Houmadi @Taktik, " diff --git a/pos_pricelist/i18n/fr.po b/pos_pricelist/i18n/fr.po index d71168dd..d2e8680d 100644 --- a/pos_pricelist/i18n/fr.po +++ b/pos_pricelist/i18n/fr.po @@ -8,32 +8,32 @@ msgid "" msgstr "" "Project-Id-Version: pos (8.0)\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-10-24 11:35+0000\n" -"PO-Revision-Date: 2017-09-22 22:56+0000\n" -"Last-Translator: OCA Transbot \n" -"Language-Team: French (http://www.transifex.com/oca/OCA-pos-8-0/language/fr/)\n" +"POT-Creation-Date: 2018-03-02 16:22+0000\n" +"PO-Revision-Date: 2018-03-02 16:22+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" -"Language: fr\n" -"Plural-Forms: nplurals=2; plural=(n > 1);\n" +"Plural-Forms: \n" #. module: pos_pricelist -#: field:pos.order.tax,amount:0 view:website:point_of_sale.report_receipt +#: field:pos.order.tax,amount:0 +#: view:website:point_of_sale.report_receipt msgid "Amount" msgstr "Montant" #. module: pos_pricelist #. openerp-web #: code:addons/pos_pricelist/static/src/js/models.js:402 +#: code:addons/pos_pricelist/static/src/js/models.js:422 #, python-format -msgid "" -"At least one pricelist has no active version ! Please create or activate " -"one." -msgstr "" +msgid "At least one pricelist has no active version ! Please create or activate one." +msgstr "Au moins une liste de prix n'a pas de version active ! Veuillez en créer ou en activer une." #. module: pos_pricelist -#: field:pos.order.tax,base:0 view:website:point_of_sale.report_receipt +#: field:pos.order.tax,base:0 +#: view:website:point_of_sale.report_receipt msgid "Base" msgstr "Base" @@ -60,10 +60,12 @@ msgstr "Nom à afficher" #. module: pos_pricelist #: help:pos.config,display_price_with_taxes:0 msgid "Display Prices with taxes on POS" -msgstr "" +msgstr "Afficher les prix TTC sur le point de vente" #. module: pos_pricelist +#: code:addons/pos_pricelist/models/pos_order_patch.py:26 #: code:addons/pos_pricelist/models/pos_order_patch.py:28 +#: code:addons/pos_pricelist/models/pos_order_patch.py:152 #: code:addons/pos_pricelist/models/pos_order_patch.py:154 #, python-format msgid "Error!" @@ -94,30 +96,42 @@ msgstr "Dernière mise à jour le" msgid "Lines of Point of Sale" msgstr "Lignes de Points de Vente" +#. module: pos_pricelist +#. openerp-web +#: code:addons/pos_pricelist/static/src/xml/pos.xml:46 +#, python-format +msgid "N/A" +msgstr "N/A" + #. module: pos_pricelist #: field:pos.order.tax,pos_order:0 msgid "POS Order" -msgstr "" +msgstr "Vente" #. module: pos_pricelist #: model:product.template,name:pos_pricelist.pos_product_product_1_product_template msgid "POS Product 1" -msgstr "" +msgstr "POS Product 1" #. module: pos_pricelist #: model:product.template,name:pos_pricelist.pos_product_product_2_product_template msgid "POS Product 2" -msgstr "" +msgstr "POS Product 2" #. module: pos_pricelist #: model:product.template,name:pos_pricelist.pos_product_product_3_product_template msgid "POS Product 3" -msgstr "" +msgstr "POS Product 3" #. module: pos_pricelist #: model:product.template,name:pos_pricelist.pos_product_product_4_product_template msgid "POS Product 4" -msgstr "" +msgstr "POS Product 4" + +#. module: pos_pricelist +#: model:ir.model,name:pos_pricelist.model_res_partner +msgid "Partner" +msgstr "Partenaire" #. module: pos_pricelist #: view:pos.order:pos_pricelist.view_pos_pos_form @@ -125,38 +139,52 @@ msgid "Payments" msgstr "Paiements" #. module: pos_pricelist +#: code:addons/pos_pricelist/models/pos_order_patch.py:152 #: code:addons/pos_pricelist/models/pos_order_patch.py:154 #, python-format msgid "Please define income account for this product: \"%s\" (id:%d)." -msgstr "" +msgstr "Veuillez définir un compte de revenu pour cet article : \"%s\" (id. : %d)" #. module: pos_pricelist #: model:ir.model,name:pos_pricelist.model_pos_order msgid "Point of Sale" -msgstr "Point de vente" +msgstr "Point de Vente" #. module: pos_pricelist #: field:pos.config,display_price_with_taxes:0 msgid "Price With Taxes" -msgstr "" +msgstr "Prix TTC" + +#. module: pos_pricelist +#. openerp-web +#: code:addons/pos_pricelist/static/src/xml/pos.xml:41 +#: code:addons/pos_pricelist/static/src/xml/pos.xml:55 +#, python-format +msgid "Pricelist" +msgstr "Liste de prix" #. module: pos_pricelist #. openerp-web #: code:addons/pos_pricelist/static/src/js/models.js:401 +#: code:addons/pos_pricelist/static/src/js/models.js:421 #, python-format msgid "Pricelist Error" -msgstr "" +msgstr "Erreur de liste de prix" #. module: pos_pricelist +#: code:addons/pos_pricelist/models/pos_order_patch.py:26 #: code:addons/pos_pricelist/models/pos_order_patch.py:28 #, python-format msgid "Selected orders do not have the same session!" -msgstr "" +msgstr "Les commandes sélectionnées n'ont pas la même session !" #. module: pos_pricelist +#: code:addons/pos_pricelist/models/pos_order_patch.py:188 #: code:addons/pos_pricelist/models/pos_order_patch.py:190 +#: code:addons/pos_pricelist/models/pos_order_patch.py:205 #: code:addons/pos_pricelist/models/pos_order_patch.py:207 -#: field:pos.order.tax,tax:0 view:website:point_of_sale.report_receipt +#: field:pos.order.tax,tax:0 +#: view:website:point_of_sale.report_receipt #, python-format msgid "Tax" msgstr "Taxe" @@ -164,10 +192,11 @@ msgstr "Taxe" #. module: pos_pricelist #: field:pos.order.tax,name:0 msgid "Tax Description" -msgstr "" +msgstr "Description de la taxe" #. module: pos_pricelist -#: view:pos.order:pos_pricelist.view_pos_pos_form field:pos.order,taxes:0 +#: view:pos.order:pos_pricelist.view_pos_pos_form +#: field:pos.order,taxes:0 #: field:pos.order.line,tax_ids:0 msgid "Taxes" msgstr "Taxes" @@ -175,21 +204,23 @@ msgstr "Taxes" #. module: pos_pricelist #: model:ir.model,name:pos_pricelist.model_account_fiscal_position_tax msgid "Taxes Fiscal Position" -msgstr "" +msgstr "Position fiscale des taxes" #. module: pos_pricelist #: view:pos.order:pos_pricelist.view_pos_pos_form msgid "Taxes detail" -msgstr "" +msgstr "Détail des taxes" #. module: pos_pricelist +#: code:addons/pos_pricelist/models/pos_order_patch.py:117 #: code:addons/pos_pricelist/models/pos_order_patch.py:119 #, python-format msgid "The POS order must have lines when calling this method" -msgstr "" +msgstr "Le point de vente doit avoir des lignes lors de l'appel à cette méthode" #. module: pos_pricelist +#: code:addons/pos_pricelist/models/pos_order_patch.py:218 #: code:addons/pos_pricelist/models/pos_order_patch.py:220 #, python-format msgid "Trade Receivables" -msgstr "" +msgstr "Marchandises à recevoir" diff --git a/pos_pricelist/models/__init__.py b/pos_pricelist/models/__init__.py index 467e1253..6751b457 100644 --- a/pos_pricelist/models/__init__.py +++ b/pos_pricelist/models/__init__.py @@ -7,3 +7,4 @@ from . import account_fiscal_position from . import pos_pricelist from . import point_of_sale from . import pos_order_patch +from . import res_partner diff --git a/pos_pricelist/models/point_of_sale.py b/pos_pricelist/models/point_of_sale.py index 4ff55a55..418f8ae2 100644 --- a/pos_pricelist/models/point_of_sale.py +++ b/pos_pricelist/models/point_of_sale.py @@ -73,6 +73,17 @@ class PosOrderLine(models.Model): price_subtotal = fields.Float(compute="_amount_line_all", store=True) price_subtotal_incl = fields.Float(compute="_amount_line_all", store=True) + @api.multi + def onchange_product_id( + self, pricelist, product_id, qty=0, partner_id=False): + product_obj = self.env['product.product'] + res = super(PosOrderLine, self).onchange_product_id( + pricelist, product_id, qty=qty, partner_id=partner_id) + if product_id: + product = product_obj.browse(product_id) + res['value']['tax_ids'] = product.taxes_id.ids + return res + class PosOrder(models.Model): _inherit = "pos.order" @@ -80,6 +91,12 @@ class PosOrder(models.Model): taxes = fields.One2many(comodel_name='pos.order.tax', inverse_name='pos_order', readonly=True) + @api.model + def _order_fields(self, ui_order): + res = super(PosOrder, self)._order_fields(ui_order) + res.update({'pricelist_id': ui_order['pricelist_id']}) + return res + @api.model def _amount_line_tax(self, line): price = line.price_unit * (1 - (line.discount or 0.0) / 100.0) diff --git a/pos_pricelist/models/res_partner.py b/pos_pricelist/models/res_partner.py new file mode 100644 index 00000000..b4440dea --- /dev/null +++ b/pos_pricelist/models/res_partner.py @@ -0,0 +1,20 @@ +# coding: utf-8 +# Copyright (C) 2018 - Today: GRAP (http://www.grap.coop) +# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openerp import api, models + + +class ResPartner(models.Model): + _inherit = 'res.partner' + + @api.model + def create_from_ui(self, partner): + if 'property_product_pricelist' in partner: + pricelist_id_str = partner.get('property_product_pricelist') + if pricelist_id_str: + partner['property_product_pricelist'] = int(pricelist_id_str) + else: + partner['property_product_pricelist'] = False + return super(ResPartner, self).create_from_ui(partner) diff --git a/pos_pricelist/static/src/js/models.js b/pos_pricelist/static/src/js/models.js index 82c74407..c82eaaaa 100644 --- a/pos_pricelist/static/src/js/models.js +++ b/pos_pricelist/static/src/js/models.js @@ -73,6 +73,24 @@ function pos_pricelist_models(instance, module) { } }); + /** + * Extend the Order + */ + var moduleOrderParent = module.Order; + module.Order = module.Order.extend({ + export_as_JSON: function() { + var order = moduleOrderParent.prototype.export_as_JSON.apply(this, arguments); + partner = this.get_client(); + if (partner && partner.property_product_pricelist) { + pricelist_id = partner.property_product_pricelist[0]; + } else { + pricelist_id = this.pos.config.pricelist_id[0]; + } + order['pricelist_id'] = pricelist_id; + return order; + }, + }); + /** * Extend the Order line */ diff --git a/pos_pricelist/static/src/xml/pos.xml b/pos_pricelist/static/src/xml/pos.xml index 51fc5099..0f6b90aa 100644 --- a/pos_pricelist/static/src/xml/pos.xml +++ b/pos_pricelist/static/src/xml/pos.xml @@ -34,4 +34,36 @@ - \ No newline at end of file + + + +
+ Pricelist + + + + + N/A + +
+
+
+ + + +
+ Pricelist + +
+
+
+ +