diff --git a/models/res_partner_contract_annex.py b/models/res_partner_contract_annex.py index a751955..1095018 100644 --- a/models/res_partner_contract_annex.py +++ b/models/res_partner_contract_annex.py @@ -12,6 +12,7 @@ class ContractOrderAnnex(models.Model, IDocument, Extension): name = fields.Char(string="Name",) display_name = fields.Char(compute="_compute_display_name",) + specification_name = fields.Char(compute="_compute_specification_name",) order_id = fields.Many2one( "sale.order", string="Order", @@ -57,6 +58,13 @@ class ContractOrderAnnex(models.Model, IDocument, Extension): for record in self: record.display_name = "№{} {}".format(record.number or record.contract_id.contract_annex_number, record.name) + @api.depends('specification_name', 'contract_id', 'order_id') + def _compute_specification_name(self): + self.specification_name = _("{name} from {date}").format( + name="{}-{}".format(self.contract_id.name, self.order_id.name), + date=self.contract_id.get_date().strftime("%d.%m.%Y"), + ) + @api.model def create(self, values): record = super().create(values) diff --git a/wizard/res_partner_contract_wizard.py b/wizard/res_partner_contract_wizard.py index 7c715ad..811f3cb 100644 --- a/wizard/res_partner_contract_wizard.py +++ b/wizard/res_partner_contract_wizard.py @@ -161,13 +161,9 @@ class ContractWizard(models.TransientModel): if transient_field.technical_name and transient_field.value } if self.target._name == "res.partner.contract.annex": - # TODO: bad fields.update({ "annex_name": self.document_name, - "specification_name": _("{name} from {date}").format( - name="{}-{}".format(self.target.contract_id.name, self.target.order_id.name), - date=self.target.contract_id.get_date().strftime("%d.%m.%Y"), - ), + "specification_name": self.target.specification_name, }) binary_data = get_document_from_values_stream(path_to_template, fields).read()