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
This commit is contained in:
Cédric Krier
2024-03-25 10:17:35 +01:00
parent a240337a51
commit 79e5ab807d
+2 -2
View File
@@ -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')