I forgot to mention that the example field is in the stock.warehouse.orderpoint class. Here's the whole code:
class stock_warehouse_orderpoint(osv.osv):
_inherit = 'stock.warehouse.orderpoint'
def _is_internal(self, cr, uid, ids, name, args, context=None):
res = {}
for op in self.browse(cr, uid, ids, context=context): res[op.id] = False proc_loc_id = op.location_id.procurement_location_id parent_ids = self.search(cr, uid, [ ('location_id', '=', proc_loc_id.id), ('product_id', '=', op.product_id.id)])
if parent_ids: res[op.id] = True
return res
def _get_orderpoints(self, cr, uid, ids, context):
prod_ids = set()
for op in self.browse(cr, uid, ids): prod_ids.add(op.product_id.id)
return self.search(cr, uid, [('product_id', 'in', list(prod_ids))])
I forgot to mention that the example field is in the stock.warehouse .orderpoint class. Here's the whole code: _orderpoint( osv.osv) : warehouse. orderpoint'
class stock_warehouse
_inherit = 'stock.
def _is_internal(self, cr, uid, ids, name, args, context=None):
res[ op.id] = False
proc_ loc_id = op.location_ id.procurement_ location_ id
parent_ ids = self.search(cr, uid, [
('location_ id', '=', proc_loc_id.id),
('product_ id', '=', op.product_id.id)])
res[op. id] = True
res = {}
for op in self.browse(cr, uid, ids, context=context):
if parent_ids:
return res
def _get_orderpoint s(self, cr, uid, ids, context):
prod_ ids.add( op.product_ id.id)
prod_ids = set()
for op in self.browse(cr, uid, ids):
return self.search(cr, uid, [('product_id', 'in', list(prod_ids))])
def _get_locations( self, cr, uid, ids, context): get('stock. warehouse. orderpoint' )\
.search( cr, uid, [('location_id', 'in', ids)])
return self.pool.
_columns = { function( _is_internal, method=True, type='boolean',
string= 'Internal' , store={
'stock. warehouse. orderpoint' :
( _get_orderpoint s, ['location_id'], 10),
'stock. location' : (_get_locations, ['procurement_ location_ id'], 20),
#bug: deleting an orderpoint won't trigger recalculation of the
#other orderpoints with the same product_id
'internal': fields.
}),
}