~unifield-team/unifield-wm/us-671-homere

« back to all changes in this revision

Viewing changes to account_override/invoice.py

  • Committer: jf
  • Date: 2015-07-30 12:32:15 UTC
  • mfrom: (2542.10.9 unifield-wm)
  • Revision ID: jfb@tempo-consulting.fr-20150730123215-shhjwx7p7iiw6qxb
US-192 [IMP] Accounting documents: check posting date and document date are in the same FY

lp:~unifield-team/unifield-wm/us-192

Show diffs side-by-side

added added

removed removed

Lines of Context:
308
308
        if isinstance(ids, (int, long)):
309
309
            ids = [ids]
310
310
        for i in self.browse(cr, uid, ids):
311
 
            if i.document_date and i.date_invoice and i.date_invoice < i.document_date:
312
 
                raise osv.except_osv(_('Error'), _('Posting date should be later than Document Date.'))
 
311
            self.pool.get('finance.tools').check_document_date(cr, uid,
 
312
                i.document_date, i.date_invoice)
313
313
        return True
314
314
 
315
315
    def _refund_cleanup_lines(self, cr, uid, lines):
468
468
        """
469
469
        if not context:
470
470
            context = {}
 
471
        if 'document_date' in vals and 'date_invoice' in vals:
 
472
            self.pool.get('finance.tools').check_document_date(cr, uid,
 
473
                vals['document_date'], vals['date_invoice'], context=context)
 
474
 
471
475
        # Create a sequence for this new invoice
472
476
        res_seq = self.create_sequence(cr, uid, vals, context)
473
477
        vals.update({'sequence_id': res_seq,})
 
478
 
474
479
        # UTP-317 # Check that no inactive partner have been used to create this invoice
475
480
        if 'partner_id' in vals:
476
481
            partner_id = vals.get('partner_id')
479
484
            partner = self.pool.get('res.partner').browse(cr, uid, [partner_id])
480
485
            if partner and partner[0] and not partner[0].active:
481
486
                raise osv.except_osv(_('Warning'), _("Partner '%s' is not active.") % (partner[0] and partner[0].name or '',))
 
487
 
482
488
        return super(account_invoice, self).create(cr, uid, vals, context)
483
489
 
484
490
    def write(self, cr, uid, ids, vals, context=None):