From 79e5ab807d2cc6c6d8d50296e1d4bb20f77bb045 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 25 Mar 2024 10:17:35 +0100 Subject: [PATCH] Set posting employee only when using button As the posted by employee field can not be modified once the invoice is posted, the employee must be set only when it is an action of the user. On processing the invoice, it is the internal posting method that must be used so no employee is set nor any other warning checks. Closes #13124 --- modules/account_invoice/invoice.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/account_invoice/invoice.py b/modules/account_invoice/invoice.py index 711488231e..90bbc430a6 100644 --- a/modules/account_invoice/invoice.py +++ b/modules/account_invoice/invoice.py @@ -1817,6 +1817,7 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin, InvoiceReportMixin): @classmethod @ModelView.button @Workflow.transition('posted') + @set_employee('posted_by', when='before') def post(cls, invoices): pool = Pool() Date = pool.get('ir.date') @@ -1845,7 +1846,6 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin, InvoiceReportMixin): cls._post(invoices) @classmethod - @set_employee('posted_by', when='before') def _post(cls, invoices): pool = Pool() Move = pool.get('account.move') @@ -1988,7 +1988,7 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin, InvoiceReportMixin): else: posted.append(invoice) cls.paid(paid) - cls.post(posted) + cls._post(posted) @classmethod @Workflow.transition('paid')