[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
This commit is contained in:
Nicolas Martinelli
2017-05-02 16:20:50 +02:00
parent be1ca7b100
commit 279b3a8ac1
2 changed files with 8 additions and 0 deletions
@@ -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"
@@ -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