[FIX] website_slides: changing channel_id on slide.slide

Steps:
-Go into Slides (into Website Admin main menu)
-Find the Slide "Odoo Explained"
-Change the channel to "Employee Channel"
-Disconnect or open a private session
-Go to the menu "Presentations" on website
-Click on "Public channel"

Bug:

Error 403

Fix:

When changing the channel_id of a slide, the custom_slide_id of all
the channels using this slide as "Slide to Promote"  has to change
in False to avoid access rights errors.

opw:682063
This commit is contained in:
Goffin Simon
2016-07-12 09:01:25 +02:00
parent 2f3249d688
commit 3ea1ac7e0d
+3
View File
@@ -373,6 +373,9 @@ class Slide(models.Model):
doc_data = self._parse_document_url(values['url']).get('values', dict())
for key, value in doc_data.iteritems():
values.setdefault(key, value)
if values.get('channel_id'):
custom_channels = self.env['slide.channel'].search([('custom_slide_id', '=', self.id), ('id', '!=', values.get('channel_id'))])
custom_channels.write({'custom_slide_id': False})
res = super(Slide, self).write(values)
if values.get('website_published'):
self.date_published = datetime.datetime.now()