[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#131779

X-original-commit: 4de4a099296be150a8e75ffdbf1321cdee75137c
Signed-off-by: Séna Serge Nshimiyimana (sesn) <sesn@odoo.com>
Signed-off-by: Habib Ayob (ayh) <ayh@odoo.com>
This commit is contained in:
Nshimiyimana Séna
2023-08-13 19:42:12 +02:00
parent c025531f06
commit 00f174fb26
+1 -20
View File
@@ -1,6 +1,4 @@
from odoo import api, fields, models
from odoo.exceptions import UserError
from odoo.tools.translate import _
from odoo import fields, models
class AccountTax(models.Model):
@@ -9,23 +7,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.account_fiscal_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"