mirror of
https://github.com/bringout/oca-ocb-l10n_europe.git
synced 2026-04-27 00:22:03 +02:00
19.0 vanilla
This commit is contained in:
parent
ff721d030e
commit
7721452493
1826 changed files with 124775 additions and 274114 deletions
|
|
@ -1,4 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import account_account
|
||||
from . import template_dk
|
||||
from . import account_journal
|
||||
from . import res_partner
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
from collections import defaultdict
|
||||
|
||||
from odoo import api, models, _
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class AccountAccount(models.Model):
|
||||
_name = 'account.account'
|
||||
_inherit = 'account.account'
|
||||
|
||||
@api.ondelete(at_uninstall=False)
|
||||
def _unlink_bank_cash_accounts(self):
|
||||
nb_account_to_delete_per_company = defaultdict(self.env['account.account'].browse)
|
||||
for account in self:
|
||||
for company in account.company_ids:
|
||||
if company.country_code == 'DK':
|
||||
nb_account_to_delete_per_company[company] |= account
|
||||
|
||||
if not nb_account_to_delete_per_company:
|
||||
return
|
||||
|
||||
grouped_counts = self.read_group(
|
||||
domain=[('company_ids.account_fiscal_country_id.code', '=', 'DK'), ('account_type', '=', 'asset_cash')],
|
||||
fields=['company_ids', 'id:count'],
|
||||
groupby=['company_ids'],
|
||||
)
|
||||
nb_account_per_company = {self.env['res.company'].browse(entry['company_ids'][0]): entry['company_ids_count'] for entry in grouped_counts}
|
||||
|
||||
for company_id, count in nb_account_per_company.items():
|
||||
nb_to_delete = sum(1 for account in nb_account_to_delete_per_company.get(company_id) if account.account_type == 'asset_cash')
|
||||
if count - nb_to_delete < 1:
|
||||
raise UserError(_("You must keep at least one bank and cash account for %(company)s!", company=company_id.name))
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, models
|
||||
from odoo import api, Command, models
|
||||
|
||||
|
||||
class AccountJournal(models.Model):
|
||||
|
|
@ -16,6 +16,9 @@ class AccountJournal(models.Model):
|
|||
# Ensure the newly liquidity accounts have the right account tag in order to be part
|
||||
# of the Danish financial reports.
|
||||
account_vals.setdefault('tag_ids', [])
|
||||
account_vals['tag_ids'].append((4, self.env.ref('l10n_dk.account_tag_liquidity').id))
|
||||
if vals.get('type') == 'bank':
|
||||
account_vals['tag_ids'].append(Command.link(self.env.ref('l10n_dk.account_tag_6481').id))
|
||||
elif vals.get('type') == 'cash':
|
||||
account_vals['tag_ids'].append(Command.link(self.env.ref('l10n_dk.account_tag_6471').id))
|
||||
|
||||
return account_vals
|
||||
|
|
|
|||
29
odoo-bringout-oca-ocb-l10n_dk/l10n_dk/models/res_partner.py
Normal file
29
odoo-bringout-oca-ocb-l10n_dk/l10n_dk/models/res_partner.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
from odoo import api, models
|
||||
from odoo.addons.account.models.partner import _ref_company_registry
|
||||
|
||||
|
||||
class ResPartner(models.Model):
|
||||
_inherit = 'res.partner'
|
||||
|
||||
@api.depends('vat', 'country_id')
|
||||
def _compute_company_registry(self):
|
||||
# OVERRIDE
|
||||
# In Denmark, if you have a VAT number, it's also your company registry (CVR) number
|
||||
super()._compute_company_registry()
|
||||
for partner in self.filtered(lambda p: p.country_id.code == 'DK' and p.vat):
|
||||
vat_country, vat_number = self._split_vat(partner.vat)
|
||||
if vat_country in ('DK', '') and self._check_vat_number('DK', vat_number):
|
||||
partner.company_registry = vat_number
|
||||
|
||||
@api.depends('country_id.code', 'ref_company_ids.account_fiscal_country_id.code')
|
||||
def _compute_company_registry_placeholder(self):
|
||||
super()._compute_company_registry_placeholder()
|
||||
for partner in self:
|
||||
country = partner.ref_company_ids[:1].account_fiscal_country_id or partner.country_id
|
||||
if country.code == 'DK':
|
||||
partner.company_registry_placeholder = _ref_company_registry.get('dk') or ''
|
||||
|
||||
def _get_company_registry_labels(self):
|
||||
labels = super()._get_company_registry_labels()
|
||||
labels['DK'] = 'CVR'
|
||||
return labels
|
||||
45
odoo-bringout-oca-ocb-l10n_dk/l10n_dk/models/template_dk.py
Normal file
45
odoo-bringout-oca-ocb-l10n_dk/l10n_dk/models/template_dk.py
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import models
|
||||
from odoo.addons.account.models.chart_template import template
|
||||
|
||||
|
||||
class AccountChartTemplate(models.AbstractModel):
|
||||
_inherit = 'account.chart.template'
|
||||
|
||||
@template('dk')
|
||||
def _get_dk_template_data(self):
|
||||
return {
|
||||
'property_account_receivable_id': 'dk_coa_6190',
|
||||
'property_account_payable_id': 'dk_coa_7440',
|
||||
'code_digits': '4',
|
||||
}
|
||||
|
||||
@template('dk', 'res.company')
|
||||
def _get_dk_res_company(self):
|
||||
return {
|
||||
self.env.company.id: {
|
||||
'anglo_saxon_accounting': True,
|
||||
'account_fiscal_country_id': 'base.dk',
|
||||
'bank_account_code_prefix': '648',
|
||||
'cash_account_code_prefix': '647',
|
||||
'transfer_account_code_prefix': '683',
|
||||
'account_default_pos_receivable_account_id': 'dk_coa_6190',
|
||||
'income_currency_exchange_account_id': 'dk_coa_3610',
|
||||
'expense_currency_exchange_account_id': 'dk_coa_3610',
|
||||
'account_journal_early_pay_discount_loss_account_id': 'dk_coa_2720',
|
||||
'account_journal_early_pay_discount_gain_account_id': 'dk_coa_2720',
|
||||
'account_sale_tax_id': 'tax_s1',
|
||||
'account_purchase_tax_id': 'tax_k1',
|
||||
'default_cash_difference_income_account_id': 'dk_coa_2720',
|
||||
'default_cash_difference_expense_account_id': 'dk_coa_2720',
|
||||
'expense_account_id': 'dk_coa_1610',
|
||||
'income_account_id': 'dk_coa_1010',
|
||||
'restrictive_audit_trail': True,
|
||||
},
|
||||
}
|
||||
|
||||
def _setup_utility_bank_accounts(self, template_code, company, template_data):
|
||||
super()._setup_utility_bank_accounts(template_code, company, template_data)
|
||||
if template_code == 'dk':
|
||||
company.account_journal_suspense_account_id.tag_ids = self.env.ref('l10n_dk.account_tag_6482')
|
||||
company.transfer_account_id.tag_ids = self.env.ref('l10n_dk.account_tag_6831')
|
||||
Loading…
Add table
Add a link
Reference in a new issue