LaOsaCoop/Odoo16#52 fix product_sale_price_from_pricelist to include taxes in final price
This commit is contained in:
parent
eaec1c6b38
commit
80cc00c873
1 changed files with 15 additions and 3 deletions
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
from odoo import exceptions, models, fields, api, _
|
||||
from odoo.exceptions import UserError
|
||||
import math
|
||||
|
||||
|
||||
class ProductTemplate(models.Model):
|
||||
|
|
@ -65,11 +66,22 @@ class ProductTemplate(models.Model):
|
|||
partial_price = template.product_variant_id._get_price(
|
||||
qty=1, pricelist=pricelist
|
||||
)
|
||||
# Compute taxes to add
|
||||
tax_price = self.taxes_id.compute_all(
|
||||
partial_price[template.product_variant_id.id]["value"] or 0.0,
|
||||
handle_price_include=False,
|
||||
)
|
||||
price_with_taxes = (
|
||||
tax_price["taxes"][0]["amount"]
|
||||
+ partial_price[template.product_variant_id.id]["value"]
|
||||
)
|
||||
# Round to 0.05
|
||||
if round(price_with_taxes % 0.05, 2) != 0:
|
||||
price_with_taxes = math.ceil(price_with_taxes / 0.05) * 0.05
|
||||
|
||||
template.write(
|
||||
{
|
||||
"list_price_theoritical": partial_price[
|
||||
template.product_variant_id.id
|
||||
]["value"],
|
||||
"list_price_theoritical": price_with_taxes,
|
||||
"last_purchase_price_updated": True,
|
||||
}
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue