From e79298dfb8c3b103ca7f35f9e5bf66a044ccf85c Mon Sep 17 00:00:00 2001 From: Christopher Rogos Date: Wed, 21 Sep 2022 11:51:12 +0200 Subject: [PATCH] [IMP] Add link to contract in invoice chatter --- contract/__manifest__.py | 2 +- contract/models/contract.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/contract/__manifest__.py b/contract/__manifest__.py index 6ae6e05f3..7e3b36fc8 100644 --- a/contract/__manifest__.py +++ b/contract/__manifest__.py @@ -11,7 +11,7 @@ { "name": "Recurring - Contracts Management", - "version": "15.0.1.5.1", + "version": "15.0.1.5.2", "category": "Contract Management", "license": "AGPL-3", "author": "Tecnativa, ACSONE SA/NV, Odoo Community Association (OCA)", diff --git a/contract/models/contract.py b/contract/models/contract.py index 885db55c7..130221c72 100644 --- a/contract/models/contract.py +++ b/contract/models/contract.py @@ -604,9 +604,28 @@ class ContractContract(models.Model): partner_ids=partner_ids.ids ) + @api.model + def _add_contract_origin(self, invoices): + for item in self: + for move in invoices & item._get_related_invoices(): + move.message_post( + body=( + _( + ( + "%(msg)s by contract %(contract)s." + ), + msg=move._creation_message(), + contract_id=item.id, + contract=item.display_name, + ) + ) + ) + def _recurring_create_invoice(self, date_ref=False): invoices_values = self._prepare_recurring_invoices_values(date_ref) moves = self.env["account.move"].create(invoices_values) + self._add_contract_origin(moves) self._invoice_followers(moves) self._compute_recurring_next_date() return moves