Skip to content
Snippets Groups Projects
Commit fee4e78a authored by Nasreddin (bon)'s avatar Nasreddin (bon)
Browse files

[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#53977

Signed-off-by: default avatarNicolas Martinelli (nim) <nim@odoo.com>
parent 1bb39749
No related branches found
No related tags found
No related merge requests found
......@@ -371,6 +371,7 @@ class PurchaseOrderLine(models.Model):
qty -= move.product_uom._compute_quantity(move.product_uom_qty, self.product_uom, rounding_method='HALF-UP')
for move in incoming_moves:
qty += move.product_uom._compute_quantity(move.product_uom_qty, self.product_uom, rounding_method='HALF-UP')
description_picking = self.product_id.with_context(lang=self.order_id.dest_address_id.lang or self.env.user.lang)._get_description(self.order_id.picking_type_id)
template = {
# truncate to 2000 to avoid triggering index limit error
# TODO: remove index in master?
......@@ -393,7 +394,7 @@ class PurchaseOrderLine(models.Model):
'origin': self.order_id.name,
'propagate_date': self.propagate_date,
'propagate_date_minimum_delta': self.propagate_date_minimum_delta,
'description_picking': self.product_id._get_description(self.order_id.picking_type_id),
'description_picking': description_picking,
'propagate_cancel': self.propagate_cancel,
'route_ids': self.order_id.picking_type_id.warehouse_id and [(6, 0, [x.id for x in self.order_id.picking_type_id.warehouse_id.route_ids])] or [],
'warehouse_id': self.order_id.picking_type_id.warehouse_id.id,
......
......@@ -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):
......
......@@ -106,7 +106,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:
......
......@@ -262,6 +262,11 @@ 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)
# it is possible that we've already got some move done, so check for the done qty and create
# a new move with the correct qty
qty_left = product_qty
......@@ -271,7 +276,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': values.get('move_dest_ids', False) and [(4, x.id) for x in values['move_dest_ids']] or [],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment