Odoo Help

0

Increment integer fileds

By
Jihen BEN ALI
on 4/28/16, 12:43 PM 623 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'),
    }
0
Jignesh Mehta
On 4/29/16, 12:11 AM

Hello Jihen,


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

Thanks,

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

Jihen BEN ALI
on 4/29/16, 4:03 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 4/28/16, 12:43 PM
Seen: 623 times
Last updated: 5/3/16, 3:40 AM