73
73
class product_attributes(osv.osv):
74
74
_inherit = "product.product"
76
def _get_list_sublist(self, cr, uid, ids, field_name, arg, context={}):
78
Returns all lists/sublists where the product is in
83
if isinstance(ids, (long,int)):
88
for product in self.browse(cr, uid, ids, context=context):
90
line_ids = self.pool.get('product.list.line').search(cr, uid, [('name', '=', product.id)], context=context)
91
for line in self.pool.get('product.list.line').browse(cr, uid, line_ids, context=context):
92
if line.list_id and line.list_id.id not in res[product.id]:
93
res[product.id].append(line.list_id.id)
97
def _search_list_sublist(self, cr, uid, obj, name, args, context={}):
99
Filter the search according to the args parameter
107
if arg[0] == 'list_ids' and arg[1] == '=' and arg[2]:
108
list = self.pool.get('product.list').browse(cr, uid, int(arg[2]), context=context)
109
for line in list.product_ids:
110
ids.append(line.name.id)
111
elif arg[0] == 'list_ids' and arg[1] == 'in' and arg[2]:
112
for list in self.pool.get('product.list').browse(cr, uid, arg[2], context=context):
113
for line in list.product_ids:
114
ids.append(line.name.id)
118
return [('id', 'in', ids)]
120
76
def _get_nomen(self, cr, uid, ids, field_name, args, context={}):
252
208
'removal_time': fields.integer('Product Removal Time',
253
209
help='The number of months before a production lot should be removed.'),
254
210
'alert_time': fields.integer('Product Alert Time', help="The number of months after which an alert should be notified about the production lot."),
255
'list_ids': fields.function(_get_list_sublist, fnct_search=_search_list_sublist,
256
type='many2many', relation='product.list', method=True, string='Lists'),
257
211
'nomen_ids': fields.function(_get_nomen, fnct_search=_search_nomen,
258
212
type='many2many', relation='product.nomenclature', method=True, string='Nomenclatures'),