[FIX] code cleanup (addon procurement)
improves the _orderpoint_count method. Also, as a bonus, the preexisting orderpoint_ids is not used in any other place, so it can be removed as well bzr revid: ged@openerp.com-20140507134134-isaor8ulq4pf5wrt
This commit is contained in:
parent
e83709bdcc
commit
c13b9a1262
|
@ -615,15 +615,12 @@ class product_template(osv.osv):
|
|||
class product_product(osv.osv):
|
||||
_inherit="product.product"
|
||||
def _orderpoint_count(self, cr, uid, ids, field_name, arg, context=None):
|
||||
res = dict(map(lambda x: (x,0), ids))
|
||||
try:
|
||||
for orderpoint in self.browse(cr, uid, ids, context=context):
|
||||
res[orderpoint.id] = len(orderpoint.orderpoint_ids)
|
||||
except:
|
||||
pass
|
||||
return res
|
||||
OrderPoints = self.pool('stock.warehouse.orderpoint')
|
||||
return {
|
||||
product_id: OrderPoints.search_count(cr, uid, [('product_id', '=', product_id)], context=context)
|
||||
for product_id in ids
|
||||
}
|
||||
_columns = {
|
||||
'orderpoint_ids': fields.one2many('stock.warehouse.orderpoint', 'product_id', 'Minimum Stock Rules'),
|
||||
'orderpoint_count': fields.function(_orderpoint_count, string='# Orderpoints', type='integer'),
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue