[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>
This commit is contained in:
Florian Gilbert
2019-09-27 14:14:18 +00:00
parent b3ab9604c4
commit a77d80a48d
3 changed files with 6 additions and 5 deletions
+1 -1
View File
@@ -92,7 +92,7 @@ class ResConfigSettings(models.TransientModel):
if self.group_multi_currency:
self.env.ref('base.group_user').write({'implied_ids': [(4, self.env.ref('product.group_sale_pricelist').id)]})
# install a chart of accounts for the given company (if required)
if self.chart_template_id and self.chart_template_id != self.company_id.chart_template_id:
if self.env.company == self.company_id and self.chart_template_id and self.chart_template_id != self.company_id.chart_template_id:
self.chart_template_id._load(15.0, 15.0, self.env.company)
@api.depends('company_id')
+2 -3
View File
@@ -14,9 +14,8 @@ 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.
for company in env['res.company'].search([]):
if company.country_id != env.ref('base.ch'):
continue
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
+3 -1
View File
@@ -86,9 +86,11 @@ class AccountMove(models.Model):
#We only keep the last digits of the sequence number if it is too long
invoice_ref = invoice_ref[-l10n_ch_ISR_NUMBER_ISSUER_LENGTH:]
internal_ref = invoice_ref.zfill(l10n_ch_ISR_NUMBER_LENGTH - l10n_ch_ISR_NUMBER_ISSUER_LENGTH - 1) # -1 for mod10r check character
record.l10n_ch_isr_number = mod10r(invoice_issuer_ref + internal_ref)
record.l10n_ch_isr_number_spaced = _space_isr_number(record.l10n_ch_isr_number)
else:
record.l10n_ch_isr_number = False
record.l10n_ch_isr_number_spaced = False
@api.depends(
'currency_id.name', 'amount_total', 'name',