Add an origin invoices field to the invoice

This commit is contained in:
Cédric Krier committed 2026-01-19 12:15:30 +01:00
1 parent 4808ff83ab
commit 4e3f4055ce
2 files changed
+19

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
* Add an origin invoices field to the invoice
* Remove default invoice type
Version 7.8.0 - 2025-12-15
+18
View File
@@ -305,6 +305,9 @@ class Invoice(
Eval('context', {}).get('groups', []))),
})
origins = fields.Function(fields.Char('Origins'), 'get_origins')
origin_invoices = fields.Function(fields.Many2Many(
'account.invoice', None, None, "Origin Invoices"),
'get_origin_invoices', searcher='search_origin_invoices')
untaxed_amount = fields.Function(Monetary(
"Untaxed", currency='currency', digits='currency'),
'get_amount', searcher='search_untaxed_amount')
@@ -1534,6 +1537,21 @@ class Invoice(
return ', '.join(set(filter(None,
(l.origin_name for l in self.line_lines))))
def get_origin_invoices(self, name):
pool = Pool()
InvoiceLine = pool.get('account.invoice.line')
invoices = set()
for line in self.lines:
if isinstance(line.origin, InvoiceLine):
invoices.add(line.origin.invoice.id)
invoices.discard(self.id)
return list(invoices)
@classmethod
def search_origin_invoices(cls, name, clause):
return [('lines.origin.invoice', clause[0][len(name):],
*clause[1:3], 'account.invoice.line', *clause[3:])]
def chat_language(self, audience='internal'):
language = super().chat_language(audience=audience)
if audience == 'public':