From 5dad570423204c817f61d58b6d56bd376362e1b9 Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Wed, 28 Aug 2019 08:33:54 +0000 Subject: [PATCH] [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 partial merge of #36164 without the inventory part as discussed. closes odoo/odoo#36729 X-forward: 4717ccfa Signed-off-by: Martin Trigaux (mat) --- addons/account/models/account.py | 6 +++--- addons/account/views/report_payment_receipt_templates.xml | 2 +- addons/event/models/event.py | 2 +- addons/event_sale/models/event.py | 2 +- addons/mail/models/mail_alias.py | 2 +- addons/mail/models/mail_message.py | 2 +- addons/mail_bot/models/mail_bot.py | 2 +- addons/mail_bot/models/mail_channel.py | 2 +- addons/sale/models/sale.py | 2 +- addons/website_google_map/controllers/main.py | 2 +- doc/reference/reports.rst | 2 +- odoo/addons/base/tests/test_ir_sequence_date_range.py | 2 +- 12 files changed, 14 insertions(+), 14 deletions(-) diff --git a/addons/account/models/account.py b/addons/account/models/account.py index fff0313c555..b2f7eb426c8 100644 --- a/addons/account/models/account.py +++ b/addons/account/models/account.py @@ -279,13 +279,13 @@ class AccountAccount(models.Model): if opening_move_line: if amount: # modify the line - setattr(opening_move_line.with_context({'check_move_validity': False}), field, amount) + opening_move_line.with_context(check_move_validity=False)[field] = amount elif counter_part_map[field]: # delete the line (no need to keep a line with value = 0) - opening_move_line.with_context({'check_move_validity': False}).unlink() + opening_move_line.with_context(check_move_validity=False).unlink() elif amount: # create a new line, as none existed before - self.env['account.move.line'].with_context({'check_move_validity': False}).create({ + self.env['account.move.line'].with_context(check_move_validity=False).create({ 'name': _('Opening balance'), field: amount, 'move_id': opening_move.id, diff --git a/addons/account/views/report_payment_receipt_templates.xml b/addons/account/views/report_payment_receipt_templates.xml index c0e11a2ef7f..dce0a198571 100644 --- a/addons/account/views/report_payment_receipt_templates.xml +++ b/addons/account/views/report_payment_receipt_templates.xml @@ -2,7 +2,7 @@