[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>
This commit is contained in:
Odoo's Mergebot
2020-04-21 12:56:41 +02:00
committed by GitHub
8 changed files with 47 additions and 11 deletions
-1
View File
@@ -20,7 +20,6 @@
'mail',
'resource',
'web',
'mail_bot',
],
'data': [
'security/hr_security.xml',
-5
View File
@@ -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
-2
View File
@@ -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):
+16
View File
@@ -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',
],
}
@@ -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>
+1 -1
View File
@@ -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',
+1 -1
View File
@@ -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')
+1 -1
View File
@@ -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