~unifield-team/unifield-wm/us-826

« back to all changes in this revision

Viewing changes to account_override/invoice.py

  • Committer: Quentin THEURET
  • Date: 2014-03-05 16:51:14 UTC
  • mto: (2004.1.33 unifield-wm)
  • mto: This revision was merged to the branch mainline in revision 2016.
  • Revision ID: qt@tempo-consulting.fr-20140305165114-m3n5p978sisi4n3f
REF-27 [FIX] Fix import of tools.translate

Show diffs side-by-side

added added

removed removed

Lines of Context:
127
127
        """
128
128
        if not context:
129
129
            context = {}
130
 
        if context.get('update_mode') in ['init', 'update']:
131
 
            logging.getLogger('init').info('INV: set from yml test to True')
132
 
            vals['from_yml_test'] = True
133
130
        # Create a sequence for this new invoice
134
131
        res_seq = self.create_sequence(cr, uid, vals, context)
135
132
        vals.update({'sequence_id': res_seq,})
 
133
        # UTP-317 # Check that no inactive partner have been used to create this invoice
 
134
        if 'partner_id' in vals:
 
135
            partner_id = vals.get('partner_id')
 
136
            if isinstance(partner_id, (str)):
 
137
                partner_id = int(partner_id)
 
138
            partner = self.pool.get('res.partner').browse(cr, uid, [partner_id])
 
139
            active = True
 
140
            if partner and partner[0] and not partner[0].active:
 
141
                raise osv.except_osv(_('Warning'), _("Partner '%s' is not active.") % (partner[0] and partner[0].name or '',))
136
142
        return super(account_invoice, self).create(cr, uid, vals, context)
137
 
 
 
143
    
138
144
    def _check_document_date(self, cr, uid, ids):
139
145
        """
140
146
        Check that document's date is done BEFORE posting date
264
270
        """
265
271
        if not context:
266
272
            context = {}
267
 
        if context.get('update_mode') in ['init', 'update']:
268
 
            logging.getLogger('init').info('INV: set from yml test to True')
269
 
            vals['from_yml_test'] = True
270
273
        # Create new number with invoice sequence
271
274
        if vals.get('invoice_id') and self._name in ['account.invoice.line']:
272
275
            invoice = self.pool.get('account.invoice').browse(cr, uid, vals['invoice_id'])
273
276
            if invoice and invoice.sequence_id:
274
277
                sequence = invoice.sequence_id
275
 
                line = sequence.get_id(test='id', context=context)
 
278
                line = sequence.get_id(code_or_id='id', context=context)
276
279
                vals.update({'line_number': line})
277
280
        return super(account_invoice_line, self).create(cr, uid, vals, context)
278
281
 
289
292
            for il in self.browse(cr, uid, ids):
290
293
                if not il.line_number and il.invoice_id.sequence_id:
291
294
                    sequence = il.invoice_id.sequence_id
292
 
                    il_number = sequence.get_id(test='id', context=context)
 
295
                    il_number = sequence.get_id(code_or_id='id', context=context)
293
296
                    vals.update({'line_number': il_number})
294
297
        return super(account_invoice_line, self).write(cr, uid, ids, vals, context)
295
298