コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
10239 ビュー

Hello Friends,

I am new in Odoo 8. I want to add Sr.No. sales order line. While adding items in sale order Sr.no. should auto increment from 1.

Plz Give Solution for it.

thanks in advanced

アバター
破棄
最善の回答

Try Below code ...


class sale_order_line(osv.Model):

_inherit='sale.order.line'

  def _get_line_numbers(self, cr, uid, ids, fields, arg, context=None):

"""Assign sequential numbers to line items, starting at 1"""

if context is None: context = {}

res = {}

line_num = 1

# Take the first line in the order, find the root PO, then iterate through all

# PO line items to sequence them properly

#

  first_line_rec = self.browse(cr, uid, ids, context=context)[0]

for line_rec in first_line_rec.order_id.order_line:

res[line_rec.id] = line_num

line_num += 1

return res

_columns={

'sequence': fields.integer('Sequence'),

# TODO: Consider making this a stored field to save on read time

'line_no': fields.function(_get_line_numbers, type='integer', string='Line Number'),



XMl-----------------


<record id="view_order_form_double_validation" model="ir.ui.view">

            <field name="name">sale.order.form</field>

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

            <field name="inherit_id" ref="sale.view_order_form"/>

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

            

               

<xpath expr="//field[@name='order_line']/tree/field[@name='product_id']" position="before">

                     

                       <field name="sequence" widget="handle"/> 

            <field name="line_no" string="Line No"/>

                      

                </xpath>

Please upvote   my answer if resolved your issue          

アバター
破棄
最善の回答

You should consider using the sequence in SO line. You need to create a sequence and sequence code.Go through the following links:

http://www.zbeanztech.com/blog/sequence-openerp

https://matiar.wordpress.com/2011/09/29/sequence-in-openerp/

http://pinakinnayi.blogspot.in/2012/05/auto-number-generate-in-openerp.html

アバター
破棄
関連投稿 返信 ビュー 活動
1
11月 22
3582
0
6月 21
6139
0
3月 21
2939
2
1月 20
22008
2
5月 18
4229