mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[MIG] subscription_oca: Migration to 16.0
This commit is contained in:
@@ -96,8 +96,8 @@ class SaleSubscriptionLine(models.Model):
|
||||
for line in self:
|
||||
fpos = (
|
||||
line.sale_subscription_id.fiscal_position_id
|
||||
or line.sale_subscription_id.fiscal_position_id.get_fiscal_position(
|
||||
line.sale_subscription_id.partner_id.id
|
||||
or line.sale_subscription_id.fiscal_position_id._get_fiscal_position(
|
||||
line.sale_subscription_id.partner_id
|
||||
)
|
||||
)
|
||||
# If company_id is set, always filter taxes by the company
|
||||
@@ -174,10 +174,9 @@ class SaleSubscriptionLine(models.Model):
|
||||
partner_id=record.sale_subscription_id.partner_id.id,
|
||||
date=fields.Datetime.now(),
|
||||
uom=record.product_id.uom_id.id,
|
||||
).get_product_price_rule(
|
||||
)._get_product_price_rule(
|
||||
record.product_id,
|
||||
record.product_uom_qty or 1.0,
|
||||
record.sale_subscription_id.partner_id,
|
||||
)
|
||||
new_list_price, currency = record.with_context(
|
||||
partner_id=record.sale_subscription_id.partner_id.id,
|
||||
@@ -203,7 +202,7 @@ class SaleSubscriptionLine(models.Model):
|
||||
|
||||
def _get_real_price_currency(self, product, rule_id, qty, uom):
|
||||
PricelistItem = self.env["product.pricelist.item"]
|
||||
field_name = "lst_price"
|
||||
product_price = product.lst_price
|
||||
currency_id = None
|
||||
product_currency = product.currency_id
|
||||
if rule_id:
|
||||
@@ -217,18 +216,18 @@ class SaleSubscriptionLine(models.Model):
|
||||
):
|
||||
_price, rule_id = pricelist_item.base_pricelist_id.with_context(
|
||||
uom=uom.id
|
||||
).get_product_price_rule(
|
||||
product, qty, self.sale_subscription_id.partner_id
|
||||
)
|
||||
)._get_product_price_rule(product, qty)
|
||||
pricelist_item = PricelistItem.browse(rule_id)
|
||||
|
||||
if pricelist_item.base == "standard_price":
|
||||
field_name = "standard_price"
|
||||
product_price = product.standard_price
|
||||
product_currency = product.cost_currency_id
|
||||
elif (
|
||||
pricelist_item.base == "pricelist" and pricelist_item.base_pricelist_id
|
||||
):
|
||||
field_name = "price"
|
||||
product_price = pricelist_item.base_pricelist_id._get_product_price(
|
||||
product, self.product_uom_qty or 1.0, uom=self.product_id.uom_id
|
||||
)
|
||||
product = product.with_context(
|
||||
pricelist=pricelist_item.base_pricelist_id.id
|
||||
)
|
||||
@@ -256,23 +255,21 @@ class SaleSubscriptionLine(models.Model):
|
||||
else:
|
||||
uom_factor = 1.0
|
||||
|
||||
return product[field_name] * uom_factor * cur_factor, currency_id
|
||||
return product_price * uom_factor * cur_factor, currency_id
|
||||
|
||||
def _get_display_price(self, product):
|
||||
if self.sale_subscription_id.pricelist_id.discount_policy == "with_discount":
|
||||
return product.with_context(
|
||||
pricelist=self.sale_subscription_id.pricelist_id.id,
|
||||
uom=self.product_id.uom_id.id,
|
||||
).price
|
||||
return self.sale_subscription_id.pricelist_id._get_product_price(
|
||||
product, self.product_uom_qty or 1.0, uom=self.product_id.uom_id
|
||||
)
|
||||
|
||||
final_price, rule_id = self.sale_subscription_id.pricelist_id.with_context(
|
||||
partner_id=self.sale_subscription_id.partner_id.id,
|
||||
date=fields.Datetime.now(),
|
||||
uom=self.product_id.uom_id.id,
|
||||
).get_product_price_rule(
|
||||
)._get_product_price_rule(
|
||||
product or self.product_id,
|
||||
self.product_uom_qty or 1.0,
|
||||
self.sale_subscription_id.partner_id,
|
||||
)
|
||||
base_price, currency = self.with_context(
|
||||
partner_id=self.sale_subscription_id.partner_id.id,
|
||||
|
||||
Reference in New Issue
Block a user