~unifield-team/unifield-wm/fm-us-3386-sync-env

« back to all changes in this revision

Viewing changes to mkdb.py

  • Committer: jf
  • Date: 2017-08-29 09:17:55 UTC
  • mfrom: (119.1.1 sync-env)
  • Revision ID: jfb@tempo-consulting.fr-20170829091755-l29m5ngbdq5yc68e
US-3204: create FY

Show diffs side-by-side

added added

removed removed

Lines of Context:
775
775
        month = time.strftime('%m')
776
776
        # search current fiscalyear
777
777
        fy_ids = self.db.search_data('account.fiscalyear', [('date_start', '<=', today), ('date_stop', '>=', today)])
 
778
        if not fy_ids:
 
779
            create_fy_wiz = self.db.get('account.period.create')
 
780
            wiz_id = create_fy_wiz.create({'fiscalyear': 'current'})
 
781
            create_fy_wiz.account_period_create_periods([wiz_id])
 
782
            fy_ids = self.db.search_data('account.fiscalyear', [('date_start', '<=', today), ('date_stop', '>=', today)])
 
783
 
778
784
        assert len(fy_ids) > 0, "No fiscalyear found!"
779
785
        period_ids = self.db.search_data('account.period', [('fiscalyear_id', 'in', fy_ids), ('number', '<=', month), ('state', '=', 'created')])
780
786
        # change all period by draft state (should use action_set_state but openerplib doesn't give way to do this)