Defer invoice line only once
The post method can be called multiple times for an invoice by process but only one deferral is allowed by line. Also the initial draft deferral may be delete in case of mistake so we must not create automatically a new one later. Closes #12567 (grafted from 7c72d42d78d92db1fbe36217d3ba4720bb621521) --HG-- branch : 6.0
This commit is contained in:
1 parent
87086931cc
commit
2bf177778c
1 file changed
+3
-1
@@ -445,9 +445,11 @@ class Invoice(metaclass=PoolMeta):
|
||||
def _post(cls, invoices):
|
||||
pool = Pool()
|
||||
InvoiceDeferred = pool.get('account.invoice.deferred')
|
||||
# defer invoices only the first time post is called
|
||||
invoices_to_defer = [i for i in invoices if not i.move]
|
||||
super()._post(invoices)
|
||||
deferrals = []
|
||||
for invoice in invoices:
|
||||
for invoice in invoices_to_defer:
|
||||
for line in invoice.lines:
|
||||
if line.deferrable and line.defer_from and line.defer_to:
|
||||
deferral = InvoiceDeferred(
|
||||
|
||||
Reference in new issue
Block a user