From 56ed99cff5f0b3177a39d4c371f16606f03ef788 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Maes?= Date: Fri, 23 Dec 2016 15:10:45 +0100 Subject: [PATCH 1/9] [IMP] website_mail: extends mail.thread mixin to manage website messages mail.thread mixin will (re)provide the field 'website_message_ids'. Models can redifined its domain, since it can differ a bit (blog, forum, ... are not the same). Even if the domain can differ, we still keep it on the mixin since it will be required for the new chatter frontend (see following commits). --- addons/website_blog/models/website_blog.py | 10 ++-------- addons/website_event/models/event.py | 9 +-------- addons/website_forum/models/forum.py | 6 +----- addons/website_mail/models/__init__.py | 1 + addons/website_mail/models/mail_thread.py | 12 ++++++++++++ addons/website_sale/models/product.py | 5 ----- addons/website_slides/models/slides.py | 4 ---- 7 files changed, 17 insertions(+), 30 deletions(-) create mode 100644 addons/website_mail/models/mail_thread.py diff --git a/addons/website_blog/models/website_blog.py b/addons/website_blog/models/website_blog.py index cf202dea0ff..f10f3fe0745 100644 --- a/addons/website_blog/models/website_blog.py +++ b/addons/website_blog/models/website_blog.py @@ -140,14 +140,8 @@ class BlogPost(models.Model): teaser = fields.Text('Teaser', compute='_compute_teaser', inverse='_set_teaser') teaser_manual = fields.Text(string='Teaser Content') - website_message_ids = fields.One2many( - 'mail.message', 'res_id', - domain=lambda self: [ - '&', '&', ('model', '=', self._name), ('message_type', '=', 'comment'), ('path', '=', False) - ], - string='Website Messages', - help="Website communication history", - ) + website_message_ids = fields.One2many(domain=lambda self: [('model', '=', self._name), ('message_type', '=', 'comment'), ('path', '=', False)]) + # creation / update stuff create_date = fields.Datetime('Created on', index=True, readonly=True) published_date = fields.Datetime('Published Date') diff --git a/addons/website_event/models/event.py b/addons/website_event/models/event.py index 8fab469c5c8..81ec8c79629 100644 --- a/addons/website_event/models/event.py +++ b/addons/website_event/models/event.py @@ -19,14 +19,7 @@ class Event(models.Model): _inherit = ['event.event', 'website.seo.metadata', 'website.published.mixin'] website_published = fields.Boolean(track_visibility='onchange') - website_message_ids = fields.One2many( - 'mail.message', 'res_id', - domain=lambda self: [ - '&', ('model', '=', self._name), ('message_type', '=', 'comment') - ], - string='Website Messages', - help="Website communication history", - ) + is_participating = fields.Boolean("Is Participating", compute="_compute_is_participating") website_menu = fields.Boolean( diff --git a/addons/website_forum/models/forum.py b/addons/website_forum/models/forum.py index f303f764293..a550c679a72 100644 --- a/addons/website_forum/models/forum.py +++ b/addons/website_forum/models/forum.py @@ -209,11 +209,7 @@ class Post(models.Model): ('link', 'Article'), ('discussion', 'Discussion')], string='Type', default='question', required=True) - website_message_ids = fields.One2many( - 'mail.message', 'res_id', - domain=lambda self: ['&', ('model', '=', self._name), ('message_type', 'in', ['email', 'comment'])], - string='Post Messages', help="Comments on forum post", - ) + website_message_ids = fields.One2many(domain=lambda self: [('model', '=', self._name), ('message_type', 'in', ['email', 'comment'])]) # history create_date = fields.Datetime('Asked on', index=True, readonly=True) diff --git a/addons/website_mail/models/__init__.py b/addons/website_mail/models/__init__.py index 75ea63bd6d8..e90621e2bd2 100644 --- a/addons/website_mail/models/__init__.py +++ b/addons/website_mail/models/__init__.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. +from . import mail_thread from . import mail_message from . import update diff --git a/addons/website_mail/models/mail_thread.py b/addons/website_mail/models/mail_thread.py new file mode 100644 index 00000000000..08cd54aa301 --- /dev/null +++ b/addons/website_mail/models/mail_thread.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import api, fields, models + + +class MailThread(models.AbstractModel): + _inherit = 'mail.thread' + + website_message_ids = fields.One2many('mail.message', 'res_id', string='Website Messages', + domain=lambda self: [('model', '=', self._name), ('message_type', '=', 'comment')], auto_join=True, + help="Website communication history") diff --git a/addons/website_sale/models/product.py b/addons/website_sale/models/product.py index fe22160267f..c697973cd5d 100644 --- a/addons/website_sale/models/product.py +++ b/addons/website_sale/models/product.py @@ -109,11 +109,6 @@ class ProductTemplate(models.Model): _name = 'product.template' _mail_post_access = 'read' - website_message_ids = fields.One2many( - 'mail.message', 'res_id', - domain=lambda self: ['&', ('model', '=', self._name), ('message_type', '=', 'comment')], - string='Website Comments', - ) website_description = fields.Html('Description for the website', sanitize_attributes=False, translate=html_translate) alternative_product_ids = fields.Many2many('product.template', 'product_alternative_rel', 'src_id', 'dest_id', string='Alternative Products', help='Suggest more expensive alternatives to ' diff --git a/addons/website_slides/models/slides.py b/addons/website_slides/models/slides.py index 578bca3a147..f8726cf66b2 100644 --- a/addons/website_slides/models/slides.py +++ b/addons/website_slides/models/slides.py @@ -326,10 +326,6 @@ class Slide(models.Model): # website date_published = fields.Datetime('Publish Date') - website_message_ids = fields.One2many( - 'mail.message', 'res_id', - domain=lambda self: [('model', '=', self._name), ('message_type', '=', 'comment')], - string='Website Messages', help="Website communication history") likes = fields.Integer('Likes') dislikes = fields.Integer('Dislikes') # views From 890e665b882b27184003cc5de6ad365f2910815d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Maes?= Date: Fri, 23 Dec 2016 15:49:37 +0100 Subject: [PATCH 2/9] [IMP] website_quote: clean page style --- .../views/website_quote_templates.xml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/addons/website_quote/views/website_quote_templates.xml b/addons/website_quote/views/website_quote_templates.xml index 39b7924cc93..2c599bd46c8 100644 --- a/addons/website_quote/views/website_quote_templates.xml +++ b/addons/website_quote/views/website_quote_templates.xml @@ -438,15 +438,13 @@ - - - -