~jgrandguillaume-c2c/openobject-addons/multi-company-cost-price

« back to all changes in this revision

Viewing changes to account_voucher/voucher.py

  • Committer: Joël Grand-Guillaume
  • Date: 2010-04-08 09:00:10 UTC
  • mfrom: (2533.3.664)
  • Revision ID: joel.grandguillaume@camptocamp.com-20100408090010-c0pqjan341s18bxs
[MRG] Merge from last trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
152
152
        balance=account.balance
153
153
        return {'value':{'amount':balance}}
154
154
 
155
 
    def onchange_journal(self, cr, uid, ids, journal_id,type):
 
155
    def onchange_journal(self, cr, uid, ids, journal_id, type):
156
156
        if not journal_id:
157
157
            return {'value':{'account_id':False}}
158
158
        journal = self.pool.get('account.journal')
171
171
        total=0
172
172
        for i in obj[0].payment_ids:
173
173
            total+=i.amount
174
 
        self.write(cr,uid,ids,{'amount':total})
175
 
        self.write(cr, uid, ids, {'state':'proforma'})
 
174
        if total!=0:
 
175
            self.write(cr,uid,ids,{'amount':total})
 
176
            self.write(cr, uid, ids, {'state':'proforma'})
 
177
        else:
 
178
            raise osv.except_osv('Invalid action !', 'You can not post to Pro-Forma a voucher with Total amount = 0')
176
179
        return True
177
180
 
178
181
    def proforma_voucher(self, cr, uid, ids, context={}):
197
200
            if t['state'] in ('draft', 'cancel'):
198
201
                unlink_ids.append(t['id'])
199
202
            else:
200
 
                raise osv.except_osv('Invalid action !', 'Cannot delete invoice(s) which are already opened or paid !')
 
203
                raise osv.except_osv('Invalid action !', 'Cannot delete Voucher(s) which are already opened or paid !')
201
204
        osv.osv.unlink(self, cr, uid, unlink_ids)
202
205
        return True
203
206
 
402
405
    def _convert_ref(self, cr, uid, ref):
403
406
        return (ref or '').replace('/','')
404
407
 
405
 
 
406
408
    def action_number(self, cr, uid, ids, *args):
407
409
        cr.execute('SELECT id, type, number, move_id, reference ' \
408
410
                'FROM account_voucher ' \
428
430
                            (ref, move_id))
429
431
        return True
430
432
 
431
 
 
432
 
 
433
433
    def name_get(self, cr, uid, ids, context={}):
434
434
        if not len(ids):
435
435
            return []
481
481
 
482
482
account_voucher()
483
483
 
484
 
class VoucherLine(osv.osv):
 
484
class account_voucher_line(osv.osv):
485
485
    _name = 'account.voucher.line'
486
486
    _description = 'Voucher Line'
487
487
    _columns = {
694
694
            'ref' : line.ref
695
695
        }
696
696
 
697
 
VoucherLine()
 
697
account_voucher_line()
698
698
 
699
699
 
700
700