[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>
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user