From 279b3a8ac1bbdc51003ccfd9c1d426665b9de753 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Tue, 2 May 2017 11:47:24 +0200 Subject: [PATCH] [FIX] account_tax_cash_basis: raise if no account Since the account is a mandatory field, we raise an clear error is no account is defined. This is necessary when running an automatic reconciliation on the POS. The POS uses a try/except to avoid any error, but in the case of an SQL error, the cursor is invalidated, so the transaction fails. opw-741677 --- .../account_tax_cash_basis/i18n/account_tax_cash_basis.pot | 6 ++++++ .../models/account_partial_reconcile.py | 2 ++ 2 files changed, 8 insertions(+) diff --git a/addons/account_tax_cash_basis/i18n/account_tax_cash_basis.pot b/addons/account_tax_cash_basis/i18n/account_tax_cash_basis.pot index 1739ba3f241..f3ccca6c7cf 100644 --- a/addons/account_tax_cash_basis/i18n/account_tax_cash_basis.pot +++ b/addons/account_tax_cash_basis/i18n/account_tax_cash_basis.pot @@ -40,6 +40,12 @@ msgstr "" msgid "Partial Reconcile" msgstr "" +#. module: account_tax_cash_basis +#: code:addons/account_tax_cash_basis/models/account_partial_reconcile.py:39 +#, python-format +msgid "Please configure a Tax Received Account for tax %s" +msgstr "" + #. module: account_tax_cash_basis #: model:ir.model.fields,help:account_tax_cash_basis.field_account_tax_use_cash_basis msgid "Select this if the tax should use cash basis,which will create an entry for this tax on a given account during reconciliation" diff --git a/addons/account_tax_cash_basis/models/account_partial_reconcile.py b/addons/account_tax_cash_basis/models/account_partial_reconcile.py index 3bbea4a8140..a95e355b68f 100644 --- a/addons/account_tax_cash_basis/models/account_partial_reconcile.py +++ b/addons/account_tax_cash_basis/models/account_partial_reconcile.py @@ -35,6 +35,8 @@ class AccountPartialReconcileCashBasis(models.Model): tax_group[acc] = amount # Group by cash basis account and tax acc = line.tax_line_id.cash_basis_account.id + if not acc: + raise UserError(_('Please configure a Tax Received Account for tax %s') % line.tax_line_id.name) key = (acc, line.tax_line_id.id) if key in total_by_cash_basis_account: total_by_cash_basis_account[key] += amount