Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
5 Risposte
8209 Visualizzazioni

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>

Avatar
Abbandona
Risposta migliore

Hello,

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

Thanks.

Shamji.

Avatar
Abbandona
Autore

Other field means? which field

Autore

Then How to change my code...

Autore

Can You Explain breifly...

Risposta migliore

Reffer This Link add serial no in sale order line odoo 

Avatar
Abbandona