Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][FIX] product_configurator_sale: pricelist with discount included in price #149

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading