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):
default.update({
'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),
}
purchase_order()
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.