From 52ff3e361fd36e523f782201ec5c78844d820ae4 Mon Sep 17 00:00:00 2001 From: Juliana Date: Thu, 10 Sep 2020 11:14:28 +0200 Subject: [PATCH] Modif pack: affichage du bon prix sur site + gestion des stocks + affichage prix au kilo --- __manifest__.py | 4 +++- models/__init__.py | 3 ++- models/product_template.py | 40 ++++++++++++++++++++++++++++++++ views/product_template_views.xml | 15 ++++++++++++ views/templates.xml | 32 +++++++++++++++++++++++++ 5 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 models/product_template.py create mode 100644 views/product_template_views.xml create mode 100644 views/templates.xml diff --git a/__manifest__.py b/__manifest__.py index f522471..91fe5fa 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -13,6 +13,8 @@ ], "data": [ 'security/ir.model.access.csv', - 'report/sale_report.xml' + 'report/sale_report.xml', + 'views/product_template_views.xml', + 'views/templates.xml' ] } diff --git a/models/__init__.py b/models/__init__.py index 8008ded..9eb91fd 100644 --- a/models/__init__.py +++ b/models/__init__.py @@ -1,4 +1,5 @@ # © 2019 Le Filament () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from . import sale_order \ No newline at end of file +from . import sale_order +from . import product_template \ No newline at end of file diff --git a/models/product_template.py b/models/product_template.py new file mode 100644 index 0000000..9bb467d --- /dev/null +++ b/models/product_template.py @@ -0,0 +1,40 @@ +# © 2020 Le Filament () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import _, api, fields, models +from odoo.exceptions import ValidationError + +from odoo.addons import decimal_precision as dp + + +class ProductTemplate(models.Model): + _inherit = 'product.template' + + list_price_ref_pack = fields.Float( + 'Prix référent au kilo', default=1.0, + digits=dp.get_precision('Product Price'), + compute='_compute_list_price_ref_pack') + price_ref_pack_compute = fields.Float( + 'Prix calculé', default=1.0, + digits=dp.get_precision('Product Price'), + compute='_compute_price_ref_pack_compute') + + def _compute_list_price_ref_pack(self): + for template in self: + if template.pack_line_ids: + if template.pack_ok and (template.pack_type == 'detailed' and template.pack_component_price == 'totalized'): + pack_price_ref = 0.0 + for pack_line in template.pack_line_ids: + pack_price_ref += pack_line.product_id.list_price + template.list_price_ref_pack = pack_price_ref + # template.list_price_ref_pack = template.pack_line_ids[0].product_id.list_price + + def _compute_price_ref_pack_compute(self): + for template in self: + if template.pack_line_ids: + if template.pack_ok and (template.pack_type == 'detailed' and template.pack_component_price == 'totalized'): + pack_price = 0.0 + for pack_line in template.pack_line_ids: + pack_price += pack_line.product_id.list_price * pack_line.quantity + template.price_ref_pack_compute = pack_price + \ No newline at end of file diff --git a/views/product_template_views.xml b/views/product_template_views.xml new file mode 100644 index 0000000..afe7590 --- /dev/null +++ b/views/product_template_views.xml @@ -0,0 +1,15 @@ + + + + + product.template.pack.form + product.template + + + + + + + + + diff --git a/views/templates.xml b/views/templates.xml new file mode 100644 index 0000000..3c028a2 --- /dev/null +++ b/views/templates.xml @@ -0,0 +1,32 @@ + + + + + + + + \ No newline at end of file