Files
odoo_source/addons/l10n_nl/models/account_journal.py
T
Hubert (huvw) 4fa534abaf [FIX] l10n_nl: set 'Cost of Revenue' in allowed account types for Vendor Bills journal created for a l10n_nl chart of account
Allow Cost of Revenue accounts to match the default expense account

closes odoo/odoo#74461

Ticket: 2458146
X-original-commit: f4235243700d4a52117ca6750c44afb10142bf42
Signed-off-by: William André (wan) <wan@odoo.com>
2021-07-29 16:52:52 +00:00

34 lines
1.2 KiB
Python

# -*- coding: utf-8 -*-
from odoo import api, fields, models, _
class AccountJournal(models.Model):
_inherit = 'account.journal'
@api.model
def _fill_missing_values(self, vals):
super()._fill_missing_values(vals)
if vals.get('type') != 'purchase':
return
company = self.env['res.company'].browse(vals['company_id']) if vals.get('company_id') else self.env.company
if company.country_id.code == "NL":
type_control_ids = vals.get('type_control_ids', [])
type_control_ids.append(self.env.ref('account.data_account_type_direct_costs').id)
vals['type_control_ids'] = [(6, 0, type_control_ids)]
@api.model
def _prepare_liquidity_account_vals(self, company, code, vals):
# OVERRIDE
account_vals = super()._prepare_liquidity_account_vals(company, code, vals)
if company.account_fiscal_country_id.code == 'NL':
# Ensure the newly liquidity accounts have the right account tag in order to be part
# of the Dutch financial reports.
account_vals.setdefault('tag_ids', [])
account_vals['tag_ids'].append((4, self.env.ref('l10n_nl.account_tag_25').id))
return account_vals