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

« back to all changes in this revision

Viewing changes to res_currency_functional/account_move_line_compute_currency.py

  • Committer: jf
  • Date: 2016-01-25 14:14:07 UTC
  • mfrom: (2703.20.59 unifield-wm)
  • Revision ID: jfb@tempo-consulting.fr-20160125141407-vgfz8lrdvvgq0zip
US-822 [IMP] Year End Closure functionnality
lp:~unifield-team/unifield-wm/us-822

Show diffs side-by-side

added added

removed removed

Lines of Context:
401
401
            if move_line.source_date:
402
402
                ctx['date'] = move_line.source_date
403
403
 
404
 
            if move_line.period_id.state != 'done':
 
404
            if move_line.period_id.state != 'done' and not move_line.period_id.is_system:
405
405
                if move_line.debit_currency != 0.0 or move_line.credit_currency != 0.0:
406
406
                    # amount currency is not set; it is computed from the 2 other fields
407
407
                    amount_currency = move_line.debit_currency - move_line.credit_currency
502
502
        # Some verifications
503
503
        self.check_date(cr, uid, vals)
504
504
        date_to_compute = False
 
505
        is_system_period = False
505
506
 
506
507
        if 'period_id' in vals:
507
508
            period = self.pool.get('account.period').browse(cr, uid, vals.get('period_id'), context)
508
509
            if period and period.state == 'created':
509
510
                raise osv.except_osv(_('Error !'), _('Period \'%s\' is not open! No Journal Item is created') % (period.name,))
 
511
            is_system_period = period.is_system
510
512
 
511
513
        if not 'date' in vals:
512
514
            if vals.get('move_id'):
546
548
            else:
547
549
                newvals['currency_id'] = curr_fun
548
550
        # Don't update values for addendum lines that come from a reconciliation
549
 
        if not newvals.get('is_addendum_line', False):
 
551
        if not is_system_period and not newvals.get('is_addendum_line', False):
550
552
            newvals.update(self._update_amount_bis(cr, uid, vals, newvals['currency_id'], curr_fun, date=date_to_compute))
551
553
        return super(account_move_line_compute_currency, self).create(cr, uid, newvals, context, check=check)
552
554
 
573
575
                vals.update({'currency_id': line.move_id and line.move_id.manual_currency_id and line.move_id.manual_currency_id.id or False})
574
576
            currency_id = vals.get('currency_id') or line.currency_id.id
575
577
            func_currency = line.account_id.company_id.currency_id.id
576
 
            newvals.update(self._update_amount_bis(cr, uid, newvals, currency_id, func_currency, date, source_date, line.debit_currency, line.credit_currency))
 
578
            if line.period_id and not line.period_id.is_system:
 
579
                newvals.update(self._update_amount_bis(cr, uid, newvals, currency_id, func_currency, date, source_date, line.debit_currency, line.credit_currency))
577
580
            res = res and super(account_move_line_compute_currency, self).write(cr, uid, [line.id], newvals, context, check=check, update_check=update_check)
578
581
            # Update addendum line for reconciliation entries if this line is reconciled
579
582
            if line.reconcile_id: