diff --git a/modules/purchase/stock.py b/modules/purchase/stock.py index 3b6652bea3..4aecefdb81 100644 --- a/modules/purchase/stock.py +++ b/modules/purchase/stock.py @@ -7,6 +7,7 @@ from trytond.model import ModelView, Workflow, fields from trytond.model.exceptions import AccessError from trytond.pool import Pool, PoolMeta from trytond.pyson import Eval +from trytond.tools import cached_property from trytond.transaction import Transaction, without_check_access @@ -186,6 +187,16 @@ class Move(metaclass=PoolMeta): if isinstance(self.origin, PurchaseLine): return self.origin.purchase.party.id + @cached_property + def product_name(self): + pool = Pool() + PurchaseLine = pool.get('purchase.line') + name = super().product_name + if (isinstance(self.origin, PurchaseLine) + and self.origin.product_supplier): + name = self.origin.product_supplier.rec_name + return name + @fields.depends('origin') def on_change_with_product_uom_category(self, name=None): pool = Pool() diff --git a/modules/sale_product_customer/__init__.py b/modules/sale_product_customer/__init__.py index 40cd0dc71d..3f41c4126d 100644 --- a/modules/sale_product_customer/__init__.py +++ b/modules/sale_product_customer/__init__.py @@ -3,7 +3,7 @@ from trytond.pool import Pool -from . import account, product, sale +from . import account, product, sale, stock __all__ = ['register'] @@ -15,6 +15,7 @@ def register(): product.ProductCustomer, sale.Line, account.InvoiceLine, + stock.Move, module='sale_product_customer', type_='model') Pool.register( sale.AmendmentLine, diff --git a/modules/sale_product_customer/stock.py b/modules/sale_product_customer/stock.py new file mode 100644 index 0000000000..c138e49935 --- /dev/null +++ b/modules/sale_product_customer/stock.py @@ -0,0 +1,19 @@ +# This file is part of Tryton. The COPYRIGHT file at the top level of +# this repository contains the full copyright notices and license terms. + +from trytond.pool import Pool, PoolMeta +from trytond.tools import cached_property + + +class Move(metaclass=PoolMeta): + __name__ = 'stock.move' + + @cached_property + def product_name(self): + pool = Pool() + SaleLine = pool.get('sale.line') + name = super().product_name + if (isinstance(self.origin, SaleLine) + and self.origin.product_customer): + name = self.origin.product_customer.rec_name + return name diff --git a/modules/sale_product_customer/tryton.cfg b/modules/sale_product_customer/tryton.cfg index 80410e67ef..39bf9fd694 100644 --- a/modules/sale_product_customer/tryton.cfg +++ b/modules/sale_product_customer/tryton.cfg @@ -5,6 +5,7 @@ depends: ir product sale + stock extras_depend: sale_amendment sale_blanket_agreement diff --git a/modules/stock/delivery_note.fodt b/modules/stock/delivery_note.fodt index c6c1552e3e..c0d57e9c2c 100644 --- a/modules/stock/delivery_note.fodt +++ b/modules/stock/delivery_note.fodt @@ -520,7 +520,7 @@ - <move.product.rec_name> + <move.product_name> <format_number_symbol(move.quantity, shipment.delivery_address.party.lang, move.unit, digits=move.unit.digits)> diff --git a/modules/stock/move.py b/modules/stock/move.py index 1a43575b72..4c1ca6b3ee 100644 --- a/modules/stock/move.py +++ b/modules/stock/move.py @@ -19,7 +19,7 @@ from trytond.model.exceptions import AccessError from trytond.modules.product import price_digits, round_price from trytond.pool import Pool from trytond.pyson import Bool, Eval, If, TimeDelta -from trytond.tools import grouped_slice, reduce_ids +from trytond.tools import cached_property, grouped_slice, reduce_ids from trytond.transaction import Transaction, without_check_access from .exceptions import MoveFutureWarning, MoveOriginWarning @@ -471,6 +471,10 @@ class Move(Workflow, ModelSQL, ModelView): or self.unit.category != default_uom.category): self.unit = default_uom + @cached_property + def product_name(self): + return self.product.rec_name if self.product else '' + @fields.depends('product') def on_change_with_product_uom_category(self, name=None): return self.product.default_uom_category if self.product else None