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 to add sequences number in Purchase order Line with custom module?

By
Odoo
on 3/26/15, 8:24 AM 1,013 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'

_columns={

'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"?>

<openerp>

<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>

<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>

</record>

</data>

</openerp>

==================================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>

<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)"/> -->

</xpath>

</field>

</record>

1

Solanki Shamji

--Solanki Shamji--
1293
| 5 2 6
Baroda, India
--Solanki Shamji--

Hello!

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

Hello,

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

Thanks.

Shamji.

Other field means? which field

Odoo
on 4/28/15, 3:10 AM

Then How to change my code...

Odoo
on 4/28/15, 3:11 AM

Can You Explain breifly...

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

1 follower(s)

Stats

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