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 I create a second sequence for purchase order. ?

By
luis
on 6/21/13, 4:52 PM 816 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):
    default.update({
    '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'),
        }  
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>
<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>
</record>

</data>

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" />
    </xpath>
    </field>
</record>

</data>

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

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