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}">