From 229fe73517da135428f9e72715a8e5faff7bb62e Mon Sep 17 00:00:00 2001 From: Maitri Patel Date: Wed, 14 Jun 2023 06:53:00 +0000 Subject: [PATCH] [FIX] mail: handle error while click on follow button MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a user click on the 'Follow' button in the chatterbox of the project Task form view without adding any data, then traceback will appear. Steps to reproduce(i.e Project): - Install project module. - Go to Project >> Tasks >> My task(you can also choose the all task menu) . - In the list view of project.task model, click on the new button. - In-form view of project.task model, Click on Follow Button in the chatterbox. Error: traceback appears: "psycopg2.errors.UndefinedFunction: operator does not exist: integer = boolean" sentry-4243265676 closes odoo/odoo#126749 X-original-commit: eeaee0d57effb50d3a0edad1672e17bffea11d0a Signed-off-by: Alexandre Kühn (aku) --- addons/mail/static/src/core/web/chatter.js | 19 +++++++++++++++-- .../static/tests/web/follow_button_tests.js | 21 +++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/addons/mail/static/src/core/web/chatter.js b/addons/mail/static/src/core/web/chatter.js index baaeac65846..3b3427f4a2c 100644 --- a/addons/mail/static/src/core/web/chatter.js +++ b/addons/mail/static/src/core/web/chatter.js @@ -280,13 +280,28 @@ export class Chatter extends Component { document.body.click(); // hack to close dropdown } - async onClickFollow() { - await this.orm.call(this.props.threadModel, "message_subscribe", [[this.props.threadId]], { + async _follow(threadModel, threadId) { + await this.orm.call(threadModel, "message_subscribe", [[threadId]], { partner_ids: [this.store.self.id], }); this.onFollowerChanged(); } + async onClickFollow() { + if (this.props.threadId) { + this._follow(this.props.threadModel, this.props.threadId); + } else { + this.onNextUpdate = (nextProps) => { + if (nextProps.threadId) { + this._follow(nextProps.threadModel, nextProps.threadId); + } else { + return true; + } + }; + await this.props.saveRecord?.(); + } + } + /** * @param {MouseEvent} ev * @param {import("@mail/core/common/follower_model").Follower} follower diff --git a/addons/mail/static/tests/web/follow_button_tests.js b/addons/mail/static/tests/web/follow_button_tests.js index 93f647d2540..6a7cfb065e8 100644 --- a/addons/mail/static/tests/web/follow_button_tests.js +++ b/addons/mail/static/tests/web/follow_button_tests.js @@ -57,6 +57,27 @@ QUnit.test('click on "follow" button', async (assert) => { assert.containsOnce($, "button:contains(Following)"); }); +QUnit.test('Click on "follow" button should save draft record', async (assert) => { + const views = { + "res.partner,false,form": ` +
+ + + +
+ +
+
`, + }; + const { openFormView } = await start({ serverData: { views } }); + await openFormView("res.partner"); + assert.containsOnce($, "button:contains(Follow)"); + assert.containsOnce($, "div.o_field_char"); + + await click("button:contains(Follow)"); + assert.containsOnce($, "div.o_field_invalid"); +}); + QUnit.test('click on "unfollow" button', async (assert) => { const pyEnv = await startServer(); const threadId = pyEnv["res.partner"].create({});