diff options
| author | Nasreddin (bon) <bon@odoo.com> | 2020-07-02 12:05:20 +0000 |
|---|---|---|
| committer | Nasreddin (bon) <bon@odoo.com> | 2020-07-03 15:12:56 +0000 |
| commit | cc0713dc5adf8348b1f79625aa93a47ed6c64e74 (patch) | |
| tree | c08b42f31ce142b8dfd94667362df0dc71bea3bd /addons | |
| parent | 9d7f3be8b3449d2809f6742b358e9da5bef53797 (diff) | |
[FIX] stock: Display translated picking description in delivery slip
Issue
- Install English and French languages
- Create a customer contact and assign french as his language
- Create a product with correct names in both languages.
For example 'French product name' and 'English product name' for easy reference.
- Create an inventory transfer with the french customer as contact
- Add the product that you created
- Print > Delivery Slip
The report will show in the lines:
"""
French product name
English product name
"""
Cause
Getting product description without checking partner language.
Solution
If partner is set, get product description with partner language in context.
opw-2280490
closes odoo/odoo#54061
X-original-commit: cebe2cf57e68e2d1d54cd442aff6ba7d9554d043
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
Signed-off-by: bon-odoo <nboulif@users.noreply.github.com>
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/purchase_stock/models/purchase.py | 3 | ||||
| -rw-r--r-- | addons/stock/models/stock_move.py | 3 | ||||
| -rw-r--r-- | addons/stock/models/stock_move_line.py | 3 | ||||
| -rw-r--r-- | addons/stock/models/stock_rule.py | 5 |
4 files changed, 10 insertions, 4 deletions
diff --git a/addons/purchase_stock/models/purchase.py b/addons/purchase_stock/models/purchase.py index aad035d5b55..d174413910e 100644 --- a/addons/purchase_stock/models/purchase.py +++ b/addons/purchase_stock/models/purchase.py @@ -450,7 +450,8 @@ class PurchaseOrderLine(models.Model): def _prepare_stock_move_vals(self, picking, price_unit, product_uom_qty, product_uom): self.ensure_one() - description_picking = self.product_id._get_description(self.order_id.picking_type_id) + product = self.product_id.with_context(lang=self.order_id.dest_address_id.lang or self.env.user.lang) + description_picking = product._get_description(self.order_id.picking_type_id) if self.product_description_variants: description_picking += self.product_description_variants return { diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index b196ec1adc2..bbae48b0d8b 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -182,7 +182,8 @@ class StockMove(models.Model): @api.onchange('product_id', 'picking_type_id') def onchange_product(self): if self.product_id: - self.description_picking = self.product_id._get_description(self.picking_type_id) + product = self.product_id.with_context(lang=self.picking_id.partner_id.lang or self.env.user.lang) + self.description_picking = product._get_description(self.picking_type_id) @api.depends('has_tracking', 'picking_type_id.use_create_lots', 'picking_type_id.use_existing_lots', 'state') def _compute_display_assign_serial(self): diff --git a/addons/stock/models/stock_move_line.py b/addons/stock/models/stock_move_line.py index 6204341b12e..068142958b5 100644 --- a/addons/stock/models/stock_move_line.py +++ b/addons/stock/models/stock_move_line.py @@ -116,7 +116,8 @@ class StockMoveLine(models.Model): if not self.id and self.user_has_groups('stock.group_stock_multi_locations'): self.location_dest_id = self.location_dest_id._get_putaway_strategy(self.product_id) or self.location_dest_id if self.picking_id: - self.description_picking = self.product_id._get_description(self.picking_id.picking_type_id) + product = self.product_id.with_context(lang=self.picking_id.partner_id.lang or self.env.user.lang) + self.description_picking = product._get_description(self.picking_id.picking_type_id) self.lots_visible = self.product_id.tracking != 'none' if not self.product_uom_id or self.product_uom_id.category_id != self.product_id.uom_id.category_id: if self.move_id.product_uom: diff --git a/addons/stock/models/stock_rule.py b/addons/stock/models/stock_rule.py index 3f03a224947..a400738f8b3 100644 --- a/addons/stock/models/stock_rule.py +++ b/addons/stock/models/stock_rule.py @@ -283,6 +283,9 @@ class StockRule(models.Model): date_expected = fields.Datetime.to_string( fields.Datetime.from_string(values['date_planned']) - relativedelta(days=self.delay or 0) ) + partner = self.partner_address_id or (values.get('group_id', False) and values['group_id'].partner_id) + if partner: + product_id = product_id.with_context(lang=partner.lang or self.env.user.lang) picking_description = product_id._get_description(self.picking_type_id) if values.get('product_description_variants'): picking_description += values['product_description_variants'] @@ -300,7 +303,7 @@ class StockRule(models.Model): 'product_id': product_id.id, 'product_uom': product_uom.id, 'product_uom_qty': qty_left, - 'partner_id': self.partner_address_id.id or (values.get('group_id', False) and values['group_id'].partner_id.id) or False, + 'partner_id': partner.id if partner else False, 'location_id': self.location_src_id.id, 'location_dest_id': location_id.id, 'move_dest_ids': move_dest_ids, |
