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

How can you condition a sequence ?

By
luis
on 6/25/13, 6:05 PM 840 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):
    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.

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

0 follower(s)

Stats

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