+ def _is_product_variant(self, cr, uid, ids, name, arg, context=None):
+ return self._is_product_variant_impl(cr, uid, ids, name, arg, context=context)
+
+ def _is_product_variant_impl(self, cr, uid, ids, name, arg, context=None):
+ return dict.fromkeys(ids, False)
+
+ def _product_template_price(self, cr, uid, ids, name, arg, context=None):
+ plobj = self.pool.get('product.pricelist')
+ res = {}
+ quantity = context.get('quantity') or 1.0
+ pricelist = context.get('pricelist', False)
+ partner = context.get('partner', False)
+ if pricelist:
+ # Support context pricelists specified as display_name or ID for compatibility
+ if isinstance(pricelist, basestring):
+ pricelist_ids = plobj.name_search(
+ cr, uid, pricelist, operator='=', context=context, limit=1)
+ pricelist = pricelist_ids[0][0] if pricelist_ids else pricelist
+
+ if isinstance(pricelist, (int, long)):
+ products = self.browse(cr, uid, ids, context=context)
+ qtys = map(lambda x: (x, quantity, partner), products)
+ pl = plobj.browse(cr, uid, pricelist, context=context)
+ price = plobj._price_get_multi(cr,uid, pl, qtys, context=context)
+ for id in ids:
+ res[id] = price.get(id, 0.0)
+ for id in ids:
+ res.setdefault(id, 0.0)
+ return res
+
+ def get_history_price(self, cr, uid, product_tmpl, company_id, date=None, context=None):
+ if context is None:
+ context = {}
+ if date is None:
+ date = time.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
+ price_history_obj = self.pool.get('product.price.history')
+ history_ids = price_history_obj.search(cr, uid, [('company_id', '=', company_id), ('product_template_id', '=', product_tmpl), ('datetime', '<=', date)], limit=1)
+ if history_ids:
+ return price_history_obj.read(cr, uid, history_ids[0], ['cost'], context=context)['cost']
+ return 0.0
+
+ def _set_standard_price(self, cr, uid, product_tmpl_id, value, context=None):
+ ''' Store the standard price change in order to be able to retrieve the cost of a product template for a given date'''
+ if context is None:
+ context = {}
+ price_history_obj = self.pool['product.price.history']
+ user_company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id
+ company_id = context.get('force_company', user_company)
+ price_history_obj.create(cr, uid, {
+ 'product_template_id': product_tmpl_id,
+ 'cost': value,
+ 'company_id': company_id,
+ }, context=context)
+
+ def _get_product_variant_count(self, cr, uid, ids, name, arg, context=None):
+ res = {}
+ for product in self.browse(cr, uid, ids):
+ res[product.id] = len(product.product_variant_ids)
+ return res
+