mirror of
https://github.com/bringout/oca-ocb-core.git
synced 2026-04-21 03:32:05 +02:00
17.0 vanilla
This commit is contained in:
parent
2e65bf056a
commit
df627a6bba
328 changed files with 578149 additions and 759311 deletions
|
|
@ -19,18 +19,17 @@ class Partner(models.Model):
|
|||
def _populate_factories(self):
|
||||
# Activate currency to avoid fail iterator
|
||||
(self.env.ref('base.USD') | self.env.ref('base.EUR')).active = True
|
||||
last_id = self.env["res.company"].search([], order="id desc", limit=1).id
|
||||
|
||||
# remaining: paperformat_id, parent_id, partner_id, favicon, font, report_header, external_report_layout_id, report_footer
|
||||
# remaining: paperformat_id, parent_id, partner_id, font, report_header, external_report_layout_id, report_footer
|
||||
def get_name(values=None, counter=0, **kwargs):
|
||||
return 'company_%s_%s' % (counter, self.env['res.currency'].browse(values['currency_id']).name)
|
||||
return 'company_%s_%s' % (last_id + counter + 1, 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)),
|
||||
('company_registry', populate.iterate([False, 'company_registry_{counter}'])),
|
||||
('base_onboarding_company_state', populate.iterate(
|
||||
[False] + [e[0] for e in self._fields['base_onboarding_company_state'].selection])),
|
||||
('primary_color', populate.iterate([False, '', '#ff7755'])),
|
||||
('secondary_color', populate.iterate([False, '', '#ffff55'], seed='primary_color')),
|
||||
('currency_id', populate.iterate(active_currencies)),
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class ResCurrencyRate(models.Model):
|
|||
])
|
||||
return [
|
||||
('currency_id', populate.randomize(self.env['res.currency'].search([('active', '=', True)]).ids)),
|
||||
('company_id', populate.randomize(company_ids.ids)),
|
||||
('company_id', populate.randomize(company_ids.root_id.ids)),
|
||||
('name', populate.compute(get_date)),
|
||||
('rate', populate.compute(get_rate)),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ class Partner(models.Model):
|
|||
('employee', populate.cartesian([True, False], [0.1, 0.9])),
|
||||
('email', populate.iterate(
|
||||
[False, '', 'email{counter}@example.com', '<contact 万> contact{counter}@anotherexample.com', 'invalid_email'])),
|
||||
('type', populate.constant('contact')), # todo add more logic, manage 'invoice', 'delivery', 'other', 'private'
|
||||
('type', populate.constant('contact')), # todo add more logic, manage 'invoice', 'delivery', 'other'
|
||||
('is_company', populate.iterate([True, False], [0.05, 0.95])),
|
||||
('_address', generate_address),
|
||||
('state_id', populate.compute(get_state)),
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ class Users(models.Model):
|
|||
_populate_dependencies = ["res.partner"]
|
||||
|
||||
def _populate_factories(self):
|
||||
last_id = self.env["res.users"].search([], order="id desc", limit=1).id
|
||||
|
||||
def generate_partner_id(iterator, *args):
|
||||
partner_factories = self.env['res.partner']._populate_factories()
|
||||
partner_generator = populate.chain_factories(partner_factories, self._name)
|
||||
|
|
@ -30,13 +32,19 @@ class Users(models.Model):
|
|||
def get_company_ids(values, **kwargs):
|
||||
return [(6, 0, [values['company_id']])]
|
||||
|
||||
def compute_login(values=None, counter=0, **kwargs):
|
||||
return f'user_login_{last_id + counter + 1}'
|
||||
|
||||
def compute_name(values=None, counter=0, **kwargs):
|
||||
return f'user_{last_id + counter + 1}'
|
||||
|
||||
return [
|
||||
('active', populate.cartesian([True, False], [0.9, 0.1])),
|
||||
('partner_id', generate_partner_id),
|
||||
('company_id', populate.randomize(self.env.registry.populated_models['res.company'])),
|
||||
('company_ids', populate.compute(get_company_ids)),
|
||||
('login', populate.constant('user_login_{counter}')),
|
||||
('name', populate.constant('user_{counter}')),
|
||||
('login', populate.compute(compute_login)),
|
||||
('name', populate.compute(compute_name)),
|
||||
]
|
||||
|
||||
def _populate(self, size):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue