Odoo Help

Welcome!

This community 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.

0

Increment integer fileds

By
Jihen BEN ALI
on 4/28/16, 12:43 PM 291 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

--Jignesh Mehta--
2087
| 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,

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

Jihen BEN ALI
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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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