[FIX] website_blog: archive multiple blog.post throws a server error
Step to reproduce: - Go to 'Blog' > 'Blog Posts' in the 'Website Admin' module - Select several blog.post on the list view - Click on 'Archive' in the 'Action' dropdown This will throw a server error since write() is overriden for blog.post and do an ensure_one() This commit closes #22208
This commit is contained in:
committed by
Jeremy Kersten
parent
34bfadb2f2
commit
3c998acaaf
@@ -207,11 +207,12 @@ class BlogPost(models.Model):
|
||||
|
||||
@api.multi
|
||||
def write(self, vals):
|
||||
self.ensure_one()
|
||||
if 'website_published' in vals and 'published_date' not in vals:
|
||||
if self.published_date <= fields.Datetime.now():
|
||||
vals['published_date'] = vals['website_published'] and fields.Datetime.now()
|
||||
result = super(BlogPost, self).write(vals)
|
||||
result = True
|
||||
for post in self:
|
||||
copy_vals = vals
|
||||
if 'website_published' in vals and 'published_date' not in vals and post.published_date <= fields.Datetime.now():
|
||||
copy_vals['published_date'] = vals['website_published'] and fields.Datetime.now() or False
|
||||
result &= super(BlogPost, self).write(copy_vals)
|
||||
self._check_for_publication(vals)
|
||||
return result
|
||||
|
||||
|
||||
Reference in New Issue
Block a user