mirror of
https://github.com/bringout/oca-ocb-l10n_europe.git
synced 2026-04-27 04:22:00 +02:00
Initial commit: L10N_Europe packages
This commit is contained in:
commit
9803722600
2377 changed files with 380711 additions and 0 deletions
8
odoo-bringout-oca-ocb-l10n_de/l10n_de/models/__init__.py
Normal file
8
odoo-bringout-oca-ocb-l10n_de/l10n_de/models/__init__.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import account_journal
|
||||
from . import datev
|
||||
from . import chart_template
|
||||
from . import ir_actions_report
|
||||
from . import res_company
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import api, models
|
||||
|
||||
class AccountJournal(models.Model):
|
||||
_inherit = "account.journal"
|
||||
|
||||
@api.model
|
||||
def _prepare_liquidity_account_vals(self, company, code, vals):
|
||||
res = super()._prepare_liquidity_account_vals(company, code, vals)
|
||||
|
||||
if company.account_fiscal_country_id.code == 'DE':
|
||||
tag_ids = res.get('tag_ids', [])
|
||||
tag_ids.append((4, self.env.ref('l10n_de.tag_de_asset_bs_B_IV').id))
|
||||
res['tag_ids'] = tag_ids
|
||||
|
||||
return res
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from odoo import models, Command, _
|
||||
|
||||
|
||||
class AccountChartTemplate(models.Model):
|
||||
_inherit = 'account.chart.template'
|
||||
|
||||
# Write paperformat and report template used on company
|
||||
def _load(self, company):
|
||||
res = super(AccountChartTemplate, self)._load(company)
|
||||
if self in [
|
||||
self.env.ref('l10n_de_skr03.l10n_de_chart_template', raise_if_not_found=False),
|
||||
self.env.ref('l10n_de_skr04.l10n_chart_de_skr04', raise_if_not_found=False)
|
||||
]:
|
||||
company.write({
|
||||
'external_report_layout_id': self.env.ref('l10n_din5008.external_layout_din5008').id,
|
||||
'paperformat_id': self.env.ref('l10n_din5008.paperformat_euro_din').id
|
||||
})
|
||||
|
||||
outstanding_receipt = company.account_journal_payment_debit_account_id
|
||||
outstanding_payment = company.account_journal_payment_credit_account_id
|
||||
|
||||
asset_tag = self.env.ref('l10n_de.tag_de_asset_bs_B_II_4')
|
||||
outstanding_receipt['tag_ids'] += asset_tag
|
||||
outstanding_payment['tag_ids'] += asset_tag
|
||||
|
||||
return res
|
||||
|
||||
def _prepare_transfer_account_template(self):
|
||||
res = super(AccountChartTemplate, self)._prepare_transfer_account_template(None)
|
||||
if self in [
|
||||
self.env.ref('l10n_de_skr03.l10n_de_chart_template', raise_if_not_found=False),
|
||||
self.env.ref('l10n_de_skr04.l10n_chart_de_skr04', raise_if_not_found=False)
|
||||
]:
|
||||
tag_ids = res.get('tag_ids', [])
|
||||
tag_ids += [Command.link(self.env.ref('l10n_de.tag_de_asset_bs_B_II_4').id)]
|
||||
res['tag_ids'] = tag_ids
|
||||
|
||||
return res
|
||||
|
||||
def _create_liquidity_journal_suspense_account(self, company, code_digits):
|
||||
if self not in [
|
||||
self.env.ref('l10n_de_skr03.l10n_de_chart_template', raise_if_not_found=False),
|
||||
self.env.ref('l10n_de_skr04.l10n_chart_de_skr04', raise_if_not_found=False)
|
||||
]:
|
||||
return super()._create_liquidity_journal_suspense_account(company, code_digits)
|
||||
return self.env['account.account'].create({
|
||||
'name': _("Bank Suspense Account"),
|
||||
'code': self.env['account.account']._search_new_account_code(company, code_digits, company.bank_account_code_prefix or ''),
|
||||
'account_type': 'asset_current',
|
||||
'company_id': company.id,
|
||||
'tag_ids': self.env.ref('l10n_de.tag_de_asset_bs_B_IV')
|
||||
})
|
||||
40
odoo-bringout-oca-ocb-l10n_de/l10n_de/models/datev.py
Normal file
40
odoo-bringout-oca-ocb-l10n_de/l10n_de/models/datev.py
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
from odoo import fields, models
|
||||
|
||||
class AccountTaxTemplate(models.Model):
|
||||
_inherit = 'account.tax.template'
|
||||
|
||||
l10n_de_datev_code = fields.Char(size=4)
|
||||
|
||||
def _get_tax_vals(self, company, tax_template_to_tax):
|
||||
vals = super(AccountTaxTemplate, self)._get_tax_vals(company, tax_template_to_tax)
|
||||
vals['l10n_de_datev_code'] = self.l10n_de_datev_code
|
||||
return vals
|
||||
|
||||
class AccountTax(models.Model):
|
||||
_inherit = "account.tax"
|
||||
|
||||
l10n_de_datev_code = fields.Char(size=4, help="4 digits code use by Datev")
|
||||
|
||||
|
||||
class ProductTemplate(models.Model):
|
||||
_inherit = "product.template"
|
||||
|
||||
def _get_product_accounts(self):
|
||||
""" As taxes with a different rate need a different income/expense account, we add this logic in case people only use
|
||||
invoicing to not be blocked by the above constraint"""
|
||||
result = super(ProductTemplate, self)._get_product_accounts()
|
||||
company = self.env.company
|
||||
if company.account_fiscal_country_id.code == "DE":
|
||||
if not self.property_account_income_id:
|
||||
taxes = self.taxes_id.filtered(lambda t: t.company_id == company)
|
||||
if not result['income'] or (result['income'].tax_ids and taxes and taxes[0] not in result['income'].tax_ids):
|
||||
result_income = self.env['account.account'].search([('internal_group', '=', 'income'), ('deprecated', '=', False),
|
||||
('tax_ids', 'in', taxes.ids)], limit=1)
|
||||
result['income'] = result_income or result['income']
|
||||
if not self.property_account_expense_id:
|
||||
supplier_taxes = self.supplier_taxes_id.filtered(lambda t: t.company_id == company)
|
||||
if not result['expense'] or (result['expense'].tax_ids and supplier_taxes and supplier_taxes[0] not in result['expense'].tax_ids):
|
||||
result_expense = self.env['account.account'].search([('internal_group', '=', 'expense'), ('deprecated', '=', False),
|
||||
('tax_ids', 'in', supplier_taxes.ids)], limit=1)
|
||||
result['expense'] = result_expense or result['expense']
|
||||
return result
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
from odoo import models
|
||||
|
||||
|
||||
class IrActionsReport(models.Model):
|
||||
_inherit = 'ir.actions.report'
|
||||
|
||||
def _get_rendering_context(self, report, docids, data):
|
||||
data = super()._get_rendering_context(report, docids, data)
|
||||
data['din_header_spacing'] = report.get_paperformat().header_spacing
|
||||
return data
|
||||
40
odoo-bringout-oca-ocb-l10n_de/l10n_de/models/res_company.py
Normal file
40
odoo-bringout-oca-ocb-l10n_de/l10n_de/models/res_company.py
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
import stdnum.de.stnr
|
||||
import stdnum.exceptions
|
||||
|
||||
|
||||
class ResCompany(models.Model):
|
||||
_inherit = 'res.company'
|
||||
|
||||
l10n_de_stnr = fields.Char(string="St.-Nr.", help="Steuernummer. Scheme: ??FF0BBBUUUUP, e.g.: 2893081508152 https://de.wikipedia.org/wiki/Steuernummer")
|
||||
l10n_de_widnr = fields.Char(string="W-IdNr.", help="Wirtschafts-Identifikationsnummer.")
|
||||
|
||||
@api.depends('country_code')
|
||||
@api.constrains('state_id', 'l10n_de_stnr')
|
||||
def _validate_l10n_de_stnr(self):
|
||||
for record in self:
|
||||
record.get_l10n_de_stnr_national()
|
||||
|
||||
def get_l10n_de_stnr_national(self):
|
||||
self.ensure_one()
|
||||
national_steuer_nummer = None
|
||||
|
||||
if self.l10n_de_stnr and self.country_code == 'DE':
|
||||
try:
|
||||
national_steuer_nummer = stdnum.de.stnr.to_country_number(self.l10n_de_stnr, self.state_id.name)
|
||||
except stdnum.exceptions.InvalidComponent:
|
||||
raise ValidationError(_("Your company's SteuerNummer is not compatible with your state"))
|
||||
except stdnum.exceptions.InvalidFormat:
|
||||
if stdnum.de.stnr.is_valid(self.l10n_de_stnr, self.state_id.name):
|
||||
national_steuer_nummer = self.l10n_de_stnr
|
||||
else:
|
||||
raise ValidationError(_("Your company's SteuerNummer is not valid"))
|
||||
|
||||
elif self.l10n_de_stnr:
|
||||
national_steuer_nummer = self.l10n_de_stnr
|
||||
|
||||
return national_steuer_nummer
|
||||
Loading…
Add table
Add a link
Reference in a new issue