Odoo Help


Increment integer fileds

on 4/28/16, 12:43 PM 352 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
              'name1':fields.function(_get_increment, type='integer', string='Name1'),

Jignesh Mehta

--Jignesh Mehta--
| 6 4 8
Surat, India
--Jignesh Mehta--

Jignesh Mehta
On 4/29/16, 12:11 AM

Hello Jihen,

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


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

on 4/29/16, 4:03 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

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.


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)


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