Odoo Help


How can you condition a sequence ?

on 6/25/13, 6:05 PM 1,323 views

I generate an alternative sequence for purchase_orders, it works fine, now what I need is that this new sequence only works for a particular supplier, so for this supplier the sequence is 1,2,3,4,5 and so on, and for the rest is 0 or nothing .

how can I achive this ? thanks for your help.

class purchase_order(osv.osv):

_inherit = 'purchase.order'
_name = 'purchase.order'

def create(self, cr, uid,vals, context={}):
    vals['extra_code'] = self.pool.get('ir.sequence').get(cr, uid, 'purchase.order.extra')
    res = super(purchase_order, self).create(cr, uid, vals, context)
    return res

def copy(self, cr, uid, id, default=None, context=None):
    'extra_code': self.pool.get('ir.sequence').get(cr, uid, 'purchase.order.extra')})
    return super(porchase_order, self).copy(cr, uid, id, default, context)

_columns = {
        'extra_code': fields.char('Referencia Bic', size=64, readonly=True),


Hi! I think there is a mistake in copy() method. When you call super you have assign wrong class name it should be purchase_order.

on 6/26/13, 2:47 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

0 follower(s)


Asked: 6/25/13, 6:05 PM
Seen: 1323 times
Last updated: 3/16/15, 8:10 AM