diff --git a/stock_ux/models/res_config_settings.py b/stock_ux/models/res_config_settings.py index 29d14cc79..6145c4730 100644 --- a/stock_ux/models/res_config_settings.py +++ b/stock_ux/models/res_config_settings.py @@ -19,6 +19,11 @@ class ResConfigSettings(models.TransientModel): config_parameter="stock_ux.delivery_slip_use_origin", ) + delivery_slip_add_product_name = fields.Boolean( + "Agregar el nombre del producto a la descripción de origen", + config_parameter="stock_ux.delivery_slip_add_product_name", + ) + delivery_slip_remaining_qty = fields.Boolean( "En Comprobantes de Transferencia mostrar cantidades pendientes de entrega", config_parameter="stock_ux.delivery_slip_remaining_qty", diff --git a/stock_ux/models/stock_move_line.py b/stock_ux/models/stock_move_line.py index cd5793868..7756f519a 100644 --- a/stock_ux/models/stock_move_line.py +++ b/stock_ux/models/stock_move_line.py @@ -151,6 +151,11 @@ def _get_aggregated_properties(self, move_line=False, move=False): origin_description = move.origin_description or reference product = move.product_id + add_product_name = ( + self.env["ir.config_parameter"].sudo().get_param("stock_ux.delivery_slip_add_product_name", "False") + == "True" + ) + # Clean the origin_description by removing product name prefix clean_description = origin_description if origin_description != reference: @@ -159,7 +164,10 @@ def _get_aggregated_properties(self, move_line=False, move=False): elif origin_description.startswith(product.name): clean_description = origin_description.removeprefix(product.name).strip() - name = clean_description if clean_description else origin_description + if add_product_name and clean_description and clean_description != origin_description: + name = f"{product.name} {'-'} {clean_description}" + else: + name = clean_description if clean_description else origin_description line_key = f"{product.id}_{name}_{uom.id}_{move.packaging_uom_id or ''}" bom_line = getattr(move, "bom_line_id", False) if bom_line and bom_line.bom_id: diff --git a/stock_ux/views/res_config_settings_views.xml b/stock_ux/views/res_config_settings_views.xml index 1837d1e45..31d17fd97 100644 --- a/stock_ux/views/res_config_settings_views.xml +++ b/stock_ux/views/res_config_settings_views.xml @@ -32,6 +32,12 @@