summaryrefslogtreecommitdiff
path: root/addons/product
diff options
context:
space:
mode:
authorSimon Lejeune <sle@openerp.com>2019-05-10 14:11:32 +0000
committerSimon Lejeune <sle@openerp.com>2019-06-09 14:11:36 +0000
commit0477bdb75afafa62b204f29e9dbfc3fc5fd012d4 (patch)
tree1e343e8d9a27cb2c7f0f3c8ac2d5871b318c68e2 /addons/product
parent72693c1d0a6e1053fceed4154c8d46c11917d4a3 (diff)
[REF] product, stock_account, etc: remove product.price.history table
This table tracked standard price changes. It was used to compute the valuation at date in AVCO and standard through `get_history_price`. The next commits will introduce the stock valuation layers, separating the valuation from the stock move. As a valuation layer will be created when a standard price is updated on the product or when a stock move impacts the valuation, the information from this table will be duplicated. We don't plan to adapt `get_history_price` to work with the valuation layer since the valuation report at date and today will be the same: a grouped list on the valuation layers with eventually a domain on the date. task-1875873
Diffstat (limited to 'addons/product')
-rw-r--r--addons/product/models/product.py44
-rw-r--r--addons/product/security/ir.model.access.csv2
2 files changed, 0 insertions, 46 deletions
diff --git a/addons/product/models/product.py b/addons/product/models/product.py
index a8df285d257..936b3350f54 100644
--- a/addons/product/models/product.py
+++ b/addons/product/models/product.py
@@ -63,23 +63,6 @@ class ProductCategory(models.Model):
return self.create({'name': name}).name_get()[0]
-class ProductPriceHistory(models.Model):
- """ Keep track of the ``product.template`` standard prices as they are changed. """
- _name = 'product.price.history'
- _rec_name = 'datetime'
- _order = 'datetime desc'
- _description = 'Product Price List History'
-
- def _get_default_company_id(self):
- return self._context.get('force_company', self.env.company.id)
-
- company_id = fields.Many2one('res.company', string='Company',
- default=_get_default_company_id, required=True)
- product_id = fields.Many2one('product.product', 'Product', ondelete='cascade', required=True)
- datetime = fields.Datetime('Date', default=fields.Datetime.now)
- cost = fields.Float('Cost', digits=dp.get_precision('Product Price'))
-
-
class ProductProduct(models.Model):
_name = "product.product"
_description = "Product"
@@ -386,10 +369,6 @@ class ProductProduct(models.Model):
@api.model_create_multi
def create(self, vals_list):
products = super(ProductProduct, self.with_context(create_product_product=True)).create(vals_list)
- for product, vals in zip(products, vals_list):
- # When a unique variant is created from tmpl then the standard price is set by _set_standard_price
- if not (self.env.context.get('create_from_tmpl') and len(product.product_tmpl_id.product_variant_ids) == 1):
- product._set_standard_price(vals.get('standard_price') or 0.0)
# `_get_variant_id_for_combination` depends on existing variants
self.clear_caches()
self.env['product.template'].invalidate_cache(
@@ -406,10 +385,7 @@ class ProductProduct(models.Model):
@api.multi
def write(self, values):
- ''' Store the standard price change in order to be able to retrieve the cost of a product for a given date'''
res = super(ProductProduct, self).write(values)
- if 'standard_price' in values:
- self._set_standard_price(values['standard_price'])
if 'attribute_value_ids' in values:
# `_get_variant_id_for_combination` depends on `attribute_value_ids`
self.clear_caches()
@@ -686,31 +662,11 @@ class ProductProduct(models.Model):
return prices
-
# compatibility to remove after v10 - DEPRECATED
@api.multi
def price_get(self, ptype='list_price'):
return self.price_compute(ptype)
- @api.multi
- def _set_standard_price(self, value):
- ''' Store the standard price change in order to be able to retrieve the cost of a product for a given date'''
- PriceHistory = self.env['product.price.history']
- for product in self:
- PriceHistory.create({
- 'product_id': product.id,
- 'cost': value,
- 'company_id': self._context.get('force_company', self.env.company.id),
- })
-
- @api.multi
- def get_history_price(self, company_id, date=None):
- history = self.env['product.price.history'].search([
- ('company_id', '=', company_id),
- ('product_id', 'in', self.ids),
- ('datetime', '<=', date or fields.Datetime.now())], order='datetime desc,id desc', limit=1)
- return history.cost or 0.0
-
@api.model
def get_empty_list_help(self, help):
self = self.with_context(
diff --git a/addons/product/security/ir.model.access.csv b/addons/product/security/ir.model.access.csv
index 5af96e9dfa9..19aa27fa1bc 100644
--- a/addons/product/security/ir.model.access.csv
+++ b/addons/product/security/ir.model.access.csv
@@ -7,7 +7,6 @@ access_product_pricelist_user,product.pricelist.user,model_product_pricelist,bas
access_product_pricelist_item_user,product.pricelist.item.user,model_product_pricelist_item,base.group_user,1,0,0,0
access_product_pricelist_partner_manager,product.pricelist partner manager,model_product_pricelist,base.group_partner_manager,1,0,0,0
access_product_product_employee,product.product employee,model_product_product,base.group_user,1,0,0,0
-access_product_price_history_employee,prices.history employee,model_product_price_history,base.group_user,1,0,0,0
access_product_attribute,product.attribute,model_product_attribute,base.group_user,1,0,0,0
access_product_attribute_value,product.attribute value,model_product_attribute_value,base.group_user,1,0,0,0
access_product_product_attribute,product.template.attribute value,model_product_template_attribute_value,base.group_user,1,0,0,0
@@ -20,7 +19,6 @@ access_product_supplierinfo_manager,product.supplierinfo.manager,model_product_s
access_product_pricelist_manager,product.pricelist.manager,model_product_pricelist,base.group_system,1,1,1,1
access_product_pricelist_item_manager,product.pricelist.item.manager,model_product_pricelist_item,base.group_system,1,1,1,1
access_product_product_manager,product.product manager,model_product_product,base.group_system,1,1,1,1
-access_product_price_history_manager,prices.history manager,model_product_price_history,base.group_system,1,1,1,1
access_product_attribute_manager,product.attribute manager,model_product_attribute,base.group_system,1,1,1,1
access_product_attribute_value_manager,product.attribute value manager,model_product_attribute_value,base.group_system,1,1,1,1
access_product_product_attribute_manager,product.template.attribute value manager,model_product_template_attribute_value,base.group_system,1,1,1,1