Comment 1 for bug 996816

Revision history for this message
Amit Parik (amit-parik) wrote :

Hello qdp,

I have checked your scenario but I think this is not a bug it's behaviour of framework.

You have created a new table(object) through _inherit with another name (stock_picking_in) and main object is stock_picking. Then you have inherit the stock.picking object again (for adding purchase_id field) because you have to set a one2many field picking_ids on purchase order. But here you have assigned a object stock_picking_in (on one2many field). That's it's purchase_id required on stock_picking_in because after inherits the stock.picking it's never affected on stock_picking_in

The reason when mail stock.picking is loaded (stock.py) at that time purchase_id doesn't exist on stock.picking. Then we have _inherit this object with new name, So It will create a new table which consider all the field of stock.picking and add extra-field (Which you have assigned on stock.picking.in) , now both object are loaded. After that on purchase/stock.py you have inherit stock_picking main object and add purchase_id, So It will affect only stock.picking object not the stock.picking.in (which you want). That's why purchase_id doesn't found on stock.picking.in and you have to add it on stock.picking.in.

One most important thing which is the sequence (time of your table creation) of module loading. If you first inherit the stock.picking with adding a purchase_id after that you have create a new table through _inherit with another name this time you are able to see purchase_id on both object.

I am giving you a one small example, I think which is more helpfull.

Class test_test(osv.osv):
_name = test.test
 _columns = {
     'number': fields.integer(string='Number', readonly=True, help="List OF Address"),
     'name': fields.char('Name', size=64, required=True, select=True, help="unique number of the purchase order,computed automatically when the purchase order is created"),
        'test' : fields.many2one('res.users', 'Manange by', readonly=True),
     }