summaryrefslogtreecommitdiff
path: root/addons/l10n_de
diff options
context:
space:
mode:
authorCedric Snauwaert <csn@openerp.com>2018-06-08 14:48:37 +0200
committerqdp-odoo <qdp@odoo.com>2018-07-26 15:15:12 +0200
commit82da221b1fb761bdab84c4ffd3924809df2bec39 (patch)
tree0c8e0834b13544d2f588268c97b8fdb7c2066b8b /addons/l10n_de
parenta3bc08d9d8aa40e8d41f99e5b102997c6990396a (diff)
[FIX] l10n_de: DATEV export compatiblity
When invoicing a line with an account that has a tax, ensure that line has the same tax of accounts. This is required by DATEV and is common usage in Germany Was task 35289 Was PR #25202
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