From f2f77b0b4a52aeb360fb290455dbc1eadaf4767e Mon Sep 17 00:00:00 2001 From: niyasraphy Date: Sat, 19 Aug 2023 07:55:04 +0000 Subject: [PATCH] [FIX] pos_online_payment: translatable warning message before this commit, the added user error and validation error is not translatable to end user language. after this commit, user error and validation error will be show in users language closes odoo/odoo#132637 X-original-commit: e2e580a0b83356dc32bc31bafaf1a3d03b47e266 Signed-off-by: Joseph Caburnay (jcb) --- addons/pos_online_payment/models/pos_payment.py | 10 +++++----- addons/pos_online_payment/models/pos_payment_method.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/pos_online_payment/models/pos_payment.py b/addons/pos_online_payment/models/pos_payment.py index 230c520a939..fac04eb99e3 100644 --- a/addons/pos_online_payment/models/pos_payment.py +++ b/addons/pos_online_payment/models/pos_payment.py @@ -2,7 +2,7 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. import logging -from odoo import api, fields, models +from odoo import api, fields, models, _ from odoo.exceptions import UserError _logger = logging.getLogger(__name__) @@ -29,22 +29,22 @@ class PosPayment(models.Model): for pm_id, oaps_id in online_account_payments_by_pm.items(): if pm_id in opms_id: if None in oaps_id: - raise UserError("Cannot create a POS online payment without an accounting payment.") + raise UserError(_("Cannot create a POS online payment without an accounting payment.")) else: online_account_payments_to_check_id.update(oaps_id) elif any(oaps_id): - raise UserError("Cannot create a POS payment with a not online payment method and an online accounting payment.") + raise UserError(_("Cannot create a POS payment with a not online payment method and an online accounting payment.")) if online_account_payments_to_check_id: valid_oap_amount = self.env['account.payment'].search_count([('id', 'in', list(online_account_payments_to_check_id))]) if valid_oap_amount != len(online_account_payments_to_check_id): - raise UserError("Cannot create a POS online payment without an accounting payment.") + raise UserError(_("Cannot create a POS online payment without an accounting payment.")) return super().create(vals_list) def write(self, vals): if vals.keys() & ('amount', 'payment_date', 'payment_method_id', 'online_account_payment_id', 'pos_order_id') and any(payment.online_account_payment_id or payment.payment_method_id.is_online_payment for payment in self): - raise UserError("Cannot edit a POS online payment essential data.") + raise UserError(_("Cannot edit a POS online payment essential data.")) return super().write(vals) @api.constrains('payment_method_id') diff --git a/addons/pos_online_payment/models/pos_payment_method.py b/addons/pos_online_payment/models/pos_payment_method.py index cd8841b902e..4db975fae16 100644 --- a/addons/pos_online_payment/models/pos_payment_method.py +++ b/addons/pos_online_payment/models/pos_payment_method.py @@ -114,5 +114,5 @@ class PosPaymentMethod(models.Model): 'company_id': company_id, }) if not payment_method_id: - raise ValidationError('Could not create an online payment method (company_id=%d, pos_config_id=%d)' % (company_id, pos_config_id)) + raise ValidationError(_('Could not create an online payment method (company_id=%d, pos_config_id=%d)', company_id, pos_config_id)) return payment_method_id