~jfb-tempo-consulting/unifield-wm/sync-env-py3

« back to all changes in this revision

Viewing changes to mkdb.py

  • Committer: jf
  • Date: 2023-11-21 10:40:13 UTC
  • Revision ID: jfb@tempo-consulting.fr-20231121104013-d5y5vy35998qvdrn
RB: activate asset / CC date_start

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
    # Needed for setUpClass and skipIf methods
34
34
    import unittest27 as unittest
35
35
 
 
36
from datetime import datetime
 
37
from dateutil.relativedelta import relativedelta
 
38
 
 
39
 
36
40
bool_configuration_only = False
37
41
bool_creation_only = False
38
42
master_dir = '/'.join(os.path.realpath(__file__).split('/')[0:-1]+['master_dump'])
343
347
                        hq_name = self.db and self.db.name and re.findall(r'HQ[0-9]+', self.db.name)
344
348
                        if hq_name and hasattr(config, 'currency_tree'):
345
349
                            data['functional_id'] = config.currency_tree.get(hq_name[-1], config.default_currency)
 
350
                    if model == 'fixed.asset.setup':
 
351
                        data['fixed_asset_ok'] = True
346
352
                    button = data.pop('button', 'action_next')
347
353
                    answer = getattr(self.db.wizard(model, data), button)()
348
354
                model = answer.get('res_model', None)
367
373
        cost_center_id = False
368
374
        top_cost_center_id = False
369
375
        mission_suffix = 'OC'
 
376
        month_12 = (datetime.now() + relativedelta(day=1, months=-12)).strftime('%Y-%m-%d')
370
377
        if mission and mission.db is hq:
371
378
            # coordo
372
379
            mission_suffix = "%02d" % self.index
376
383
                'category' : 'OC',
377
384
                'type' : 'view',
378
385
                'parent_id' : hq.search_data('account.analytic.account', {'Code':'OC'})[0],
 
386
                'date_start': month_12,
379
387
            }
380
388
            top_cost_center_id = hq.get('account.analytic.account').create(top_data)
381
389
            data = {
384
392
                'category' : 'OC',
385
393
                'type' : 'normal',
386
394
                'parent_id' : top_cost_center_id,
 
395
                'date_start': month_12,
387
396
            }
388
397
            cost_center_id = hq.get('account.analytic.account').create(data)
389
398
        elif self.db is not hq:
396
405
                'category' : 'OC',
397
406
                'type' : 'normal',
398
407
                'parent_id' : parent_cost_center_id,
 
408
                'date_start': month_12,
399
409
            }
400
410
            top_cost_center_id = hq.get('account.analytic.account').create(data)
401
411
        data = {