summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRomain Derie <rde@odoo.com>2019-07-25 15:19:56 +0000
committerJeremy Kersten <jke@odoo.com>2019-08-03 09:51:22 +0000
commit7a90dedd25755c2d0a6091b13a5cec7de7b52009 (patch)
treed2d41560b96aaf0bd47d1baf37e19b4534a642cc
parentcc1d78a80b518bd5eaec7eb70d7bc14ec4c31275 (diff)
[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.
-rw-r--r--addons/website/models/mixins.py7
-rw-r--r--addons/website_crm_partner_assign/models/res_partner.py4
-rw-r--r--addons/website_customer/models/res_partner.py4
-rw-r--r--addons/website_slides/models/slide_channel_tag.py7
4 files changed, 15 insertions, 7 deletions
diff --git a/addons/website/models/mixins.py b/addons/website/models/mixins.py
index e9c08d2c31d..34af6ea2bba 100644
--- a/addons/website/models/mixins.py
+++ b/addons/website/models/mixins.py
@@ -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 != '#':
diff --git a/addons/website_crm_partner_assign/models/res_partner.py b/addons/website_crm_partner_assign/models/res_partner.py
index 3bf89a04ae9..5ce0387890d 100644
--- a/addons/website_crm_partner_assign/models/res_partner.py
+++ b/addons/website_crm_partner_assign/models/res_partner.py
@@ -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'
diff --git a/addons/website_customer/models/res_partner.py b/addons/website_customer/models/res_partner.py
index a70dd40bab3..9a70eef5ca7 100644
--- a/addons/website_customer/models/res_partner.py
+++ b/addons/website_customer/models/res_partner.py
@@ -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
diff --git a/addons/website_slides/models/slide_channel_tag.py b/addons/website_slides/models/slide_channel_tag.py
index 174ec347c7f..e59e3de1e82 100644
--- a/addons/website_slides/models/slide_channel_tag.py
+++ b/addons/website_slides/models/slide_channel_tag.py
@@ -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):