~unifield-team/unifield-wm/uftp-388

« back to all changes in this revision

Viewing changes to account_corrections/wizard/journal_items_corrections.py

  • Committer: duy.vo at msf
  • Date: 2014-10-28 10:10:09 UTC
  • Revision ID: duy.vo@geneva.msf.org-20141028101009-l781gnpawie7ee6l
UFTP-388: Check if the given period is valid before doing any corrections

Show diffs side-by-side

added added

removed removed

Lines of Context:
322
322
                    raise osv.except_osv(_('Warning'), _('Please insert a correction date from the entry date onwards.'))
323
323
        # Retrieve values
324
324
        wizard = self.browse(cr, uid, ids[0], context=context)
 
325
        
 
326
        # UFTP-388: Check if the given period is valid: period open, or not close, if not just block the correction
 
327
        correction_period_ids = self.pool.get('account.period').get_period_from_date(cr, uid, wizard.date)
 
328
        if not correction_period_ids:
 
329
                raise osv.except_osv(_('Error'), _('No period found for the given date: %s') % (wizard.date,))
 
330
        for cp in self.pool.get('account.period').browse(cr, uid, correction_period_ids):
 
331
            if cp.state != 'draft':
 
332
                raise osv.except_osv(_('Error'), _('Period (%s) is not open.') % (cp.name,))        
 
333
        
325
334
        aml_obj = self.pool.get('account.move.line')
326
335
        # Fetch old line
327
336
        old_line = wizard.move_line_id