Adding custom fields in stock.picking and inheriting view_picking_in_form

Asked by __vital on 2013-05-22

Hi.

I added custom field in stock.picking

class stock_picking(osv.osv):
    _name = "stock.picking"
    _inherit = "stock.picking"
    _description = "Picking List"
    _table="stock_picking"

    _columns = {
        'new_test_field' : fields.char('New value', size=64, help='New value help'),
    }

and than i try to show it in view_picking_in_form

<record id="view_picking_in_form_1" model="ir.ui.view">
            <field name="name">stock.picking.in.form_1</field>
            <field name="model">stock.picking.in</field>
            <field name="inherit_id" ref="stock.view_picking_in_form"/>
            <field name="arch" type="xml">
                    <notebook>
                        <page string="New page">
                            <field name="new_test_field"/>
                        </page>
                    </notebook>
            </field>
        </record>

and i have error

openerp.osv.orm: Can't find field 'new_test_field' in the following view parts composing the view of object model stock.picking': * stock.picking.form

What is wrong ?

Question information

Language:
English Edit question
Status:
Answered
For:
Odoo Addons (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Last query:
2013-05-22
Last reply:
2013-05-30

you need to add you field to both stock.picking and stock.picking.in models (and maybe to stock.picking.out too).

See the oldly placed comments about this in the delivery/stock.py.

Hello vital ,

You tried to add a new field in 'stock.picking' and you want this field in 'stock.picking.in' , so both the objects are different.

if you want to add in stock.picking.in you need to inherit stock.picking.in in your .py file.

so
class stock_picking(osv.osv):
    _name = "stock.picking"
    _inherit = "stock.picking" //this is wrong
    _inherit = "stock.picking.in" //try this

Thanks,
Bipin Rathod,
SerpentCS.

Hi Serpent,

Alexandre is right. In and out pickings are strongly integrated with stock.picking in an non-standard way, so that the normal way of extending does not apply. See https://bugs.launchpad.net/openobject-addons/+bug/1169998

Ah, missed this completely!
This won't help us in migrations we are going to do for our clients!
Thanks.

Guys,

What a mess!

I have been fighting to this issues since long in my migration of carriers.

Bipin, you could have told me earlier.

Thanks.

Dhirendra,

I am sorry, I myself was not aware.

I will tell you more when I am back to Indian office.

Thanks,
Bipin Rathod,
SerpentCS.

I also noticed that if you add a <button type="object" name="foobar"> on a stock.picking.out then the method must be defined on the stock.picking.out class. Defining it only on the stock.picking class won't work.

Can you help with this problem?

Provide an answer of your own, or ask __vital for more information if necessary.

To post a message you must log in.