[15.0][MIG] product_contract : Migration to 15.0

This commit is contained in:
Adasat
2023-07-26 13:42:59 +00:00
committed by Adasat
parent 0a0218c9a8
commit 74407ad19d
12 changed files with 44 additions and 29 deletions

View File

@@ -18,7 +18,7 @@ class ContractLine(models.Model):
)
def _prepare_invoice_line(self, move_form):
res = super(ContractLine, self)._prepare_invoice_line(move_form)
res = super()._prepare_invoice_line(move_form)
if self.sale_order_line_id and res:
res["sale_line_ids"] = [(6, 0, [self.sale_order_line_id.id])]
return res

View File

@@ -68,7 +68,7 @@ class ProductTemplate(models.Model):
self.with_company(company).write(
{"property_contract_template_id": False}
)
super().write(vals)
return super().write(vals)
@api.constrains("is_contract", "type")
def _check_contract_product_type(self):

View File

@@ -94,8 +94,9 @@ class SaleOrder(models.Model):
raise ValidationError(
_(
"You must specify a contract "
"template for '{}' product in '{}' company."
).format(order_line.product_id.name, rec.company_id.name)
"template for '%(order_line.product_id.name)s' "
"product in '%(rec.company_id.name)s' company."
)
)
contract_templates |= contract_template
for contract_template in contract_templates:

View File

@@ -43,8 +43,8 @@ class SaleOrderLine(models.Model):
help="Specify if process date is 'from' or 'to' invoicing date",
copy=False,
)
date_start = fields.Date(string="Date Start")
date_end = fields.Date(string="Date End")
date_start = fields.Date()
date_end = fields.Date()
contract_line_id = fields.Many2one(
comodel_name="contract.line",
@@ -142,13 +142,13 @@ class SaleOrderLine(models.Model):
@api.onchange("product_id")
def product_id_change(self):
super().product_id_change()
for rec in self:
if rec.product_id.is_contract:
rec.is_contract = True
else:
# Don't initialize wrong values
rec.is_contract = False
return super().product_id_change()
def _get_contract_line_qty(self):
"""Returns the quantity to be put on new contract lines."""