diff --git a/modules/account_invoice/invoice.py b/modules/account_invoice/invoice.py index 4d6e7989e1..082d654228 100644 --- a/modules/account_invoice/invoice.py +++ b/modules/account_invoice/invoice.py @@ -1926,6 +1926,18 @@ class InvoiceLine(sequence_ordered(), ModelSQL, ModelView, TaxableMixin): 'invisible': Bool(Eval('context', {}).get('standalone')), 'readonly': _states['readonly'] & Bool(Eval('invoice')), }) + invoice_party = fields.Function( + fields.Many2One( + 'party.party', "Party", + context={ + 'company': Eval('company', -1), + }, + depends=['company']), + 'on_change_with_invoice_party', searcher='search_invoice_party') + invoice_description = fields.Function( + fields.Char("Invoice Description"), + 'on_change_with_invoice_description', + searcher='search_invoice_description') invoice_state = fields.Function( fields.Selection('get_invoice_states', "Invoice State"), 'on_change_with_invoice_state') @@ -2180,6 +2192,30 @@ class InvoiceLine(sequence_ordered(), ModelSQL, ModelView, TaxableMixin): def default_type(): return 'line' + @fields.depends('party', 'invoice', '_parent_invoice.party') + def on_change_with_invoice_party(self, name=None): + if self.invoice and self.invoice.party: + return self.invoice.party.id + elif self.party: + return self.party.id + + @classmethod + def search_invoice_party(cls, name, clause): + nested = clause[0][len(name) + 1:] + return ['OR', + ('invoice.party' + nested, *clause[1:]), + ('party' + nested, *clause[1:]), + ] + + @fields.depends('invoice', '_parent_invoice.description') + def on_change_with_invoice_description(self, name=None): + if self.invoice: + return self.invoice.description + + @classmethod + def search_invoice_description(cls, name, clause): + return [('invoice.description', *clause[1:])] + @classmethod def default_invoice_state(cls): return 'draft' diff --git a/modules/account_invoice/view/invoice_line_tree.xml b/modules/account_invoice/view/invoice_line_tree.xml index 2132851edc..4fce0774c3 100644 --- a/modules/account_invoice/view/invoice_line_tree.xml +++ b/modules/account_invoice/view/invoice_line_tree.xml @@ -3,12 +3,14 @@ this repository contains the full copyright notices and license terms. --> + - + - - + + +