Odoo Help


How to add sequences number in Purchase order Line with custom module?

on 3/26/15, 8:24 AM 1,643 views

I am trying to add a sequence number in purchase order line .But when i create  multiple purchase order with orderline  the sequence comes from the previous purchase order.line sequence number .Here is my code ...

eg: Now sequence come for first purchase order with line is 1,2,3 .If I create another purchase order then order line sequence comes like 4,5,6.I need new order line sequence starting from 1,2,3.This is my issue .Need a help....

class purchase_order_line(osv.osv):

  _inherit = 'purchase.order.line'


'line_no':fields.char('Line No'),


_defaults = {

'line_no':lambda obj,cr,uid,context:obj.pool.get('ir.sequence').get(cr, uid, 'purchase.order.line'),


=======================sequence.xml file

<?xml version="1.0"?>


<data noupdate="1">

<record id="seq_type_purchase_order_line" model="ir.sequence.type">

<field name="name">Purchase Order Line</field>

<field name="code">purchase.order.line</field>


<record id="seq_purchase_order_line" model="ir.sequence">

<field name="name">Purchase Order Line</field>

<field name="code">purchase.order.line</field>

<field name="padding">1</field>

<field name="number_increment">1</field>




==================================view.xml file-------

<record model="ir.ui.view" id="order form">

<field name="name">order.line</field>

<field name="model">purchase.order</field>

<field name="inherit_id" ref="purchase.purchase_order_form" />

<field name="arch" type="xml">

<xpath expr="/form/sheet/notebook/page/field/tree/field[@name='name']" position="after">

<field name="pdt_country"/>


<xpath expr="/form/sheet/notebook/page/field/tree/field[@name='name']" position="before">

<field name="line_no"/>

<!-- <field name="sequence_no" on_change="onchange_line(sequence_no)"/> -->




Solanki Shamji
On 4/28/15, 3:01 AM


Due to constraint we cant repeat the sequence. You can try with other fields.



Other field means? which field

on 4/28/15, 3:10 AM

Then How to change my code...

on 4/28/15, 3:11 AM

Can You Explain breifly...

on 4/28/15, 3:34 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

1 follower(s)


Asked: 3/26/15, 8:24 AM
Seen: 1643 times
Last updated: 5/25/15, 8:42 AM