diff --git a/addons/website_blog/controllers/main.py b/addons/website_blog/controllers/main.py index 1106df0b..a8923a82 100644 --- a/addons/website_blog/controllers/main.py +++ b/addons/website_blog/controllers/main.py @@ -24,7 +24,7 @@ class WebsiteBlog(http.Controller): dom = blog and [('blog_id', '=', blog.id)] or [] if not request.env.user.has_group('website.group_website_designer'): dom += [('post_date', '<=', fields.Datetime.now()), - '|', ("website_ids", "in", request.website.id), ('website_ids', '=', False)] + ("website_ids", "in", request.website.id)] groups = request.env['blog.post']._read_group_raw( dom, ['name', 'post_date'], @@ -64,7 +64,7 @@ class WebsiteBlog(http.Controller): page=page, step=self._blog_post_per_page, ) - posts = BlogPost.search(['|', ("website_ids", "in", request.website.id), ('website_ids', '=', False)], offset=(page - 1) * self._blog_post_per_page, limit=self._blog_post_per_page) + posts = BlogPost.search([('website_ids', 'in', request.website.id)], offset=(page - 1) * self._blog_post_per_page, limit=self._blog_post_per_page) blog_url = QueryURL('', ['blog', 'tag']) return request.render("website_blog.latest_blogs", { 'posts': posts, @@ -114,16 +114,16 @@ class WebsiteBlog(http.Controller): domain += [("post_date", ">=", date_begin), ("post_date", "<=", date_end)] if request.env.user.has_group('website.group_website_designer'): - count_domain = domain + [("website_published", "=", True), '|', ("website_ids", "in", request.website.id), ('website_ids', '=', False), ("post_date", "<=", fields.Datetime.now())] + count_domain = domain + [("website_published", "=", True), ("website_ids", "in", request.website.id), ("post_date", "<=", fields.Datetime.now())] published_count = BlogPost.search_count(count_domain) unpublished_count = BlogPost.search_count(domain) - published_count if state == "published": - domain += [("website_published", "=", True), '|', ("website_ids", "in", request.website.id), ('website_ids', '=', False), ("post_date", "<=", fields.Datetime.now())] + domain += [("website_published", "=", True), ("website_ids", "in", request.website.id), ("post_date", "<=", fields.Datetime.now())] elif state == "unpublished": - domain += ['|', ("website_published", "=", False), '|', ("website_ids", "in", request.website.id), ('website_ids', '=', False), ("post_date", ">", fields.Datetime.now())] + domain += ['|', ("website_published", "=", False), ("website_ids", "in", request.website.id), ("post_date", ">", fields.Datetime.now())] else: - domain += [("post_date", "<=", fields.Datetime.now()), '|', ("website_ids", "in", request.website.id), ('website_ids', '=', False)] + domain += [("post_date", "<=", fields.Datetime.now()), ("website_ids", "in", request.website.id)] blog_url = QueryURL('', ['blog', 'tag'], blog=blog, tag=tag, date_begin=date_begin, date_end=date_end) @@ -198,6 +198,10 @@ class WebsiteBlog(http.Controller): - 'nav_list': a dict [year][month] for archives navigation - 'next_post': next blog post, to direct the user towards the next interesting post """ + if not request.env.user.has_group('website.group_website_publisher') \ + and request.website.id not in blog_post.website_ids.ids: + return request.render('website.404') + BlogPost = request.env['blog.post'] date_begin, date_end = post.get('date_begin'), post.get('date_end') @@ -225,7 +229,7 @@ class WebsiteBlog(http.Controller): tags = request.env['blog.tag'].search([]) # Find next Post - all_post = BlogPost.search([('blog_id', '=', blog.id)]) + all_post = BlogPost.search([('blog_id', '=', blog.id), ("website_published", "=", True), ("website_ids", "in", request.website.id)]) if not request.env.user.has_group('website.group_website_designer'): all_post = all_post.filtered(lambda r: r.post_date <= fields.Datetime.now()) @@ -331,7 +335,7 @@ class WebsiteBlog(http.Controller): #check current user belongs to website publisher group publish = request.env.user.has_group('website.group_website_publisher') if not publish: - domain.append(('website_published', '=', True), '|', ("website_ids", "in", request.website.id), ('website_ids', '=', False)) + domain.append(('website_published', '=', True), ("website_ids", "in", request.website.id)) messages = request.env['mail.message'].sudo().search(domain, count=count) if count: return messages.ids diff --git a/addons/website_blog/data/website_blog_demo.xml b/addons/website_blog/data/website_blog_demo.xml index 9f72f925..2b85bd90 100644 --- a/addons/website_blog/data/website_blog_demo.xml +++ b/addons/website_blog/data/website_blog_demo.xml @@ -16,7 +16,6 @@ - Flectra, email The Future of Emails @@ -132,7 +131,6 @@ Building your company's website and selling your products online easy. - {"background-image": "url(/web/image/website_blog.blog_post_cover_02)", "resize_class": "cover container-fluid cover_full", "background-color": "oe_black", "opacity": "0.0"} diff --git a/addons/website_blog/models/website_blog.py b/addons/website_blog/models/website_blog.py index e443ee81..2195d6fb 100644 --- a/addons/website_blog/models/website_blog.py +++ b/addons/website_blog/models/website_blog.py @@ -127,6 +127,10 @@ class BlogPost(models.Model): ''' + def _default_website(self): + default_website_id = self.env.ref('website.default_website') + return [default_website_id.id] if default_website_id else None + name = fields.Char('Title', required=True, translate=True, default='') subtitle = fields.Char('Sub Title', translate=True) author_id = fields.Many2one('res.partner', 'Author', default=lambda self: self.env.user.partner_id) @@ -155,9 +159,10 @@ class BlogPost(models.Model): ranking = fields.Float(compute='_compute_ranking', string='Ranking') website_ids = fields.Many2many('website', 'website_blog_pub_rel', 'website_id', 'blog_id', + default=_default_website, string='Websites', copy=False, help='List of websites in which ' - 'Blog Post is published.') + 'Blog Post will published.') @api.multi @api.depends('content', 'teaser_manual') diff --git a/addons/website_blog/tests/test_website_blog_flow.py b/addons/website_blog/tests/test_website_blog_flow.py index 4992dc9f..64e2535f 100644 --- a/addons/website_blog/tests/test_website_blog_flow.py +++ b/addons/website_blog/tests/test_website_blog_flow.py @@ -17,7 +17,7 @@ class TestWebsiteBlogFlow(TestWebsiteBlogCommon): - if someone subscribe to the post or comment it, it become follower and receive notification for future comments. """ - self.website = self.env['website'].browse(1) + website = self.env['website'].browse(1) # Create a new blog, subscribe the employee to the blog test_blog = self.env['blog.blog'].sudo(self.user_blogmanager).create({ 'name': 'New Blog', @@ -40,7 +40,7 @@ class TestWebsiteBlogFlow(TestWebsiteBlogCommon): 'website_blog: subscribing to a blog should not subscribe to its posts') # Publish the blog - test_blog_post.write({'website_published': True, 'website_ids': [(6, 0, [self.website.id])]}) + test_blog_post.write({'website_published': True, 'website_ids': [(6, 0, [website.id])]}) # Check publish message has been sent to blog followers publish_message = next((m for m in test_blog_post.blog_id.message_ids if m.subtype_id.id == self.ref('website_blog.mt_blog_blog_published')), None) diff --git a/addons/website_blog/views/website_blog_templates.xml b/addons/website_blog/views/website_blog_templates.xml index 030caa5b..a848d00b 100644 --- a/addons/website_blog/views/website_blog_templates.xml +++ b/addons/website_blog/views/website_blog_templates.xml @@ -133,7 +133,7 @@

-
+

Untitled Post

diff --git a/addons/website_crm_partner_assign/controllers/main.py b/addons/website_crm_partner_assign/controllers/main.py index 37b340e5..73cc1f8b 100644 --- a/addons/website_crm_partner_assign/controllers/main.py +++ b/addons/website_crm_partner_assign/controllers/main.py @@ -185,14 +185,14 @@ class WebsiteCrmPartnerAssign(WebsitePartnerPage): yield {'loc': '/partners'} Grade = env['res.partner.grade'] - dom = [('website_published', '=', True), '|', ('website_ids', 'in', request.website.id), ('website_ids', '=', False)] + dom = [('website_published', '=', True), ('website_ids', 'in', request.website.id)] dom += sitemap_qs2dom(qs=qs, route='/partners/grade/', field=Grade._rec_name) for grade in env['res.partner.grade'].search(dom): loc = '/partners/grade/%s' % slug(grade) if not qs or qs.lower() in loc: yield {'loc': loc} - partners_dom = [('is_company', '=', True), ('grade_id', '!=', False), ('website_published', '=', True), '|', ('website_ids', 'in', request.website.id), ('website_ids', '=', False), ('grade_id.website_published', '=', True)] + partners_dom = [('is_company', '=', True), ('grade_id', '!=', False), ('website_published', '=', True), ('website_ids', 'in', request.website.id), ('grade_id.website_published', '=', True)] dom += sitemap_qs2dom(qs=qs, route='/partners/country/') countries = env['res.partner'].sudo().read_group(partners_dom, fields=['id', 'country_id'], groupby='country_id') for country in countries: @@ -219,9 +219,9 @@ class WebsiteCrmPartnerAssign(WebsitePartnerPage): country_obj = request.env['res.country'] search = post.get('search', '') - base_partner_domain = [('is_company', '=', True), ('grade_id', '!=', False), ('website_published', '=', True)] + base_partner_domain = [('is_company', '=', True), ('grade_id', '!=', False), ('website_published', '=', True), ('website_ids', 'in', request.website.id)] if not request.env['res.users'].has_group('website.group_website_publisher'): - base_partner_domain += [('grade_id.website_published', '=', True), '|', ('grade_id.website_ids', 'in', request.website.id), ('grade_id.website_ids', '=', False)] + base_partner_domain += [('grade_id.website_published', '=', True), ('grade_id.website_ids', 'in', request.website.id)] if search: base_partner_domain += ['|', ('name', 'ilike', search), ('website_description', 'ilike', search)] @@ -327,7 +327,7 @@ class WebsiteCrmPartnerAssign(WebsitePartnerPage): if partner_id: partner = request.env['res.partner'].sudo().browse(partner_id) is_website_publisher = request.env['res.users'].has_group('website.group_website_publisher') - if partner.exists() and ((partner.website_published and request.website in partner.website_ids) or is_website_publisher): + if partner.exists() and ((partner.website_published and request.website in partner.website_ids) or is_website_publisher): values = { 'main_object': partner, 'partner': partner, diff --git a/addons/website_crm_partner_assign/data/res_partner_grade_demo.xml b/addons/website_crm_partner_assign/data/res_partner_grade_demo.xml index e1b963b1..c24d0a3c 100644 --- a/addons/website_crm_partner_assign/data/res_partner_grade_demo.xml +++ b/addons/website_crm_partner_assign/data/res_partner_grade_demo.xml @@ -3,19 +3,15 @@ - - - - diff --git a/addons/website_crm_partner_assign/models/res_partner.py b/addons/website_crm_partner_assign/models/res_partner.py index 745ac480..f11b5681 100644 --- a/addons/website_crm_partner_assign/models/res_partner.py +++ b/addons/website_crm_partner_assign/models/res_partner.py @@ -9,6 +9,10 @@ class ResPartnerGrade(models.Model): _name = 'res.partner.grade' _inherit = ['website.published.mixin'] + def _default_website(self): + default_website_id = self.env.ref('website.default_website') + return [default_website_id.id] if default_website_id else None + website_published = fields.Boolean(default=True) sequence = fields.Integer('Sequence') active = fields.Boolean('Active', default=lambda *args: 1) @@ -18,8 +22,9 @@ class ResPartnerGrade(models.Model): website_ids = fields.Many2many('website', 'website_partner_grade_pub_rel', 'website_id', 'partner_grade_id', string='Websites', copy=False, + default=_default_website, help='List of websites in which ' - 'Partner Grade is published.') + 'Partner Grade will published.') @api.multi def _compute_website_url(self): diff --git a/addons/website_crm_partner_assign/views/website_crm_partner_assign_templates.xml b/addons/website_crm_partner_assign/views/website_crm_partner_assign_templates.xml index 3f41d52d..25d5cf25 100644 --- a/addons/website_crm_partner_assign/views/website_crm_partner_assign_templates.xml +++ b/addons/website_crm_partner_assign/views/website_crm_partner_assign_templates.xml @@ -162,7 +162,7 @@ @@ -171,7 +171,7 @@

References

- + diff --git a/addons/website_customer/controllers/main.py b/addons/website_customer/controllers/main.py index 25702078..d8d393bf 100644 --- a/addons/website_customer/controllers/main.py +++ b/addons/website_customer/controllers/main.py @@ -47,7 +47,7 @@ class WebsiteCustomer(http.Controller): Partner = request.env['res.partner'] search_value = post.get('search') - domain = [('website_published', '=', True), '|', ('website_ids', '=', False), ('website_ids', 'in', request.website.id), ('assigned_partner_id', '!=', False)] + domain = [('website_published', '=', True), ('website_ids', 'in', request.website.id), ('assigned_partner_id', '!=', False)] if search_value: domain += [ '|', '|', @@ -118,7 +118,7 @@ class WebsiteCustomer(http.Controller): google_map_partner_ids = ','.join(str(it) for it in partners.ids) google_maps_api_key = request.env['ir.config_parameter'].sudo().get_param('google_maps_api_key') - tags = Tag.search([('website_published', '=', True), '|', ('website_ids', '=', False), ('website_ids', 'in', request.website.id), ('partner_ids', 'in', partners.ids)], order='classname, name ASC') + tags = Tag.search([('website_published', '=', True), ('website_ids', 'in', request.website.id), ('partner_ids', 'in', partners.ids)], order='classname, name ASC') tag = tag_id and Tag.browse(tag_id) or False values = { @@ -145,7 +145,7 @@ class WebsiteCustomer(http.Controller): _, partner_id = unslug(partner_id) if partner_id: partner = request.env['res.partner'].sudo().browse(partner_id) - if partner.exists() and partner.website_published and (request.website in partner.website_ids or not partner.website_ids): + if partner.exists() and partner.website_published and request.website in partner.website_ids: values = {} values['main_object'] = values['partner'] = partner return request.render("website_customer.details", values) diff --git a/addons/website_customer/data/res_partner_demo.xml b/addons/website_customer/data/res_partner_demo.xml index 3436aae4..ab53207e 100644 --- a/addons/website_customer/data/res_partner_demo.xml +++ b/addons/website_customer/data/res_partner_demo.xml @@ -4,7 +4,6 @@ - Agrolait designs, develops, integrates and supports HR and Supply Chain processes in order to make our customers more productive, responsive and profitable.

@@ -35,7 +34,6 @@ - A non-profit international educational and scientific organisation, hosting three departments (aeronautics and aerospace, environmental and applied fluid dynamics, and turbomachinery and propulsion).

@@ -64,7 +62,6 @@ - Agrolait designs, develops, integrates and supports HR and Supply Chain processes in order to make our customers more productive, responsive and profitable.

@@ -95,7 +92,6 @@ - A non-profit international educational and scientific organisation, hosting three departments (aeronautics and aerospace, environmental and applied fluid dynamics, and turbomachinery and propulsion).

diff --git a/addons/website_customer/models/res_partner.py b/addons/website_customer/models/res_partner.py index e030bd47..4e680849 100644 --- a/addons/website_customer/models/res_partner.py +++ b/addons/website_customer/models/res_partner.py @@ -22,6 +22,10 @@ class Tags(models.Model): classname = ['default', 'primary', 'success', 'warning', 'danger'] return [(x, str.title(x)) for x in classname] + def _default_website(self): + default_website_id = self.env.ref('website.default_website') + return [default_website_id.id] if default_website_id else None + name = fields.Char('Category Name', required=True, translate=True) 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) @@ -30,5 +34,6 @@ class Tags(models.Model): website_ids = fields.Many2many('website', 'website_partner_tag_pub_rel', 'website_id', 'partner_tag_id', string='Websites', copy=False, + default=_default_website, help='List of websites in which ' - 'Partner Tag is published.') + 'Partner Tag will published.') diff --git a/addons/website_customer/views/res_partner_views.xml b/addons/website_customer/views/res_partner_views.xml index e6825e06..461875d3 100644 --- a/addons/website_customer/views/res_partner_views.xml +++ b/addons/website_customer/views/res_partner_views.xml @@ -37,7 +37,6 @@ - diff --git a/addons/website_customer/views/website_customer_templates.xml b/addons/website_customer/views/website_customer_templates.xml index 52d3c9d3..46d0c806 100644 --- a/addons/website_customer/views/website_customer_templates.xml +++ b/addons/website_customer/views/website_customer_templates.xml @@ -189,7 +189,7 @@