[FIX] point_of_sale: check payment methods intermediary accounts is set
This is normally not supposed to happen to have a payment method without a receivable account set, as this is a required field. However, it happens the receivable account cannot be found during upgrades and this is a bommer to block the upgrade for that point, given the user can correct this by himself, without requiring a manual intervention from our upgrade support. However, this must be ensured this receivable is well set before opening a POS session. closes odoo/odoo#52862 X-original-commit: 88cad346445f21d1513c066e965fc7df59582a56 Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
This commit is contained in:
@@ -5236,6 +5236,13 @@ msgid ""
|
||||
"Orders that where not synced before will be synced next time you close an order while connected to the internet or when you close the session."
|
||||
msgstr ""
|
||||
|
||||
#. module: point_of_sale
|
||||
#: code:addons/point_of_sale/models/pos_config.py:0
|
||||
#, python-format
|
||||
msgid ""
|
||||
"You must configure an intermediary account for the payment methods: %s."
|
||||
msgstr ""
|
||||
|
||||
#. module: point_of_sale
|
||||
#: model_terms:ir.actions.act_window,help:point_of_sale.product_product_action
|
||||
msgid ""
|
||||
|
||||
@@ -356,6 +356,20 @@ class PosConfig(models.Model):
|
||||
):
|
||||
raise ValidationError(_("All payment methods must be in the same currency as the Sales Journal or the company currency if that is not set."))
|
||||
|
||||
@api.constrains('payment_method_ids')
|
||||
def _check_payment_method_receivable_accounts(self):
|
||||
# This is normally not supposed to happen to have a payment method without a receivable account set,
|
||||
# as this is a required field. However, it happens the receivable account cannot be found during upgrades
|
||||
# and this is a bommer to block the upgrade for that point, given the user can correct this by himself,
|
||||
# without requiring a manual intervention from our upgrade support.
|
||||
# However, this must be ensured this receivable is well set before opening a POS session.
|
||||
invalid_payment_methods = self.payment_method_ids.filtered(lambda method: not method.receivable_account_id)
|
||||
if invalid_payment_methods:
|
||||
method_names = ", ".join(method.name for method in invalid_payment_methods)
|
||||
raise ValidationError(
|
||||
_("You must configure an intermediary account for the payment methods: %s.") % method_names
|
||||
)
|
||||
|
||||
@api.constrains('company_id', 'available_pricelist_ids')
|
||||
def _check_companies(self):
|
||||
if any(self.available_pricelist_ids.mapped(lambda pl: pl.company_id.id not in (False, self.company_id.id))):
|
||||
@@ -568,6 +582,7 @@ class PosConfig(models.Model):
|
||||
self._check_company_payment()
|
||||
self._check_currencies()
|
||||
self._check_profit_loss_cash_journal()
|
||||
self._check_payment_method_receivable_accounts()
|
||||
self.env['pos.session'].create({
|
||||
'user_id': self.env.uid,
|
||||
'config_id': self.id
|
||||
|
||||
Reference in New Issue
Block a user