details: https://code.tryton.org/tryton/commit/4a431db124b4
branch: default
user: Cédric Krier <[email protected]>
date: Tue Jan 06 17:41:05 2026 +0100
description:
Add supplier and customer code properties to invoice line
diffstat:
modules/account_invoice/invoice.py | 16 ++++++++++++++++
modules/purchase/invoice.py | 11 +++++++++++
modules/sale_product_customer/account.py | 11 +++++++++++
3 files changed, 38 insertions(+), 0 deletions(-)
diffs (65 lines):
diff -r 79fc43326a34 -r 4a431db124b4 modules/account_invoice/invoice.py
--- a/modules/account_invoice/invoice.py Tue Jan 06 11:38:37 2026 +0100
+++ b/modules/account_invoice/invoice.py Tue Jan 06 17:41:05 2026 +0100
@@ -2860,6 +2860,22 @@
def product_name(self):
return self.product.rec_name if self.product else ''
+ @cached_property
+ def product_supplier_code(self):
+ code = ''
+ if self.invoice.type == 'out':
+ if self.product:
+ code = self.product.code
+ return code
+
+ @cached_property
+ def product_customer_code(self):
+ code = ''
+ if self.invoice.type == 'in':
+ if self.product:
+ code = self.product.code
+ return code
+
@fields.depends('product')
def on_change_with_product_uom_category(self, name=None):
return self.product.default_uom_category if self.product else None
diff -r 79fc43326a34 -r 4a431db124b4 modules/purchase/invoice.py
--- a/modules/purchase/invoice.py Tue Jan 06 11:38:37 2026 +0100
+++ b/modules/purchase/invoice.py Tue Jan 06 17:41:05 2026 +0100
@@ -122,6 +122,17 @@
name = self.origin.product_supplier.rec_name
return name
+ @cached_property
+ def product_supplier_code(self):
+ pool = Pool()
+ PurchaseLine = pool.get('purchase.line')
+ code = super().product_supplier_code
+ if (self.invoice.type == 'in'
+ and isinstance(self.origin, PurchaseLine)
+ and self.origin.product_supplier):
+ code = self.origin.product_supplier.code
+ return code
+
@fields.depends('origin')
def on_change_with_product_uom_category(self, name=None):
pool = Pool()
diff -r 79fc43326a34 -r 4a431db124b4 modules/sale_product_customer/account.py
--- a/modules/sale_product_customer/account.py Tue Jan 06 11:38:37 2026 +0100
+++ b/modules/sale_product_customer/account.py Tue Jan 06 17:41:05 2026 +0100
@@ -17,3 +17,14 @@
and self.origin.product_customer):
name = self.origin.product_customer.rec_name
return name
+
+ @cached_property
+ def product_customer_code(self):
+ pool = Pool()
+ SaleLine = pool.get('sale.line')
+ code = super().product_customer_code
+ if (self.invoice.type == 'out'
+ and isinstance(self.origin, SaleLine)
+ and self.origin.product_customer):
+ code = self.origin.product_customer.code
+ return code