Add ability to put a key in ctx to disable generation of a price history line

This commit is contained in:
Alexis de Lattre
2016-03-11 14:41:42 +01:00
parent e22b56c7a9
commit 753333521f

View File

@@ -42,16 +42,17 @@ class ProductTemplate(orm.Model):
retrieve the cost of a product template for a given date''' retrieve the cost of a product template for a given date'''
if context is None: if context is None:
context = {} context = {}
price_history_obj = self.pool['product.price.history'] if not context.get('dont_create_price_history'):
user_company = self.pool['res.users'].browse( price_history_obj = self.pool['product.price.history']
cr, uid, uid, context=context).company_id.id user_company = self.pool['res.users'].browse(
company_id = context.get('force_company', user_company) cr, uid, uid, context=context).company_id.id
price_history_obj.create(cr, SUPERUSER_ID, { company_id = context.get('force_company', user_company)
'product_template_id': product_tmpl_id, price_history_obj.create(cr, SUPERUSER_ID, {
'cost': value, 'product_template_id': product_tmpl_id,
'company_id': company_id, 'cost': value,
'origin': context.get('product_price_history_origin', False), 'company_id': company_id,
}, context=context) 'origin': context.get('product_price_history_origin', False),
}, context=context)
def create(self, cr, uid, vals, context=None): def create(self, cr, uid, vals, context=None):
product_template_id = super(ProductTemplate, self).create( product_template_id = super(ProductTemplate, self).create(