This question has been flagged
1 Reply
2926 Views

Hello everyone,

I have added this fields under account.invoice inorder to get an autoincrement number but it doesn't work

Help me please to figure out my error

    _inherit = 'account.invoice'
    
    def _get_increment(self, cr, uid, ids, fields, arg, context=None):
        if context is None: context = {}
        res = {}
        if type == 'out_invoice':
            ids = self.search(cr,uid,[('id','!=',False),('type','in',('out_invoice','out_refund'))])
            if ids:
                last_id = ids and max(ids)
                print 'last_id',last_id
                for invoice in self.browse(cr, uid, last_id, context):
                    print 'invoice', invoice
                    res[invoice.id] = invoice.name1
                    invoice.name1 += 1
            return res
    
    _columns={
              'name1':fields.function(_get_increment, type='integer', string='Name1'),
    }
Avatar
Discard
Best Answer

Hello Jihen,


You can use the Sequence for custom fields for auto increment number.

Thanks,

Avatar
Discard
Author

Thanks for your answer but I don't want to use sequence