~julie-w/unifield-wm/UTP-925

« back to all changes in this revision

Viewing changes to account_period_closing_level/account_year_end_closing.py

  • Committer: jftempo
  • Date: 2016-01-30 10:20:59 UTC
  • mfrom: (2740.9.3 unifield-wm)
  • Revision ID: jfb@tempo-consulting.fr-20160130102059-8knqq5g5mmj8ijpt
US-879 [FIX] Fiscal Year closing: sync down FY state and periods state
lp:~unifield-team/unifield-wm/us-879

Show diffs side-by-side

added added

removed removed

Lines of Context:
765
765
                state = 'done'
766
766
 
767
767
        if state:
768
 
            vals = { 'state': state, }
769
768
            # period 0 (FY+1)/16 state
 
769
 
 
770
            # US-879: for periods update, set 'state_sync_flag' field first,
 
771
            # for adhoc sync state flow, like in account_period.action_set_state
 
772
            vals = { 'state_sync_flag': state, }
770
773
            period_ids = self._get_periods_ids(cr, uid,
771
774
                self._browse_fy(cr, uid, fy_id, context=context),
772
775
                context=context)
774
777
                self.pool.get('account.period').write(cr, uid, period_ids, vals,
775
778
                    context=context)
776
779
 
777
 
            # fy state
 
780
                # then after 'state_sync_flag' set, set account_journal_period state
 
781
                # and period true state
 
782
                # (DO NOT CHANGE 'state' in same write than 'state_sync_flag'
 
783
                if state == 'done':
 
784
                    journal_state = 'done'
 
785
                else:
 
786
                    journal_state = 'draft'
 
787
                cr.execute('UPDATE account_journal_period' \
 
788
                    ' SET state=%s WHERE period_id IN %s', (
 
789
                        journal_state, tuple(period_ids), ))
 
790
                vals = {'state': state, 'field_process': False}
 
791
                self.pool.get('account.period').write(cr, uid, period_ids, vals,
 
792
                        context=context)
 
793
 
 
794
            # then set FY state
 
795
            vals = { 'state': state, }
778
796
            fy_obj.write(cr, uid, [fy_id], vals, context=context)
779
797
 
780
798
    def _search_record(self, cr, uid, model, domain, context=None):