Do not use invoices function field for invoice exception
This allows to reuse the design for invoices linked differently to the purchase. issue6274 review26161002
This commit is contained in:
+2
-4
@@ -1,5 +1,6 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from itertools import chain
|
||||
from functools import wraps
|
||||
from sql import Table
|
||||
|
||||
@@ -86,10 +87,7 @@ class Invoice:
|
||||
@ModelView.button
|
||||
@Workflow.transition('draft')
|
||||
def draft(cls, invoices):
|
||||
Purchase = Pool().get('purchase.purchase')
|
||||
purchases = Purchase.search([
|
||||
('invoices', 'in', [i.id for i in invoices]),
|
||||
])
|
||||
purchases = list(chain(*(i.purchases for i in invoices)))
|
||||
if purchases and any(i.state == 'cancel' for i in invoices):
|
||||
cls.raise_user_error('reset_invoice_purchase')
|
||||
|
||||
|
||||
+2
-8
@@ -1580,19 +1580,13 @@ class HandleInvoiceException(Wizard):
|
||||
|
||||
def transition_handle(self):
|
||||
Purchase = Pool().get('purchase.purchase')
|
||||
to_recreate = self.ask.recreate_invoices
|
||||
domain_invoices = self.ask.domain_invoices
|
||||
|
||||
purchase = Purchase(Transaction().context['active_id'])
|
||||
|
||||
skip = set(purchase.invoices_ignored)
|
||||
skip.update(purchase.invoices_recreated)
|
||||
invoices_ignored = []
|
||||
invoices_recreated = []
|
||||
for invoice in purchase.invoices:
|
||||
if invoice not in domain_invoices or invoice in skip:
|
||||
continue
|
||||
if invoice in to_recreate:
|
||||
for invoice in self.ask.domain_invoices:
|
||||
if invoice in self.ask.recreate_invoices:
|
||||
invoices_recreated.append(invoice.id)
|
||||
else:
|
||||
invoices_ignored.append(invoice.id)
|
||||
|
||||
Reference in New Issue
Block a user