details:   https://code.tryton.org/tryton/commit/e75c7ceb6871
branch:    default
user:      Cédric Krier <[email protected]>
date:      Mon Jan 19 12:15:30 2026 +0100
description:
        Add an origin invoices field to the invoice
diffstat:

 modules/account_invoice/CHANGELOG  |   1 +
 modules/account_invoice/invoice.py |  18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 0 deletions(-)

diffs (43 lines):

diff -r fa6de53a766e -r e75c7ceb6871 modules/account_invoice/CHANGELOG
--- a/modules/account_invoice/CHANGELOG Mon Jan 19 09:59:37 2026 +0100
+++ b/modules/account_invoice/CHANGELOG Mon Jan 19 12:15:30 2026 +0100
@@ -1,3 +1,4 @@
+* Add an origin invoices field to the invoice
 * Remove default invoice type
 
 Version 7.8.0 - 2025-12-15
diff -r fa6de53a766e -r e75c7ceb6871 modules/account_invoice/invoice.py
--- a/modules/account_invoice/invoice.py        Mon Jan 19 09:59:37 2026 +0100
+++ b/modules/account_invoice/invoice.py        Mon Jan 19 12:15:30 2026 +0100
@@ -305,6 +305,9 @@
                     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 @@
         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':

Reply via email to