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 fields to stock picking form and tree

By
kaynis
on 8/30/13, 5:32 AM 3,769 views

Hi All, Using V6 on windows I am trying to add a field to products on the Stock Move string in Product page/tab inside Delivery Order but the field is not displaying even though the module I created loaded without errors. My .py and xml code are below. The python is still in development and will add on_change function later to the class. Help please. Thank you in advance

  class order_line_picking_list(osv.osv):
      _name = 'order.line.picking.list'
      _inherit = 'stock.picking'
      _columns = {
    'picking_labels': fields.many2one('label.maker','Label',select=True, help='label for the product on the picking list'),

}
  order_line_picking_list()

  class stock_move(osv.osv): 
      _name = 'stock.move'
      _inherit = 'stock.move'
      _columns = {
    'picking_labels': fields.many2one('label.maker','Label',select=True, help='label for the product on the picking list'),
}
  stock_move()

  <openerp>
      <data>
  <record model="ir.ui.view" id="view_order_line_picking_list_form">
        <field name="name">order.line.picking.list.form</field>
        <field name="model">stock.picking</field>
        <field name="inherit_id" ref="stock.view_picking_form"/>
        <field name="arch" type="xml">
            <data>
                <xpath expr="/form/notebook/page/field[@name='move_lines']/form/field[@name='product_qty' ]" position="after">
                    <field name="picking_labels" />
                </xpath>
                <xpath expr="/form/notebook/page/field[@name='move_lines']/tree[@string='Stock Moves']/field[@name='product_qty']" position="after">
                    <field name="picking_labels" />
                </xpath>
            </data>
        </field>
    </record>

    <record model="ir.ui.view" id="view_order_line_picking_list_tree">
        <field name="name">order.line.picking.list.form.in</field>
        <field name="model">stock.picking.in</field>
        <field name="view_type">form</field>
        <field name="inherit_id" ref="stock.view_picking_in_form"/>
        <field name="arch" type="xml">
            <field name="product_qty" position="before">
                <field name="picking_labels"/>
            </field>
        </field>
    </record>

    <record id="view_move_form_inherit" model="ir.ui.view">
        <field name="name">stock.move.form.out</field>
        <field name="model">stock.picking.out</field>
        <field name="view_type">form</field>
        <field name="inherit_id" ref="stock.view_picking_out_form"/>
        <field name="arch" type="xml">
            <field name="product_qty" position="before">
                <field name="picking_labels"/>
            </field>
        </field>
    </record> 

     </data>
    </openerp>
0
kaynis
On 8/30/13, 9:15 AM

Solve it these are all the views that I needed

    <record model='ir.ui.view' id='stock_move_form_view'>
        <field name='name'>Stock Move Form Inherit</field>
        <field name='model'>stock.move</field>
        <field name='inherit_id' ref='stock.view_move_form'/>
        <field name='arch' type='xml'>
            <data>
                <field name="product_qty" position="after">
                    <field name="picking_labels"/>
                </field>
            </data>                
        </field>
    </record>

    <record id="view_stock_move_7" model="ir.ui.view">
        <field name="name">stock.move.tree.inherit7</field>
        <field name="model">stock.move</field>
        <field name="inherit_id" ref="stock.view_move_tree"/>
        <field name="arch" type="xml">
            <data>
                <field name="product_qty" position="after">
                    <field name="picking_labels"/>
                </field>
            </data>
        </field>
    </record>

    <record model="ir.ui.view" id="view_order_line_picking_list_tree">
        <field name="name">order.line.picking.list.form.in</field>
        <field name="model">stock.picking</field>
        <field name="view_type">form</field>
        <field name="inherit_id" ref="stock.view_picking_in_form"/>
        <field name="arch" type="xml">
            <data>
                <field name="product_qty" position="before">
                    <field name="picking_labels"/>
                </field>
                <xpath expr="/form/notebook/page/field[@name='move_lines']/form/field[@name='state']" position="before">
                   <field name="picking_labels"/>
                </xpath>
            </data>
        </field>
    </record>

    <record id="view_move_form_inherit" model="ir.ui.view">
        <field name="name">stock.move.form.out</field>
        <field name="model">stock.picking</field>
        <field name="view_type">form</field>
        <field name="inherit_id" ref="stock.view_picking_out_form"/>
        <field name="arch" type="xml">
            <data>
                <field name="product_qty" position="before">
                    <field name="picking_labels"/>
                </field>
                <xpath expr="/form/notebook/page/field[@name='move_lines']/form/field[@name='state']" position="before">
                   <field name="picking_labels"/>
                </xpath>
            </data> 
        </field>
    </record>     

    <record model="ir.ui.view" id="view_order_line_labels_list_form">
        <field name="name">order.line.labels.list.form</field>
        <field name="model">stock.picking</field>
        <field name="inherit_id" ref="stock.view_picking_form"/>
        <field name="type">form</field>
        <field name="arch" type="xml">
            <data>
                <xpath expr="//tree/field[@name='product_qty' ]" position="before">
                    <field name="picking_labels" />
                </xpath>
                <xpath expr="/form/notebook/page/field[@name='move_lines']/form/field[@name='state']" position="before">
                   <field name="picking_labels"/>
                </xpath>
            </data>
        </field>
    </record>

The Same Thing I Did :-) I herited stock picking, and i add one m2o field (lead_id:m2o to crm.lead) When Sale order confirmed the incoming shipments will get create :-) while creating IS i want to populate the lead_id from SO to IS(both places i ve created lead_id field). My prob is lead id is not displying in front end but storing in backend Any help???

Arun
on 9/7/13, 10:51 AM
0

what is the error message??

in your xpath u can simply write <xpath expr="//field[@name='product_qty' ]" position="after"> <field name="picking_labels" /> </xpath>

Lady Sharmane Udtuhan
on 8/30/13, 8:16 AM

no error just not displaying the field. Thanks for responding

kaynis
on 8/30/13, 8:52 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: 8/30/13, 5:32 AM
Seen: 3769 times
Last updated: 3/16/15, 8:10 AM