On my class folder a have many goods and many amounts. I need to use a domain filter on my field good_id of class amount, on that field I need to show the list of my object folder's goods.
so I create a function on my amount class (_get_folder_list_goods) that returns the list of folder's goods and I add a domain attribute on my field good_id of class amount.
here are my classes:
class folder(osv.osv):
_name = 'folder'
_columns = {
'name' : fields.char(u'Numéro',size=50, readonly=True),
'goods_ids': fields.many2many('good', 'doss_bien_rel', 'folder_id', 'good_id', 'Goods'),
'amount_id': fields.one2many('amount', 'folder_id', 'Amounts'),
....}
class good(osv.osv):
_name = 'good'
_columns = {
'name' : fields.function(_name_get_fnc, type="char", string=u''),
....}
class amount(osv.osv):
_name = 'amount'
def _get_folder_list_biens(self, cr, uid,folder_id, context={}):
liste_goods=[]
object_folder = self.pool.get('folder').browse(cr,uid,folder_id,context)
if object_folder.goods_ids:
for good in object_folder.goods_ids:
liste_goods.append(good.id)
return liste_goods
_columns = {
'folder_id': fields.many2one('folder', 'Ref folder', select=True),
'good_id':fields.many2one('good', Goos',domain="[('id', 'in', _get_folder_list_biens(folder_id))]"),
}
I got this error:
Uncaught Error: NameError: name '_get_folder_list_biens' is not defined