Tuesday, 3 June 2014

How to add new field in Delivery Orders or in shipments

I sufferd from this problem. I was trying to add new field in Delivery Order ,but it was disappearing from the view.
  So I thought to share it with you guys.
To add new field in Delivery Orders ex-'delivery_tracking' -
   inherit stock.picking.out and normal stock.picking with both having the fields.
Means you need to add your custom field in both stock.picking and stock.picking.out.

class stock_picking(osv.osv):
    _inherit = "stock.picking"
    _columns={
            'delivery_tracking': fields.char('Delivery Tracking' , size=32), # Your custom field

            }

class stock_picking_out(osv.osv):
    _inherit = "stock.picking.out"
    _columns={
            'delivery_tracking': fields.char('Delivery Tracking' , size=32), # Your custom field

            }
           

Now in xml, inherit Delivery view and add your custom field

<record id="view_stock_picking_out_extended" model="ir.ui.view">
    <field name="name">stock.picking.out.extended.form</field>
    <field name="model">stock.picking.out</field>
    <field name="inherit_id" ref="stock.view_picking_out_form"/>
    <field name="arch" type="xml">
            <field name="backorder_id" position="after">
                <field name="delivery_tracking" ><!-- Your custom field -->
            </field>
    </field>
</record>

The same applies for shipment view

Thanks
Sonu Chaudhary

No comments:

Post a Comment