diff --git a/addons/product/models/product.py b/addons/product/models/product.py index 610c10dd364..5f80efc0538 100644 --- a/addons/product/models/product.py +++ b/addons/product/models/product.py @@ -327,6 +327,7 @@ class ProductProduct(models.Model): if 'active' in values: # prefetched o2m have to be reloaded (because of active_test) # (eg. product.template: product_variant_ids) + self.flush() self.invalidate_cache() # `_get_first_possible_variant_id` depends on variants active state self.clear_caches() diff --git a/addons/product/models/product_attribute.py b/addons/product/models/product_attribute.py index 67404628f80..5ad2032a7c9 100644 --- a/addons/product/models/product_attribute.py +++ b/addons/product/models/product_attribute.py @@ -247,6 +247,7 @@ class ProductTemplateAttributeLine(models.Model): values['value_ids'] = [(5, 0, 0)] res = super(ProductTemplateAttributeLine, self).write(values) if 'active' in values: + self.flush() self.env['product.template'].invalidate_cache(fnames=['attribute_line_ids']) # If coming from `create`, no need to update the values and the variants # before all lines are created. diff --git a/addons/product/models/product_pricelist.py b/addons/product/models/product_pricelist.py index 55dad257b77..8c37bb1cef5 100644 --- a/addons/product/models/product_pricelist.py +++ b/addons/product/models/product_pricelist.py @@ -592,5 +592,6 @@ class PricelistItem(models.Model): res = super(PricelistItem, self).write(values) # When the pricelist changes we need the product.template price # to be invalided and recomputed. + self.flush() self.invalidate_cache() return res diff --git a/addons/product/models/product_template.py b/addons/product/models/product_template.py index 5bd332f7508..86bcf24abc8 100644 --- a/addons/product/models/product_template.py +++ b/addons/product/models/product_template.py @@ -595,6 +595,7 @@ class ProductTemplate(models.Model): # (eg. product.template: product_variant_ids) # We can't rely on existing invalidate_cache because of the savepoint # in _unlink_or_archive. + self.flush() self.invalidate_cache() return True