diff --git a/__init__.py b/__init__.py index ebac693bb8..f8a5cb4ff1 100644 --- a/__init__.py +++ b/__init__.py @@ -4,6 +4,7 @@ from trytond.pool import Pool from .complaint import * from .sale import * +from .account import * def register(): @@ -15,4 +16,5 @@ def register(): Action_InvoiceLine, Configuration, Sale, + InvoiceLine, module='sale_complaint', type_='model') diff --git a/account.py b/account.py new file mode 100644 index 0000000000..b281b2c797 --- /dev/null +++ b/account.py @@ -0,0 +1,16 @@ +# 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 __future__ import unicode_literals + +from trytond.pool import PoolMeta + +__all__ = ['InvoiceLine'] + + +class InvoiceLine: + __name__ = 'account.invoice.line' + __metaclass__ = PoolMeta + + @classmethod + def _get_origin(cls): + return super(InvoiceLine, cls)._get_origin() + ['sale.complaint'] diff --git a/complaint.py b/complaint.py index 4f3ed8612b..deaca12cae 100644 --- a/complaint.py +++ b/complaint.py @@ -427,9 +427,11 @@ class Action(ModelSQL, ModelView): values = invoice._credit() lines_values = [] for invoice_line in invoice_lines: - lines_values.append(invoice_line._credit()) + credit_line = invoice_line._credit() + lines_values.append(credit_line) # Remove product as it is not a return - lines_values[0].pop('product', None) + credit_line.pop('product', None) + credit_line['origin'] = str(self.complaint) if isinstance(self.complaint.origin, Line): if self.quantity is not None: lines_values[0]['quantity'] = self.quantity