Openerp set default value of popup form from one2many field parent

class definition (shop.py), please note the magic active_id


class item(osv.osv):
_name = "shop.item"
_columns = {
"item_id": fields.many2one("shop.cart", "Cart"),
}
_defaults = {
"item_id": lambda self, cr, uid, c: c.get('item_id', False),
}

class cart(osv.osv):
_name = “shop.cart”
_columns = {
“item_ids”: one2many(“shop.item”, “item_id”, “Items”),
}

In the view definition for the one2many field (shop_view.xml)

<field name=”item_ids” domain=”[‘item_id’, ‘=’, active_id]” context=”{‘item_id’: active_id}” />

 

Advertisements

common openerp beginner error

This code <field name="type"> form</field> produce the error below


The value " form " for the field "type" is not in the selection

make sure no space between “form”


the field(s) res_model,src_model: Invalid model name in the action definition.

if the code seem rights. restart the openerp-server.