mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[IMP] contract_price_revision: Improve compatibility with contract base module
Values for new line should come from _prepare_value_for_plan_successor function adding the new price.
This commit is contained in:
@@ -47,3 +47,16 @@ class ContractLine(models.Model):
|
|||||||
) * 100
|
) * 100
|
||||||
else:
|
else:
|
||||||
line.variation_percent = 0.0
|
line.variation_percent = 0.0
|
||||||
|
|
||||||
|
def _prepare_value_for_plan_successor_price(
|
||||||
|
self, date_start, date_end, is_auto_renew, price, recurring_next_date=False
|
||||||
|
):
|
||||||
|
"""
|
||||||
|
Override contract function to prepare values for new contract line
|
||||||
|
adding the new price as parameter
|
||||||
|
"""
|
||||||
|
res = super()._prepare_value_for_plan_successor(
|
||||||
|
date_start, date_end, is_auto_renew, recurring_next_date=recurring_next_date
|
||||||
|
)
|
||||||
|
res.update({"price_unit": price})
|
||||||
|
return res
|
||||||
|
|||||||
@@ -46,13 +46,13 @@ class ContractPriceRevisionWizard(models.TransientModel):
|
|||||||
|
|
||||||
def _get_new_line_value(self, line):
|
def _get_new_line_value(self, line):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
return {
|
return line._prepare_value_for_plan_successor_price(
|
||||||
"date_start": self.date_start,
|
self.date_start,
|
||||||
"last_date_invoiced": False,
|
self.date_end,
|
||||||
"date_end": self.date_end,
|
line.is_auto_renew,
|
||||||
"predecessor_contract_line_id": line.id,
|
self._get_new_price(line),
|
||||||
"price_unit": self._get_new_price(line),
|
False,
|
||||||
}
|
)
|
||||||
|
|
||||||
def _get_old_line_date_end(self, line):
|
def _get_old_line_date_end(self, line):
|
||||||
return self.date_start - relativedelta(days=1)
|
return self.date_start - relativedelta(days=1)
|
||||||
@@ -63,8 +63,7 @@ class ContractPriceRevisionWizard(models.TransientModel):
|
|||||||
for line in self._get_contract_lines_to_revise(contracts):
|
for line in self._get_contract_lines_to_revise(contracts):
|
||||||
date_end = self._get_old_line_date_end(line)
|
date_end = self._get_old_line_date_end(line)
|
||||||
line.stop(date_end)
|
line.stop(date_end)
|
||||||
new_line = line.copy()
|
new_line = line.copy(self._get_new_line_value(line))
|
||||||
new_line.update(self._get_new_line_value(line))
|
|
||||||
line.update({"successor_contract_line_id": new_line.id})
|
line.update({"successor_contract_line_id": new_line.id})
|
||||||
action = self.env["ir.actions.act_window"].for_xml_id(
|
action = self.env["ir.actions.act_window"].for_xml_id(
|
||||||
"contract", "action_customer_contract"
|
"contract", "action_customer_contract"
|
||||||
|
|||||||
Reference in New Issue
Block a user