details:   https://code.tryton.org/tryton/commit/9a68fc0961be
branch:    default
user:      Cédric Krier <[email protected]>
date:      Fri Jan 23 18:50:42 2026 +0100
description:
        Search for similar invoice line with the same category of unit for UBL 
invoice line

        Closes #14548
diffstat:

 modules/edocument_ubl/edocument.py |  38 ++++++++++++++++++++++++--------------
 1 files changed, 24 insertions(+), 14 deletions(-)

diffs (55 lines):

diff -r 3134b59848ef -r 9a68fc0961be modules/edocument_ubl/edocument.py
--- a/modules/edocument_ubl/edocument.py        Fri Jan 23 15:29:07 2026 +0100
+++ b/modules/edocument_ubl/edocument.py        Fri Jan 23 18:50:42 2026 +0100
@@ -389,13 +389,18 @@
 
         if not line.product:
             if line.description:
-                similar_lines = Line.search([
-                        ('description', 'ilike', line.description),
-                        ('invoice.company', '=', company),
-                        ('invoice.type', '=', 'in'),
-                        ('invoice.state', 'in',
-                            ['validated', 'posted', 'paid']),
-                        ],
+                similar_domain = [
+                    ('description', 'ilike', line.description),
+                    ('invoice.company', '=', company),
+                    ('invoice.type', '=', 'in'),
+                    ('invoice.state', 'in',
+                        ['validated', 'posted', 'paid']),
+                    ]
+                if line.unit:
+                    similar_domain.append(
+                        ('unit.category', '=', line.unit.category))
+                similar_lines = Line.search(
+                    similar_domain,
                     order=[('invoice.invoice_date', 'DESC')],
                     limit=1)
             else:
@@ -565,13 +570,18 @@
 
         if not line.product:
             if line.description:
-                similar_lines = Line.search([
-                        ('description', 'ilike', line.description),
-                        ('invoice.company', '=', company),
-                        ('invoice.type', '=', 'in'),
-                        ('invoice.state', 'in',
-                            ['validated', 'posted', 'paid']),
-                        ],
+                similar_domain = [
+                    ('description', 'ilike', line.description),
+                    ('invoice.company', '=', company),
+                    ('invoice.type', '=', 'in'),
+                    ('invoice.state', 'in',
+                        ['validated', 'posted', 'paid']),
+                    ]
+                if line.unit:
+                    similar_domain.append(
+                        ('unit.category', '=', line.unit.category))
+                similar_lines = Line.search(
+                    similar_domain,
                     order=[('invoice.invoice_date', 'DESC')],
                     limit=1)
             else:

Reply via email to