[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:
Gery Debongnie 2014-05-07 15:41:34 +02:00
parent e83709bdcc
commit c13b9a1262
1 changed files with 5 additions and 8 deletions

View File

@ -615,15 +615,12 @@ class product_template(osv.osv):
class product_product(osv.osv): class product_product(osv.osv):
_inherit="product.product" _inherit="product.product"
def _orderpoint_count(self, cr, uid, ids, field_name, arg, context=None): def _orderpoint_count(self, cr, uid, ids, field_name, arg, context=None):
res = dict(map(lambda x: (x,0), ids)) OrderPoints = self.pool('stock.warehouse.orderpoint')
try: return {
for orderpoint in self.browse(cr, uid, ids, context=context): product_id: OrderPoints.search_count(cr, uid, [('product_id', '=', product_id)], context=context)
res[orderpoint.id] = len(orderpoint.orderpoint_ids) for product_id in ids
except: }
pass
return res
_columns = { _columns = {
'orderpoint_ids': fields.one2many('stock.warehouse.orderpoint', 'product_id', 'Minimum Stock Rules'),
'orderpoint_count': fields.function(_orderpoint_count, string='# Orderpoints', type='integer'), 'orderpoint_count': fields.function(_orderpoint_count, string='# Orderpoints', type='integer'),
} }