[FIX] website_blog: Traceback on archived blog
Steps to reproduce the bug: - Create a blogpost in the the blog 'travel - Archive the blog 'travel' - Open the blogpost Bug: A traceback was raised opw:2444406 closes odoo/odoo#65576 X-original-commit: 196d96ef8eaf8aa06e16c9768ed595fca1c315ff Signed-off-by: Simon Goffin (sig) <sig@openerp.com> Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
This commit is contained in:
@@ -116,7 +116,7 @@ class WebsiteBlog(http.Controller):
|
||||
step=self._blog_post_per_page,
|
||||
)
|
||||
|
||||
all_tags = blog and blogs.all_tags()[blog.id] or blogs.all_tags(join=True)
|
||||
all_tags = blogs.all_tags(join=True) if not blog else blogs.all_tags().get(blog.id, request.env['blog.tag'])
|
||||
tag_category = sorted(all_tags.mapped('category_id'), key=lambda category: category.name.upper())
|
||||
other_tags = sorted(all_tags.filtered(lambda x: not x.category_id), key=lambda tag: tag.name.upper())
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ class BlogPost(models.Model):
|
||||
|
||||
def _check_for_publication(self, vals):
|
||||
if vals.get('is_published'):
|
||||
for post in self:
|
||||
for post in self.filtered(lambda p: p.active):
|
||||
post.blog_id.message_post_with_view(
|
||||
'website_blog.blog_post_template_new_post',
|
||||
subject=post.name,
|
||||
@@ -202,6 +202,9 @@ class BlogPost(models.Model):
|
||||
|
||||
def write(self, vals):
|
||||
result = True
|
||||
# archiving a blog post, unpublished the blog post
|
||||
if 'active' in vals and not vals['active']:
|
||||
vals['is_published'] = False
|
||||
for post in self:
|
||||
copy_vals = dict(vals)
|
||||
published_in_vals = set(vals.keys()) & {'is_published', 'website_published'}
|
||||
|
||||
@@ -8,4 +8,11 @@
|
||||
<field name="groups" eval="[(4, ref('base.group_public')), (4, ref('base.group_portal'))]"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.rule" id="website_blog_public">
|
||||
<field name="name">Blog: active only</field>
|
||||
<field name="model_id" ref="model_blog_blog"/>
|
||||
<field name="domain_force">[('active', '=', True)]</field>
|
||||
<field name="groups" eval="[(4, ref('base.group_public')), (4, ref('base.group_portal'))]"/>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<form string="Blog Post">
|
||||
<sheet>
|
||||
<div class="oe_button_box" name="button_box">
|
||||
<div class="oe_button_box" name="button_box" attrs="{'invisible': [('active', '=', False)]}">
|
||||
<field name="is_published" widget="website_redirect_button"/>
|
||||
</div>
|
||||
<widget name="web_ribbon" title="Archived" bg_color="bg-danger" attrs="{'invisible': [('active', '=', True)]}"/>
|
||||
|
||||
Reference in New Issue
Block a user