diff options
| author | Odoo's Mergebot <xmo+roboto@odoo.com> | 2020-04-21 12:56:41 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-21 12:56:41 +0200 |
| commit | 1d30a4cd4479e5eca4cd90da163b267825652f5a (patch) | |
| tree | 07fcd5906e5c823a05843c093b4915d94180f7c7 | |
| parent | f0a66d05e70e432d35dc68c9fb1e1cc6e51b40b8 (diff) | |
| parent | 3ba7186752e3766e897118f13e2df9b1a6484b5b (diff) | |
[MERGE][ADD] mail_bot_hr: add bridge module to remove mail_bot dependency from hr
In v12, the hr module did not have a hard dependency on mail_bot, so the users could uninstall it if they did not want/need its functionality. In v13, mail_bot was added as a dependency to include the notification widget and the odoobot state in the user forms modified by the hr module. However, this also brings potentially unwanted functionality to anyone who installs an hr related application.
This commit removes the dependency on mail_bot by adding the mail_bot_hr bridge module, which has the odoobot state field and includes a dummy notification widget.
Additionally, the automated answers from OdooBot like "Pong" that fill the chatter and annoy many users have been removed.
Task ID 2200878
closes odoo/odoo#48521
Related: odoo/upgrade#1089
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
| -rw-r--r-- | addons/hr/__manifest__.py | 1 | ||||
| -rw-r--r-- | addons/hr/views/res_users.xml | 5 | ||||
| -rw-r--r-- | addons/mail_bot/models/mail_bot.py | 2 | ||||
| -rw-r--r-- | addons/mail_bot_hr/__manifest__.py | 16 | ||||
| -rw-r--r-- | addons/mail_bot_hr/views/res_users_views.xml | 28 | ||||
| -rw-r--r-- | addons/test_mail/__manifest__.py | 2 | ||||
| -rw-r--r-- | addons/test_mail/tests/test_odoobot.py | 2 | ||||
| -rw-r--r-- | addons/test_mail/tests/test_performance.py | 2 |
8 files changed, 47 insertions, 11 deletions
diff --git a/addons/hr/__manifest__.py b/addons/hr/__manifest__.py index 68bc368853c..78dbafe5450 100644 --- a/addons/hr/__manifest__.py +++ b/addons/hr/__manifest__.py @@ -20,7 +20,6 @@ 'mail', 'resource', 'web', - 'mail_bot', ], 'data': [ 'security/hr_security.xml', diff --git a/addons/hr/views/res_users.xml b/addons/hr/views/res_users.xml index 22992df0244..2f3b0abbe9c 100644 --- a/addons/hr/views/res_users.xml +++ b/addons/hr/views/res_users.xml @@ -14,7 +14,6 @@ <field name="arch" type="xml"> <footer position="replace"/> <h1 position="replace"/> - <widget name="notification_alert" position="replace"/> <xpath expr="//field[@name='image_1920']" position="replace"/> <xpath expr="//field[@name='company_id']" position="attributes"> <attribute name="invisible">1</attribute> @@ -38,16 +37,12 @@ <field name="model">res.users</field> <field name="inherit_id" ref="res_users_view_form_simple_modif"/> <field name="arch" type="xml"> - <xpath expr="//field[@name='odoobot_state']" position="attributes"> - <attribute name="attrs">{'readonly': [('can_edit', '=', False)]}</attribute> - </xpath> <form position="replace"> <form create="false" js_class="hr_employee_profile_form"> <field name="hr_presence_state" invisible="1"/> <header> <button name="preference_change_password" type="object" string="Change password" class="btn btn-secondary"/> </header> - <widget name="notification_alert" class="mb-0"/> <sheet> <div class="oe_button_box" name="button_box"> <button diff --git a/addons/mail_bot/models/mail_bot.py b/addons/mail_bot/models/mail_bot.py index 10686b14ba3..7a4aebee197 100644 --- a/addons/mail_bot/models/mail_bot.py +++ b/addons/mail_bot/models/mail_bot.py @@ -75,8 +75,6 @@ class MailBot(models.AbstractModel): _("I'm afraid I don't understand. Sorry!"), _("Sorry I'm sleepy. Or not! Maybe I'm just trying to hide my unawareness of human language...<br/>I can show you features if you write")+ ": '<b>"+_('start the tour')+"</b>'.", ]) - elif self._is_bot_pinged(values): - return random.choice([_("Yep, OdooBot is in the place!"), _("Pong.")]) return False def _body_contains_emoji(self, body): diff --git a/addons/mail_bot_hr/__manifest__.py b/addons/mail_bot_hr/__manifest__.py new file mode 100644 index 00000000000..714717a08f5 --- /dev/null +++ b/addons/mail_bot_hr/__manifest__.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +{ + 'name': "mail_bot_hr", + 'summary': """Bridge module between hr and mailbot.""", + 'description': """This module adds the OdooBot state and notifications in the user form modified by hr.""", + 'website': "https://www.odoo.com/page/discuss", + 'category': 'Productivity/Discuss', + 'version': '1.0', + 'depends': ['mail_bot', 'hr'], + 'application': False, + 'installable': True, + 'auto_install': True, + 'data': [ + 'views/res_users_views.xml', + ], +} diff --git a/addons/mail_bot_hr/views/res_users_views.xml b/addons/mail_bot_hr/views/res_users_views.xml new file mode 100644 index 00000000000..ee0e374f57b --- /dev/null +++ b/addons/mail_bot_hr/views/res_users_views.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" ?> +<odoo> + <data> + <record id="res_users_view_form_simple_modif" model="ir.ui.view"> + <field name="name">res.users.preferences.form.simplified.inherit</field> + <field name="model">res.users</field> + <field name="inherit_id" ref="hr.res_users_view_form_simple_modif" /> + <field name="mode">primary</field> + <field name="arch" type="xml"> + <widget name="notification_alert" position="replace" /> + </field> + </record> + + <record id="res_users_view_form_profile" model="ir.ui.view"> + <field name="name">res.users.preferences.form.inherit</field> + <field name="model">res.users</field> + <field name="inherit_id" ref="hr.res_users_view_form_profile" /> + <field name="arch" type="xml"> + <xpath expr="//field[@name='odoobot_state']" position="attributes"> + <attribute name="attrs">{'readonly': [('can_edit', '=', False)]}</attribute> + </xpath> + <sheet position="before"> + <widget name="notification_alert" class="mb-0" /> + </sheet> + </field> + </record> + </data> +</odoo> diff --git a/addons/test_mail/__manifest__.py b/addons/test_mail/__manifest__.py index 18516b56e90..f539daaa69e 100644 --- a/addons/test_mail/__manifest__.py +++ b/addons/test_mail/__manifest__.py @@ -9,7 +9,7 @@ 'description': """This module contains tests related to mail. Those are contained in a separate module as it contains models used only to perform tests independently to functional aspects of other models. """, - 'depends': ['test_performance', 'mail', 'mail_bot'], + 'depends': ['test_performance', 'mail'], 'data': [ 'security/ir.model.access.csv', 'security/test_mail_security.xml', diff --git a/addons/test_mail/tests/test_odoobot.py b/addons/test_mail/tests/test_odoobot.py index 740a0444974..2e4dc55490a 100644 --- a/addons/test_mail/tests/test_odoobot.py +++ b/addons/test_mail/tests/test_odoobot.py @@ -44,7 +44,7 @@ class TestOdoobot(TestMailCommon, TestRecipients): self.assertNextMessage( self.test_record_employe.with_context({'mail_post_autofollow': True}).message_post(**kwargs), sender=self.odoobot, - answer=["Yep, OdooBot is in the place!"] + answer=False ) # Odoobot should not be a follower but user_employee and user_admin should follower = self.test_record.message_follower_ids.mapped('partner_id') diff --git a/addons/test_mail/tests/test_performance.py b/addons/test_mail/tests/test_performance.py index c79ae4abf65..de82171251b 100644 --- a/addons/test_mail/tests/test_performance.py +++ b/addons/test_mail/tests/test_performance.py @@ -286,7 +286,7 @@ class TestMailAPIPerformance(BaseMailPerformance): }).create({}) composer.onchange_template_id_wrapper() - with self.assertQueryCount(__system__=39, emp=44): + with self.assertQueryCount(__system__=40, emp=45): composer.send_mail() # remove created partner to ensure tests are the same each run |
