Odoo Help


Increment integer fileds

on 4/28/16, 12:43 PM 782 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 5 8
Surat, India
--Jignesh Mehta--

- I have 3+ years of Industry Experience, specializing Odoo Development, Analysis, Customization, Implementation, Integration.
- I have done many Customization modules in Sale, Purchase, Point of Sale, Inventory, CRM and much more. Also Worked in the Odoo Themes like Business Theme or E-Commerce Theme.
- Develop Jewelery Manufacturing process from Scratch. It have more than 10 Department. Develop PDF and Excel reports for this project around 150 per format.

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

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: 782 times
Last updated: 5/3/16, 3:40 AM