[FIX] *: remove buggy calls to with_context

When .with_context() is called with a dictionary as 1st positional
argument, it will replace context (and not modify the referenced keys)
It may create bugs when losing the content of the context (e.g. remove
partner's language)

This is a cherry-pick to saas-12.5 of odoo/odoo#36164 of the logistic
part as discussed

closes odoo/odoo#36690

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
This commit is contained in:
Jairo Llopis
2019-09-11 11:17:50 +00:00
committed by Martin Trigaux
parent f2b4d98871
commit eebb8e1484
6 changed files with 15 additions and 15 deletions
@@ -47,10 +47,10 @@ class PurchaseOrder(models.Model):
order_lines = []
for line in requisition.line_ids:
# Compute name
product_lang = line.product_id.with_context({
'lang': partner.lang,
'partner_id': partner.id,
})
product_lang = line.product_id.with_context(
lang=partner.lang,
partner_id=partner.id
)
name = product_lang.display_name
if product_lang.description_purchase:
name += '\n' + product_lang.description_purchase
+4 -4
View File
@@ -221,10 +221,10 @@ class StockRule(models.Model):
price_unit = seller.currency_id._convert(
price_unit, po.currency_id, po.company_id, po.date_order or fields.Date.today())
product_lang = product_id.with_context({
'lang': partner.lang,
'partner_id': partner.id,
})
product_lang = product_id.with_context(
lang=partner.lang,
partner_id=partner.id,
)
name = product_lang.display_name
if product_lang.description_purchase:
name += '\n' + product_lang.description_purchase
+4 -4
View File
@@ -225,10 +225,10 @@ class SaleOrderLine(models.Model):
price_unit = supplierinfo.currency_id.compute(price_unit, purchase_order.currency_id)
# purchase line description in supplier lang
product_in_supplier_lang = self.product_id.with_context({
'lang': supplierinfo.name.lang,
'partner_id': supplierinfo.name.id,
})
product_in_supplier_lang = self.product_id.with_context(
lang=supplierinfo.name.lang,
partner_id=supplierinfo.name.id,
)
name = '[%s] %s' % (self.product_id.default_code, product_in_supplier_lang.display_name)
if product_in_supplier_lang.description_purchase:
name += '\n' + product_in_supplier_lang.description_purchase
+1 -1
View File
@@ -507,7 +507,7 @@ class Product(models.Model):
return self.env['stock.quant'].with_context(ctx)._get_quants_action(domain)
def action_update_quantity_on_hand(self):
return self.product_tmpl_id.with_context({'default_product_id': self.id}).action_update_quantity_on_hand()
return self.product_tmpl_id.with_context(default_product_id=self.id).action_update_quantity_on_hand()
def action_product_forecast_report(self):
action = self.env.ref('stock.report_stock_quantity_action_product').read()[0]
+1 -1
View File
@@ -118,7 +118,7 @@ class Location(models.Model):
raise UserError(_('You still have some product in locations %s') %
(','.join(children_quants.mapped('location_id.name'))))
else:
super(Location, children_location - self).with_context({'do_not_check_quant': True}).write(values)
super(Location, children_location - self).with_context(do_not_check_quant=True).write(values)
return super(Location, self).write(values)
@api.model
@@ -22,7 +22,7 @@ class StockBackorderConfirmation(models.TransientModel):
precision_rounding=move.product_uom.rounding) > 0:
moves_to_log[move] = (move.quantity_done, move.product_uom_qty)
pick_id._log_less_quantities_than_expected(moves_to_log)
confirmation.pick_ids.with_context({'cancel_backorder': cancel_backorder}).action_done()
confirmation.pick_ids.with_context(cancel_backorder=cancel_backorder).action_done()
def process(self):
self._process()