Files
odoo_source/addons/l10n_ch/__init__.py
T
Florian Gilbert a77d80a48d [FIX] account & l10n_ch: fix l10n_ch installation on a company
And a compute field.

closes odoo/odoo#37497

Signed-off-by: Cedric Snauwaert (csn) <csn@openerp.com>
2019-09-27 14:14:18 +00:00

31 lines
1015 B
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import models
from odoo import api, SUPERUSER_ID
def load_translations(env):
env.ref('l10n_ch.l10nch_chart_template').process_coa_translations()
def init_settings(env):
'''If the company is localized in Switzerland, activate the cash rounding by default.
'''
# The cash rounding is activated by default only if the company is localized in Switzerland.
ch_country = env.ref('base.ch')
for company in env['res.company'].search([('partner_id.country_id', '=', ch_country.id)]):
res_config_id = env['res.config.settings'].create({
'company_id': company.id,
'group_cash_rounding': True
})
# We need to call execute, otherwise the "implied_group" in fields are not processed.
res_config_id.execute()
def post_init(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
load_translations(env)
init_settings(env)