From 0e943241fe2408830b9c06c1875a29f96ebe6c48 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Tue, 2 Jan 2018 14:32:06 +0100 Subject: [PATCH 1/4] [FIX] web: rotate graph label When there are too many labels to display on the x-axis, they overlap and it simply becomes unreadable. By slightly rotating them, this can be avoided in most cases. Back-port of this commit 388e258ce8c2a4fbd5e2ec5ec746bb91ca48d97f opw:802925 --- addons/web/static/src/js/views/graph_widget.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/js/views/graph_widget.js b/addons/web/static/src/js/views/graph_widget.js index 0af4ea9f362..a8994880e70 100644 --- a/addons/web/static/src/js/views/graph_widget.js +++ b/addons/web/static/src/js/views/graph_widget.js @@ -168,7 +168,7 @@ return Widget.extend({ var chart = nv.models.multiBarChart(); var maxVal = _.max(values, function(v) {return v.y}) chart.options({ - margin: {left: 12 * String(maxVal && maxVal.y || 10000000).length}, + margin: {left: 12 * String(maxVal && maxVal.y || 10000000).length, bottom: 60}, delay: 250, transition: 10, showLegend: _.size(data) <= MAX_LEGEND_LENGTH, @@ -177,7 +177,7 @@ return Widget.extend({ rightAlignYAxis: false, stacked: this.stacked, reduceXTicks: false, - // rotateLabels: 40, + rotateLabels: -20, showControls: (this.groupbys.length > 1) }); chart.yAxis.tickFormat(function(d) { return formats.format_value(d, { type : 'float' });}); From aaa8a87f36478bca6504b2acfbe5e0a2e236fa4b Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Wed, 3 Jan 2018 12:37:28 +0100 Subject: [PATCH 2/4] [FIX] website_forum: check karma to allow to flag a post without rights to edit If you set 200 kamra to allow to flag a post and 300 to edit all post, you was not able to flag the post before this commit. This commit closes #21274 @kangol: warning, fwd port need to add tag_ids into trusted_keys --- addons/website_forum/models/forum.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/addons/website_forum/models/forum.py b/addons/website_forum/models/forum.py index 8b03a0a809c..cc9b20da7c8 100644 --- a/addons/website_forum/models/forum.py +++ b/addons/website_forum/models/forum.py @@ -436,7 +436,7 @@ class Post(models.Model): elif post.parent_id and not post.can_answer: raise KarmaError('Not enough karma to answer to a question') if not post.parent_id and not post.can_post: - post.state = 'pending' + post.sudo().state = 'pending' # add karma for posting new questions if not post.parent_id and post.state == 'active': @@ -466,11 +466,18 @@ class Post(models.Model): @api.multi def write(self, vals): + trusted_keys = ['active', 'is_correct'] # fields where security is checked manually if 'content' in vals: vals['content'] = self._update_content(vals['content'], self.forum_id.id) if 'state' in vals: - if vals['state'] in ['active', 'close'] and any(not post.can_close for post in self): - raise KarmaError('Not enough karma to close or reopen a post.') + if vals['state'] in ['active', 'close']: + if any(not post.can_close for post in self): + raise KarmaError('Not enough karma to close or reopen a post.') + trusted_keys += ['state', 'closed_uid', 'closed_date', 'closed_reason_id'] + elif vals['state'] == 'flagged': + if any(not post.can_flag for post in self): + raise KarmaError('Not enough karma to flag a post.') + trusted_keys += ['state', 'flag_user_id'] if 'active' in vals: if any(not post.can_unlink for post in self): raise KarmaError('Not enough karma to delete or reactivate a post') @@ -483,7 +490,7 @@ class Post(models.Model): if vals['is_correct'] != post.is_correct and post.create_uid.id != self._uid: post.create_uid.sudo().add_karma(post.forum_id.karma_gen_answer_accepted * mult) self.env.user.sudo().add_karma(post.forum_id.karma_gen_answer_accept * mult) - if any(key not in ['state', 'active', 'is_correct', 'closed_uid', 'closed_date', 'closed_reason_id'] for key in vals.keys()) and any(not post.can_edit for post in self): + if any(key not in trusted_keys for key in vals) and any(not post.can_edit for post in self): raise KarmaError('Not enough karma to edit a post.') res = super(Post, self).write(vals) From 7a31bc60fb67a7322d6f105270cf809f5fc46e5d Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Wed, 3 Jan 2018 13:24:09 +0100 Subject: [PATCH 3/4] [FIX] website_forum: fix tooltip user info Before this commit, all tooltip users was showing website and parent_name from the Main company and not the current focsed partner. This commits closes #18430 @kangol: fwd-port company_name --- addons/website_forum/views/ir_qweb.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/website_forum/views/ir_qweb.xml b/addons/website_forum/views/ir_qweb.xml index 5b236210efa..174987a05d9 100644 --- a/addons/website_forum/views/ir_qweb.xml +++ b/addons/website_forum/views/ir_qweb.xml @@ -5,9 +5,9 @@
From 35c829f12b28615351cb306397b1a3dfbfdeaccb Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Fri, 5 Jan 2018 13:57:46 +0100 Subject: [PATCH 4/4] [FIX] mail: Discuss: apply default filters Before this rev., the default filters were ignored in Discuss. The SearchView was instantiated and correctly retrieved the default filters. However, a first manual 'do_search' needs to be done by the client action for the search view to provide the domain, and for Discuss to correctly filter the messages. Steps to reproduce the issue: - In Discuss (e.g. in Inbox), add to Favorites a given search, and tick 'Use by default' - Leave Discuss, and then go back: the default filter correctly appears in the search view, but the messages aren't filtered. --- addons/mail/static/src/js/client_action.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/addons/mail/static/src/js/client_action.js b/addons/mail/static/src/js/client_action.js index ca34192488f..5ef150e6d1d 100644 --- a/addons/mail/static/src/js/client_action.js +++ b/addons/mail/static/src/js/client_action.js @@ -231,6 +231,9 @@ var ChatAction = Widget.extend(ControlPanelMixin, { var def3 = this.extended_composer.appendTo(this.$('.o_mail_chat_content')); var def4 = this.searchview.appendTo($("
")).then(function () { self.$searchview_buttons = self.searchview.$buttons.contents(); + // manually call do_search to generate the initial domain and filter + // the messages in the default channel + self.searchview.do_search(); }); this.render_sidebar(); @@ -547,7 +550,12 @@ var ChatAction = Widget.extend(ControlPanelMixin, { }); this.domain = result.domain; - this.fetch_and_render_thread(); + if (this.channel) { + // initially (when do_search is called manually), there is no + // channel set yet, so don't try to fetch and render the thread as + // this will be done as soon as the default channel is set + this.fetch_and_render_thread(); + } }, on_post_message: function (message) {