summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAurélien Warnon <awa@odoo.com>2019-11-22 13:11:57 +0000
committerAurélien Warnon <awa@odoo.com>2019-11-25 08:38:03 +0000
commit34b1ceb942bc0ed3feed0fc53eccac3bbef49873 (patch)
tree5fc1dc979352c183c3a63006f3c315b1a9fafb25
parenta561e4cb562ff43242013e26e9394930f112830e (diff)
[FIX] website_slides: fix slide.slide statistics compute method triggers
The slide.slide "_compute_slides_statistics" method is missing the 'slide_ids.sequence' trigger. It should be specified for cases when one of the slide_ids changes category (determined by the sequence). This can cause some CacheMiss and seem related to nondeterministic errors on the runbot. PR #40705 Task#2123711 Runbot build error ID 247 closes odoo/odoo#40867 X-original-commit: 1994f544694051a767ecda88a12dee5c5579add2 Signed-off-by: awa-odoo <awa-odoo@users.noreply.github.com>
-rw-r--r--addons/website_slides/models/slide_slide.py2
-rw-r--r--addons/website_slides/tests/test_statistics.py15
2 files changed, 16 insertions, 1 deletions
diff --git a/addons/website_slides/models/slide_slide.py b/addons/website_slides/models/slide_slide.py
index d9fac8c5264..78296759ecc 100644
--- a/addons/website_slides/models/slide_slide.py
+++ b/addons/website_slides/models/slide_slide.py
@@ -267,7 +267,7 @@ class Slide(models.Model):
for slide in self:
slide.slide_views = mapped_data.get(slide.id, 0)
- @api.depends('slide_ids.slide_type', 'slide_ids.is_published', 'slide_ids.is_category')
+ @api.depends('slide_ids.sequence', 'slide_ids.slide_type', 'slide_ids.is_published', 'slide_ids.is_category')
def _compute_slides_statistics(self):
# Do not use dict.fromkeys(self.ids, dict()) otherwise it will use the same dictionnary for all keys.
# Therefore, when updating the dict of one key, it updates the dict of all keys.
diff --git a/addons/website_slides/tests/test_statistics.py b/addons/website_slides/tests/test_statistics.py
index 3d94a8ed596..ae5c406f361 100644
--- a/addons/website_slides/tests/test_statistics.py
+++ b/addons/website_slides/tests/test_statistics.py
@@ -164,3 +164,18 @@ class TestSlideStatistics(common.SlidesCase):
self.assertEqual(
category.nbr_document,
len(category.channel_id.slide_ids.filtered(lambda s: s.category_id == category and s.slide_type == 'document')))
+
+ self.assertEqual(category.total_slides, 2, 'The first category should contain 2 slides')
+ other_category = self.env['slide.slide'].with_user(self.user_publisher).create({
+ 'name': 'Other Category',
+ 'channel_id': self.channel.id,
+ 'is_category': True,
+ 'is_published': True,
+ 'sequence': 5,
+ })
+ self.assertEqual(other_category.total_slides, 0, 'The other category should not contain any slide yet')
+
+ # move one of the slide to the other category
+ self.slide_3.write({'sequence': 6})
+ self.assertEqual(category.total_slides, 1, 'The first category should contain 1 slide')
+ self.assertEqual(other_category.total_slides, 1, 'The other category should contain 1 slide')