summaryrefslogtreecommitdiff
path: root/addons/l10n_de
diff options
context:
space:
mode:
Diffstat (limited to 'addons/l10n_de')
-rw-r--r--addons/l10n_de/models/datev.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/addons/l10n_de/models/datev.py b/addons/l10n_de/models/datev.py
index 082729970aa..1578b09050f 100644
--- a/addons/l10n_de/models/datev.py
+++ b/addons/l10n_de/models/datev.py
@@ -1,4 +1,6 @@
-from odoo import fields, models
+from odoo import api, fields, models
+from odoo.exceptions import UserError
+from odoo.tools.translate import _
class AccountTaxTemplate(models.Model):
_inherit = 'account.tax.template'
@@ -14,3 +16,18 @@ class AccountTax(models.Model):
_inherit = "account.tax"
l10n_de_datev_code = fields.Char(size=2, help="2 digits code use by Datev")
+
+class AccountInvoice(models.Model):
+ _inherit = "account.invoice"
+
+ def invoice_validate(self):
+ for invoice in self:
+ 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.invoice_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(AccountInvoice, self).invoice_validate() \ No newline at end of file