Use list instead of dictionary to store invoice lines
A list is less expensive than a dictionary. issue6037 review29021002
This commit is contained in:
1 parent
727c472512
commit
0b97f06cff
1 file changed
+6
-7
+6
-7
@@ -682,18 +682,17 @@ class Purchase(Workflow, ModelSQL, ModelView, TaxableMixin):
|
||||
self.raise_user_error('missing_account_payable',
|
||||
error_args=(self.party.rec_name,))
|
||||
|
||||
invoice_lines = {}
|
||||
invoice_lines = []
|
||||
for line in self.lines:
|
||||
ilines = line.get_invoice_line()
|
||||
if ilines:
|
||||
invoice_lines[line.id] = ilines
|
||||
invoice_lines.append(line.get_invoice_line())
|
||||
invoice_lines = list(chain(*invoice_lines))
|
||||
if not invoice_lines:
|
||||
return
|
||||
|
||||
invoice = self._get_invoice_purchase()
|
||||
invoice.lines = list(chain.from_iterable(
|
||||
invoice_lines[l.id] for l in self.lines
|
||||
if l.id in invoice_lines))
|
||||
if getattr(invoice, 'lines', None):
|
||||
invoice_lines = list(invoice.lines) + invoice_lines
|
||||
invoice.lines = invoice_lines
|
||||
invoice.save()
|
||||
|
||||
Invoice.update_taxes([invoice])
|
||||
|
||||
Reference in new issue
Block a user