Se rendre au contenu
Menu
Cette question a été signalée
2 Réponses
14563 Vues

Hi am a new bee to OpenERP , i would like to do few additions to my current Delivery Order & Incoming Shipment modules , but am confused (stock.move, stock.picking,stock.picking.in,stock.picking.out etc...etc...) with the structure of the view and the way it is inherited in several other modules.

  1. How to add new fields in to 'Additional Info' page of Incoming Shipment and Delivery Order modules?

  2. How to enable 'product description column in both Incoming Shipment & Delivery Order modules?

I had an attempt to do this by creating a separate module that depends on module 'stock' but no changes happens to my view . Can anyone please point out the issue in my .xml ,.py etc... files , any help is appreciated .

Here is my source for reference :

stock.py

from openerp.osv import fields, osv

class stock_picking(osv.osv):

_inherit = "stock.picking"

_columns = {
            'po_number': fields.char('Customer PO#', size=25),
            'po_date': fields.date('Customer PO Date')
            }

stock_view.xml

  <?xml version="1.0" encoding="utf-8"?>
  <openerp>
  <data>
    <record model="ir.ui.view" id="view_picking_form2">
        <field name="name">stock.picking.form2</field>
        <field name="model">stock.picking</field>
        <field name="inherit_id" ref="stock.view_picking_form"/>
        <field name="arch" type="xml">
                <xpath expr="//group/field[@name='move_type']" position='before'>
                <field name="po_number"/>
                <field name="po_date"/>
               </xpath>
        </field>
    </record>

    <record model="ir.ui.view" id="view_move_picking_tree2">
        <field name="name">stock.picking.tree2</field>
        <field name="model">stock.picking</field>
        <field name="inherit_id" ref="stock.view_move_picking_form"/>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='move_line']/tree/field[@name='product_id']" position="after">
                <field name="name"/>
            </xpath>
        </field>
    </record>
</data>

</openerp>

Avatar
Ignorer
Meilleure réponse

Hello nishad,

You have to inherit 'stock.picking.in' & 'stock.picking.out', As you want to display the fields in Incoming Shipment and Delivery Order.

  • 'stock.picking.in' used to display Incoming Shipment
  • 'stock.picking.out' used to display Delivery Order

Write following code in .py file:

 class stock_picking_in(osv.osv):

    _inherit = "stock.picking.in"
    _columns = {
        'po_number': fields.char('Customer PO#', size=25),
        'po_date': fields.date('Customer PO Date')
    }

class stock_picking_out(osv.osv):

    _inherit = "stock.picking.out"
    _columns = {
        'po_number': fields.char('Customer PO#', size=25),
        'po_date': fields.date('Customer PO Date')
    }

And in .xml file write:

    <record model="ir.ui.view" id="view_picking_form21">
            <field name="name">stock.picking.form21</field>
            <field name="model">stock.picking.in</field>
            <field name="inherit_id" ref="stock.view_picking_form"/>
            <field name="arch" type="xml">
                <field name="move_type" position='before'>
                    <field name="po_number"/>
                    <field name="po_date"/>
                </field>
            </field>
        </record>

        <record model="ir.ui.view" id="view_picking_form22">
            <field name="name">stock.picking.form22</field>
            <field name="model">stock.picking.out</field>
            <field name="inherit_id" ref="stock.view_picking_form"/>
            <field name="arch" type="xml">
                <field name="move_type" position='before'>
                    <field name="po_number"/>
                    <field name="po_date"/>
                </field>
            </field>
        </record>

        <record id="view_stock_move_1" model="ir.ui.view">
            <field name="name">stock.move.tree.inherit5</field>
            <field name="model">stock.move</field>
            <field name="inherit_id" ref="stock.view_move_picking_tree"/>
            <field name="arch" type="xml">
                <field name="product_id" position="after">
                    <field name="name"/>
                </field>
            </field>
        </record>

Here to display the description of product we have to inherit the tree view of 'stock.move'.

Thank You.

Avatar
Ignorer

Hello Sir, I've products with different attributes and when I place a purchase order for a product i need the product attributes to be displayed on the incoming shipments form. Please suggest me how can i do this

Hello Sampath, You can find a _prepare_order_picking() method in purchase.py, This function will be called when you confirm the purchase order. Here pass the value for your new field. Define this custom field in stock.picking object.

Auteur Meilleure réponse

Thanks hiral for your effort to figure out exact way of inheriting the view , but a small change to the source . Instead of inheriting

field name="inherit_id" ref="stock.view_picking_form we need to inherit

field name="inherit_id"ref="stock.view_picking_in_form" for Incoming shipment &

field name="inherit_id" ref="stock.view_picking_out_form" for Delivery Order .

Thanks .....

Avatar
Ignorer

We can use 'stock.view_picking_in_form' & 'stock.view_picking_out_form' as both inherit's the view 'view_picking_form'. Thanks for correction. :)

Auteur

Hi Hiral , its works fine for adding columns , fields etc.... but it shown an attribute error while am using that field in report =>File "/home/nishad/Downloads/openerp-7.0-20130630-231044/openerp/osv/orm.py", line 487, in __getattr__ raise AttributeError(e) AttributeError: 'po_date'

Hi Nishad, did you got a solution for report print even i'm facing the same problem. If you have got a solution can you please help me out in getting the solution

Publications associées Réponses Vues Activité
0
mars 15
4814
0
mai 24
1574
1
mars 15
5298
0
mars 15
3324
0
mars 15
3756