Skip to content
Snippets Groups Projects
Commit 90de1797 authored by Nshimiyimana Séna's avatar Nshimiyimana Séna
Browse files

[FIX] l10n_de: allow tax other than account's default on line


Steps to reproduce
------------------
* install l10n_de
* switch to a german company
* create an invoice
* add a line such that the account's default tax is different from the
  tax set on the line (ex, account: `8400 Erlöse 19% USt` and
  tax: `7% Umsatzsteuer`)

Attempt to confirm the invoice, you should see that you can't. The
system requires the account's default tax to be the same as the tax set
on the line. This should not be the case. It's a practice in Germany to
link a tax to an account like this, but it's not a legal requirement.

opw-3324323

closes odoo/odoo#127238

Signed-off-by: default avatarHabib Ayob (ayh) <ayh@odoo.com>
parent a98a8f54
No related branches found
No related tags found
No related merge requests found
from odoo import api, fields, models
from odoo.exceptions import UserError
from odoo.tools.translate import _
from odoo import fields, models
class AccountTaxTemplate(models.Model):
_inherit = 'account.tax.template'
......@@ -18,23 +16,6 @@ class AccountTax(models.Model):
l10n_de_datev_code = fields.Char(size=4, help="4 digits code use by Datev")
class AccountMove(models.Model):
_inherit = 'account.move'
def _post(self, soft=True):
# OVERRIDE to check the invoice lines taxes.
for invoice in self.filtered(lambda move: move.is_invoice()):
for line in invoice.invoice_line_ids:
account_tax = line.account_id.tax_ids.ids
if account_tax and invoice.company_id.country_id.code == 'DE':
account_name = line.account_id.name
for tax in line.tax_ids:
if tax.id not in account_tax:
raise UserError(_('Account %s does not authorize to have tax %s specified on the line. \
Change the tax used in this invoice or remove all taxes from the account') % (account_name, tax.name))
return super()._post(soft)
class ProductTemplate(models.Model):
_inherit = "product.template"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment