[IMP] website*: use published mixin rather than own field

*website_crm_partner_assign, website_customer

Before this commit, some models would create their own `website_published`
field rather than using the `website.published.mixin` mixin which should be
used instead.

That was done to be able to override the default value of the boolean.

This commit simply adds the possibility to override the default value of the
mixin field.

Also, help and string could simply be added on xml views rather than overriding
the field.
This commit is contained in:
Romain Derie
2019-08-03 09:51:22 +00:00
committed by Jeremy Kersten
parent cc1d78a80b
commit 7a90dedd25
4 changed files with 15 additions and 7 deletions
+5 -2
View File
@@ -119,14 +119,17 @@ class WebsitePublishedMixin(models.AbstractModel):
_description = 'Website Published Mixin'
website_published = fields.Boolean('Visible on current website', related='is_published', readonly=False)
is_published = fields.Boolean('Is published', copy=False)
can_publish = fields.Boolean('Can publish', compute='_compute_can_publish')
is_published = fields.Boolean('Is Published', copy=False, default=lambda self: self._default_is_published())
can_publish = fields.Boolean('Can Publish', compute='_compute_can_publish')
website_url = fields.Char('Website URL', compute='_compute_website_url', help='The full URL to access the document through the website.')
def _compute_website_url(self):
for record in self:
record.website_url = '#'
def _default_is_published(self):
return False
def website_publish_button(self):
self.ensure_one()
if self.env.user.has_group('website.group_website_publisher') and self.website_url != '#':
@@ -10,7 +10,6 @@ class ResPartnerGrade(models.Model):
_inherit = ['website.published.mixin']
_description = 'Partner Grade'
website_published = fields.Boolean(default=True)
sequence = fields.Integer('Sequence')
active = fields.Boolean('Active', default=lambda *args: 1)
name = fields.Char('Level Name', translate=True)
@@ -22,6 +21,9 @@ class ResPartnerGrade(models.Model):
for grade in self:
grade.website_url = "/partners/grade/%s" % (slug(grade))
def _default_is_published(self):
return True
class ResPartnerActivation(models.Model):
_name = 'res.partner.activation'
@@ -26,4 +26,6 @@ class Tags(models.Model):
partner_ids = fields.Many2many('res.partner', 'res_partner_res_partner_tag_rel', 'tag_id', 'partner_id', string='Partners')
classname = fields.Selection(get_selection_class, 'Class', default='default', help="Bootstrap class to customize the color", required=True)
active = fields.Boolean('Active', default=True)
website_published = fields.Boolean(default=True)
def _default_is_published(self):
return True
@@ -7,14 +7,15 @@ from odoo import fields, models
class SlideChannelTagGroup(models.Model):
_name = 'slide.channel.tag.group'
_description = 'Channel/Course tags'
_inherit = 'website.published.mixin'
_order = 'sequence asc'
name = fields.Char('Name', required=True, translate=True)
sequence = fields.Integer('Sequence', default=10, index=True, required=True)
tag_ids = fields.One2many('slide.channel.tag', 'group_id', string='Tags')
website_published = fields.Boolean(
'Menu entry', default=True,
help='Makes a menu entry in main navigation of Slides, allowing to filter on its tags directly from main navigation.')
def _default_is_published(self):
return True
class SlideChannelTag(models.Model):