[IMP] product: computes can be written in batch.

When the value is the same for all records, the write can be done in 
batch, this can lead to a "slight" performance improvement, depending on 
write overrides, and how the value was computed for each line.
This commit is contained in:
Victor Feyens
2020-03-26 10:27:57 +00:00
parent f93965130c
commit 097b64075a
2 changed files with 5 additions and 10 deletions
+1 -2
View File
@@ -220,8 +220,7 @@ class ProductProduct(models.Model):
product.combination_indices = product.product_template_attribute_value_ids._ids2str()
def _compute_is_product_variant(self):
for product in self:
product.is_product_variant = True
self.is_product_variant = True
@api.depends_context('pricelist', 'partner', 'quantity', 'uom', 'date', 'no_variant_attributes_price_extra')
def _compute_product_price(self):
+4 -8
View File
@@ -173,8 +173,7 @@ class ProductTemplate(models.Model):
@api.depends_context('company')
def _compute_cost_currency_id(self):
for template in self:
template.cost_currency_id = self.env.company.currency_id.id
self.cost_currency_id = self.env.company.currency_id.id
def _compute_template_price(self):
prices = self._compute_template_price_no_inverse()
@@ -259,8 +258,7 @@ class ProductTemplate(models.Model):
template.weight = 0.0
def _compute_is_product_variant(self):
for template in self:
template.is_product_variant = False
self.is_product_variant = False
@api.depends('product_variant_ids.barcode')
def _compute_barcode(self):
@@ -329,12 +327,10 @@ class ProductTemplate(models.Model):
return self._get_volume_uom_id_from_ir_config_parameter().display_name
def _compute_weight_uom_name(self):
for template in self:
template.weight_uom_name = self._get_weight_uom_name_from_ir_config_parameter()
self.weight_uom_name = self._get_weight_uom_name_from_ir_config_parameter()
def _compute_volume_uom_name(self):
for template in self:
template.volume_uom_name = self._get_volume_uom_name_from_ir_config_parameter()
self.volume_uom_name = self._get_volume_uom_name_from_ir_config_parameter()
def _set_weight(self):
for template in self: