diff --git a/product_configurator_sale/__manifest__.py b/product_configurator_sale/__manifest__.py index 0759141da..08fd9df9a 100644 --- a/product_configurator_sale/__manifest__.py +++ b/product_configurator_sale/__manifest__.py @@ -2,7 +2,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { "name": "Product Configurator Sale", - "version": "16.0.1.0.1", + "version": "16.0.1.0.2", "category": "Generic Modules/Sale", "summary": "Product configuration interface modules for Sale", "author": "Pledra, Odoo Community Association (OCA)", diff --git a/product_configurator_sale/models/__init__.py b/product_configurator_sale/models/__init__.py index b2e71ae34..14b30e0f7 100644 --- a/product_configurator_sale/models/__init__.py +++ b/product_configurator_sale/models/__init__.py @@ -2,3 +2,4 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from . import sale +from . import product_pricelist diff --git a/product_configurator_sale/models/product_pricelist.py b/product_configurator_sale/models/product_pricelist.py new file mode 100644 index 000000000..91817ae45 --- /dev/null +++ b/product_configurator_sale/models/product_pricelist.py @@ -0,0 +1,14 @@ +from odoo import models + + +class PricelistItem(models.Model): + _inherit = "product.pricelist.item" + + def _compute_base_price(self, product, quantity, uom, date, target_currency): + if self.env.context.get("config_price"): + price = self.env.context.get("config_price") + else: + price = super()._compute_base_price( + product, quantity, uom, date, target_currency + ) + return price diff --git a/product_configurator_sale/models/sale.py b/product_configurator_sale/models/sale.py index 57cadb1de..41267f071 100644 --- a/product_configurator_sale/models/sale.py +++ b/product_configurator_sale/models/sale.py @@ -64,12 +64,26 @@ def _compute_price_unit(self): for line in self: if line.config_session_id: account_tax_obj = self.env["account.tax"] + config_price = line.config_session_id.price + # context = self.env.context + # add config price to context + # self = self.with_context(config_price=config_price) + + # import ipdb; ipdb.set_trace() + if line.order_id.pricelist_id.discount_policy == "with_discount": + line = line.with_context(config_price=config_price) + price = line._get_pricelist_price() + else: + price = config_price + # price = super(SaleOrderLine, line)._compute_price_unit() + # import ipdb; ipdb.set_trace() line.price_unit = account_tax_obj._fix_tax_included_price_company( - line.config_session_id.price, + price, line.product_id.taxes_id, line.tax_id, line.company_id, ) + else: result = super(SaleOrderLine, line)._compute_price_unit() return result