Skip to content

Commit

Permalink
[FIX] product_configurator_sale
Browse files Browse the repository at this point in the history
price was not updating when on the sale order was set a pricelist with discout included in price
  • Loading branch information
techgrrow committed Jan 29, 2025
1 parent 7e91797 commit e10a53f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion product_configurator_sale/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
1 change: 1 addition & 0 deletions product_configurator_sale/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import sale
from . import product_pricelist
14 changes: 14 additions & 0 deletions product_configurator_sale/models/product_pricelist.py
Original file line number Diff line number Diff line change
@@ -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
16 changes: 15 additions & 1 deletion product_configurator_sale/models/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e10a53f

Please sign in to comment.