[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.
This commit is contained in:
@@ -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)),
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user