Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
5 Respostas
8208 Visualizações

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
Cancelar
Melhor resposta

Hello,

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

Thanks.

Shamji.

Avatar
Cancelar
Autor

Other field means? which field

Autor

Then How to change my code...

Autor

Can You Explain breifly...

Melhor resposta

Reffer This Link add serial no in sale order line odoo 

Avatar
Cancelar