Odoo Help


How can I create a second sequence for purchase order. ?

on 6/21/13, 4:52 PM 1,134 views

Purchase order already have a sequence, my first question is:

How can I create a second sequence ?

How can I restrict this sequence only for a particular partner ?

This is my code I use, but obviously is overriding for the first sequence.

class purchase_order(osv.osv):
_inherit = 'purchase.order'
_name = 'purchase.order'

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

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

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

_defaults = {
        'bic_code': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'purchase.order'),

XML sequence

<?xml version="1.0" encoding="utf-8"?>
<record model="ir.sequence.type" id="seq_type_purchase_bic">
    <field name="name">number_bic_sequence</field>
    <field name="code">purchase.order.bic1</field>
<record model="ir.sequence" id="seq_purchase_bic">
    <field name="name">number_bic_sequence</field>
    <field name="code">purchase.order.bic1</field>
    <field name="prefix">10670-</field>
    <field name="padding">5</field>


XML view

<?xml version="1.0" encoding="utf-8"?>
<record id="view_bic_form" model="ir.ui.view">
        <field name="name">purchase.bic.order.form</field>
        <field name="model">purchase.order</field>
        <field name="inherit_id" ref="purchase.purchase_order_form" />
        <field name="arch" type="xml">
    <xpath expr="/form/group/field[@name='date_order']" position="after">
        <field name="bic_code" />


Thank you very much for any help you can give me .

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/21/13, 4:52 PM
Seen: 1134 times
Last updated: 3/16/15, 8:10 AM