From 8daee188488eefc36ee408ee7dfd5ad3b1b8ecb3 Mon Sep 17 00:00:00 2001 From: william Date: Fri, 8 May 2020 11:16:45 +0000 Subject: [PATCH] [IMP] base: populate currency order on res company The CHF currency was duplicated. Instead of using an hard coded list, select from all the active currencies. These are USD and EUR on a clean DB but it is easy to change if we want to populate with another currency in some use case, without changing the code. --- odoo/addons/base/populate/res_company.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/odoo/addons/base/populate/res_company.py b/odoo/addons/base/populate/res_company.py index 675e3e89f42..4e6e6ca98e4 100644 --- a/odoo/addons/base/populate/res_company.py +++ b/odoo/addons/base/populate/res_company.py @@ -18,9 +18,10 @@ class Partner(models.Model): def _populate_factories(self): # remaining: paperformat_id, parent_id, partner_id, favicon, font, report_header, external_report_layout_id, report_footer - ref = self.env.ref def get_name(values=None, counter=0, **kwargs): return 'company_%s_%s' % (counter, self.env['res.currency'].browse(values['currency_id']).name) + + active_currencies = self.env['res.currency'].search([('active', '=', True)]).ids return [ ('name', populate.constant('company_{counter}')), ('sequence', populate.randint(0, 100)), @@ -29,7 +30,7 @@ class Partner(models.Model): [False] + [e[0] for e in type(self).base_onboarding_company_state.selection])), ('primary_color', populate.iterate([False, '', '#ff7755'])), ('secondary_color', populate.iterate([False, '', '#ffff55'], seed='primary_color')), - ('currency_id', populate.iterate([ref('base.EUR').id, ref('base.USD').id, ref('base.CHF').id, ref('base.CHF').id])), # add more? + ('currency_id', populate.iterate(active_currencies)), ('name', populate.compute(get_name)), ]