[RENAME] mail, website_mail, website_mail_group, various: mail.group
model has been renamed to mail.channel to prepare the slack modeling. In future commits the mail.group model will be merged with the channel model from im_chat. The first move is to rename mail.group into mail.channel to have a model that will unite both features.
This commit is contained in:
@@ -16,8 +16,8 @@
|
||||
|
||||
<!-- Notify all employees of module installation -->
|
||||
<record model="mail.message" id="module_install_notification">
|
||||
<field name="model">mail.group</field>
|
||||
<field name="res_id" ref="mail.group_all_employees"/>
|
||||
<field name="model">mail.channel</field>
|
||||
<field name="res_id" ref="mail.channel_all_employees"/>
|
||||
<field name="message_type">notification</field>
|
||||
<field name="subtype_id" ref="mail.mt_comment"/>
|
||||
<field name="subject">Accounting and Finance application installed!</field>
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
<!-- notify all employees of module installation -->
|
||||
<record model="mail.message" id="module_install_notification">
|
||||
<field name="model">mail.group</field>
|
||||
<field name="res_id" ref="mail.group_all_employees"/>
|
||||
<field name="model">mail.channel</field>
|
||||
<field name="res_id" ref="mail.channel_all_employees"/>
|
||||
<field name="message_type">notification</field>
|
||||
<field name="subtype_id" ref="mail.mt_comment"/>
|
||||
<field name="subject">eInvoicing & Payments application installed!</field>
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
|
||||
<!-- notify all employees of module installation -->
|
||||
<record model="mail.message" id="module_install_notification">
|
||||
<field name="model">mail.group</field>
|
||||
<field name="res_id" ref="mail.group_all_employees"/>
|
||||
<field name="model">mail.channel</field>
|
||||
<field name="res_id" ref="mail.channel_all_employees"/>
|
||||
<field name="message_type">notification</field>
|
||||
<field name="subtype_id" ref="mail.mt_comment"/>
|
||||
<field name="subject">CRM application installed!</field>
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
</record>
|
||||
|
||||
<!-- notify all employees of module installation -->
|
||||
<function model="mail.group" name="message_post">
|
||||
<value eval="[ref('mail.group_all_employees')]"/>
|
||||
<function model="mail.channel" name="message_post">
|
||||
<value eval="[ref('mail.channel_all_employees')]"/>
|
||||
<value>From the top menu Events, you can organize events, manage registrations, automate communication around your event and sell events through your quotations.</value>
|
||||
<value>Module Events has been installed</value>
|
||||
</function>
|
||||
|
||||
@@ -149,9 +149,9 @@
|
||||
|
||||
<record model="gamification.goal.definition" id="definition_nbr_following">
|
||||
<field name="name">Mail Group Following</field>
|
||||
<field name="description">Follow mail groups to receive news</field>
|
||||
<field name="description">Follow mail.channels to receive news</field>
|
||||
<field name="computation_mode">python</field>
|
||||
<field name="compute_code">result = pool.get('mail.followers').search(cr, uid, [('res_model', '=', 'mail.group'), ('partner_id', '=', object.user_id.partner_id.id)], count=True, context=context)</field>
|
||||
<field name="compute_code">result = pool.get('mail.followers').search(cr, uid, [('res_model', '=', 'mail.channel'), ('partner_id', '=', object.user_id.partner_id.id)], count=True, context=context)</field>
|
||||
<field name="action_id" eval="ref('mail.action_view_groups')" />
|
||||
</record>
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ class gamification_challenge(osv.Model):
|
||||
('yearly', 'Yearly')
|
||||
],
|
||||
string="Report Frequency", required=True),
|
||||
'report_message_group_id': fields.many2one('mail.group',
|
||||
'report_message_group_id': fields.many2one('mail.channel',
|
||||
string='Send a copy to',
|
||||
help='Group that will receive a copy of the report in addition to the user'),
|
||||
'report_template_id': fields.many2one('mail.template', string="Report Template", required=True),
|
||||
@@ -626,7 +626,7 @@ class gamification_challenge(osv.Model):
|
||||
context=context,
|
||||
subtype='mail.mt_comment')
|
||||
if challenge.report_message_group_id:
|
||||
self.pool.get('mail.group').message_post(cr, uid, challenge.report_message_group_id.id,
|
||||
self.pool.get('mail.channel').message_post(cr, uid, challenge.report_message_group_id.id,
|
||||
body=body_html,
|
||||
context=context,
|
||||
subtype='mail.mt_comment')
|
||||
@@ -648,7 +648,7 @@ class gamification_challenge(osv.Model):
|
||||
context=context,
|
||||
subtype='mail.mt_comment')
|
||||
if challenge.report_message_group_id:
|
||||
self.pool.get('mail.group').message_post(cr, uid, challenge.report_message_group_id.id,
|
||||
self.pool.get('mail.channel').message_post(cr, uid, challenge.report_message_group_id.id,
|
||||
body=body_html,
|
||||
context=context,
|
||||
subtype='mail.mt_comment')
|
||||
|
||||
@@ -259,7 +259,7 @@
|
||||
('model_id', '=', model_id),
|
||||
('model_id', 'in', model_inherited_model_ids and model_inherited_model_ids[0] and model_inherited_model_ids[0][2])]" />
|
||||
<field name="domain" attrs="{'invisible':[('computation_mode','not in',('sum', 'count'))], 'required':[('computation_mode','in',('sum', 'count'))]}" class="oe_inline"/>
|
||||
<field name="compute_code" attrs="{'invisible':[('computation_mode','!=','python')], 'required':[('computation_mode','=','python')]}" placeholder="e.g. result = pool.get('mail.followers').search(cr, uid, [('res_model', '=', 'mail.group'), ('partner_id', '=', object.user_id.partner_id.id)], count=True, context=context)"/>
|
||||
<field name="compute_code" attrs="{'invisible':[('computation_mode','!=','python')], 'required':[('computation_mode','=','python')]}" placeholder="e.g. result = pool.get('mail.followers').search(cr, uid, [('res_model', '=', 'mail.channel'), ('partner_id', '=', object.user_id.partner_id.id)], count=True, context=context)"/>
|
||||
<field name="condition" widget="radio"/>
|
||||
</group>
|
||||
<group string="Optimisation" attrs="{'invisible': [('computation_mode', '!=', 'count')]}">
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
<data noupdate="1">
|
||||
<!-- notify all employees of module installation -->
|
||||
<record model="mail.message" id="module_install_notification">
|
||||
<field name="model">mail.group</field>
|
||||
<field name="res_id" ref="mail.group_all_employees"/>
|
||||
<field name="model">mail.channel</field>
|
||||
<field name="res_id" ref="mail.channel_all_employees"/>
|
||||
<field name="message_type">notification</field>
|
||||
<field name="subtype_id" ref="mail.mt_comment"/>
|
||||
<field name="subject">Employee Directory application installed!</field>
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
</record>
|
||||
<!-- notify all employees of module installation -->
|
||||
<record model="mail.message" id="module_install_notification">
|
||||
<field name="model">mail.group</field>
|
||||
<field name="res_id" ref="mail.group_all_employees"/>
|
||||
<field name="model">mail.channel</field>
|
||||
<field name="res_id" ref="mail.channel_all_employees"/>
|
||||
<field name="message_type">notification</field>
|
||||
<field name="subtype_id" ref="mail.mt_comment"/>
|
||||
<field name="subject">Employee Appraisals application installed!</field>
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
<data noupdate="1">
|
||||
<!-- notify all employees of module installation -->
|
||||
<record model="mail.message" id="module_install_notification">
|
||||
<field name="model">mail.group</field>
|
||||
<field name="res_id" ref="mail.group_all_employees"/>
|
||||
<field name="model">mail.channel</field>
|
||||
<field name="res_id" ref="mail.channel_all_employees"/>
|
||||
<field name="message_type">notification</field>
|
||||
<field name="subtype_id" ref="mail.mt_comment"/>
|
||||
<field name="subject">Expense Management application installed!</field>
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
</record>
|
||||
<!-- notify all employees of module installation -->
|
||||
<record model="mail.message" id="module_install_notification">
|
||||
<field name="model">mail.group</field>
|
||||
<field name="res_id" ref="mail.group_all_employees"/>
|
||||
<field name="model">mail.channel</field>
|
||||
<field name="res_id" ref="mail.channel_all_employees"/>
|
||||
<field name="message_type">notification</field>
|
||||
<field name="subtype_id" ref="mail.mt_comment"/>
|
||||
<field name="subject">Leave Management application installed!</field>
|
||||
|
||||
@@ -501,13 +501,13 @@ class hr_applicant(osv.Model):
|
||||
def _broadcast_welcome(self, cr, uid, employee_id, context=None):
|
||||
""" Broadcast the welcome message to all users in the employee company. """
|
||||
IrModelData = self.pool['ir.model.data']
|
||||
group_all_employees = IrModelData.xmlid_to_object(cr, uid, 'mail.group_all_employees', context=context)
|
||||
group_all_employees = IrModelData.xmlid_to_object(cr, uid, 'mail.channel_all_employees', context=context)
|
||||
template_new_employee = IrModelData.xmlid_to_object(cr, uid, 'hr_recruitment.hr_welcome_new_employee', context=context)
|
||||
if template_new_employee:
|
||||
MailTemplate = self.pool['mail.template']
|
||||
body_html = MailTemplate.render_template(cr, uid, template_new_employee.body_html, 'hr.employee', employee_id, context=context)
|
||||
subject = MailTemplate.render_template(cr, uid, template_new_employee.subject, 'hr.employee', employee_id, context=context)
|
||||
self.pool['mail.group'].message_post(cr, uid, [group_all_employees.id],
|
||||
self.pool['mail.channel'].message_post(cr, uid, [group_all_employees.id],
|
||||
body=body_html, subject=subject,
|
||||
subtype='mail.mt_comment', context=context)
|
||||
return True
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
<data noupdate="1">
|
||||
<!-- notify all employees of module installation -->
|
||||
<record model="mail.message" id="module_install_notification">
|
||||
<field name="model">mail.group</field>
|
||||
<field name="res_id" ref="mail.group_all_employees"/>
|
||||
<field name="model">mail.channel</field>
|
||||
<field name="res_id" ref="mail.channel_all_employees"/>
|
||||
<field name="message_type">notification</field>
|
||||
<field name="subtype_id" ref="mail.mt_comment"/>
|
||||
<field name="subject">Recruitment Process application installed!</field>
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
<data noupdate="1">
|
||||
<!-- notify all employees of module installation -->
|
||||
<record model="mail.message" id="hr_timesheet_module_install_notification">
|
||||
<field name="model">mail.group</field>
|
||||
<field name="res_id" ref="mail.group_all_employees"/>
|
||||
<field name="model">mail.channel</field>
|
||||
<field name="res_id" ref="mail.channel_all_employees"/>
|
||||
<field name="message_type">notification</field>
|
||||
<field name="subtype_id" ref="mail.mt_comment"/>
|
||||
<field name="subject">Timesheet Validation application installed!</field>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<openerp>
|
||||
<data noupdate="1">
|
||||
|
||||
<record model="mail.group" id="group_all_employees">
|
||||
<record model="mail.channel" id="channel_all_employees">
|
||||
<field name="name">Whole Company</field>
|
||||
<field name="group_ids" eval="[(4, ref('base.group_user'))]"/>
|
||||
<field name="description">General announces for all employees.</field>
|
||||
@@ -10,8 +10,8 @@
|
||||
|
||||
<!-- notify all employees of module installation -->
|
||||
<record model="mail.message" id="module_install_notification" context="{'mail_notify_noemail': True}">
|
||||
<field name="model">mail.group</field>
|
||||
<field name="res_id" ref="mail.group_all_employees"/>
|
||||
<field name="model">mail.channel</field>
|
||||
<field name="res_id" ref="mail.channel_all_employees"/>
|
||||
<field name="message_type">notification</field>
|
||||
<field name="subtype_id" ref="mail.mt_comment"/>
|
||||
<field name="subject">Welcome to Odoo!</field>
|
||||
|
||||
@@ -3,40 +3,40 @@
|
||||
<data noupdate="1">
|
||||
|
||||
<!-- Discussion groups, done in 2 steps to remove creator from followers -->
|
||||
<record model="mail.group" id="group_best_sales_practices">
|
||||
<record model="mail.channel" id="channel_best_sales_practices">
|
||||
<field name="name">Best Sales Practices</field>
|
||||
<field name="description">Discussion about best sales practices and deals.</field>
|
||||
</record>
|
||||
<record model="mail.group" id="group_best_sales_practices">
|
||||
<record model="mail.channel" id="channel_best_sales_practices">
|
||||
<field name="message_follower_ids" eval="[(6, 0, [ref('base.partner_demo')])]"/>
|
||||
</record>
|
||||
<record model="mail.group" id="group_board">
|
||||
<record model="mail.channel" id="channel_board">
|
||||
<field name="name">Board meetings</field>
|
||||
<field name="description">Board meetings, budgets, strategic plans</field>
|
||||
</record>
|
||||
<record model="mail.group" id="group_board">
|
||||
<record model="mail.channel" id="channel_board">
|
||||
<field name="message_follower_ids" eval="[(6, 0, [])]"/>
|
||||
</record>
|
||||
<record model="mail.group" id="group_rd">
|
||||
<record model="mail.channel" id="channel_rd">
|
||||
<field name="name">R&D</field>
|
||||
<field name="description">Research and development discussion group</field>
|
||||
</record>
|
||||
<record model="mail.group" id="group_hr_policies">
|
||||
<record model="mail.channel" id="channel_hr_policies">
|
||||
<field name="name">HR Policies</field>
|
||||
<field name="description">Company cars, holidays and other advantages</field>
|
||||
</record>
|
||||
<record model="mail.group" id="group_rd">
|
||||
<record model="mail.channel" id="channel_rd">
|
||||
<field name="message_follower_ids" eval="[(6, 0, [])]"/>
|
||||
</record>
|
||||
<record model="mail.group" id="group_support">
|
||||
<record model="mail.channel" id="channel_support">
|
||||
<field name="name">Support</field>
|
||||
<field name="description">Support team</field>
|
||||
</record>
|
||||
|
||||
<!-- Best sales practices messages -->
|
||||
<record id="msg_group_1_1" model="mail.message">
|
||||
<field name="model">mail.group</field>
|
||||
<field name="res_id" ref="mail.group_best_sales_practices"/>
|
||||
<field name="model">mail.channel</field>
|
||||
<field name="res_id" ref="mail.channel_best_sales_practices"/>
|
||||
<field name="body"><![CDATA[<p>Selling a training session and selling the products after the training session is more efficient than directly selling a pack with the training session and the products.</p>]]></field>
|
||||
<field name="message_type">comment</field>
|
||||
<field name="subtype_id" ref="mt_comment"/>
|
||||
@@ -44,8 +44,8 @@
|
||||
<field name="date" eval="(DateTime.today() - timedelta(days=5)).strftime('%Y-%m-%d %H:%M')"/>
|
||||
</record>
|
||||
<record id="msg_group_1_2" model="mail.message">
|
||||
<field name="model">mail.group</field>
|
||||
<field name="res_id" ref="mail.group_best_sales_practices"/>
|
||||
<field name="model">mail.channel</field>
|
||||
<field name="res_id" ref="mail.channel_best_sales_practices"/>
|
||||
<field name="body"><![CDATA[<p>I noted I can not manage efficiently my pipeline when I have more than 50 opportunities in the qualification stage.</p><p>Any advice on this? How do you organize your activities with more than 50 opportunities?</p>]]></field>
|
||||
<field name="message_type">comment</field>
|
||||
<field name="subtype_id" ref="mt_comment"/>
|
||||
@@ -53,8 +53,8 @@
|
||||
<field name="date" eval="(DateTime.today() - timedelta(days=4)).strftime('%Y-%m-%d %H:%M')"/>
|
||||
</record>
|
||||
<record id="msg_group_1_3" model="mail.message">
|
||||
<field name="model">mail.group</field>
|
||||
<field name="res_id" ref="mail.group_best_sales_practices"/>
|
||||
<field name="model">mail.channel</field>
|
||||
<field name="res_id" ref="mail.channel_best_sales_practices"/>
|
||||
<field name="body"><![CDATA[<p>When I have too much opportunities in the pipe, I start communicating with prospects more by email than phonecalls.</p><p>I send an email to create a sense of emergency, like <i>"can I call you this week about our quote?"</i> and I call only those that answer this email.</p><p>You can use the email template feature of Odoo to automate email composition.</p>]]></field>
|
||||
<field name="message_type">comment</field>
|
||||
<field name="parent_id" ref="msg_group_1_2"/>
|
||||
@@ -64,8 +64,8 @@
|
||||
<field name="date" eval="(DateTime.today() - timedelta(days=3)).strftime('%Y-%m-%d %H:%M')"/>
|
||||
</record>
|
||||
<record id="msg_group_1_4" model="mail.message">
|
||||
<field name="model">mail.group</field>
|
||||
<field name="res_id" ref="mail.group_best_sales_practices"/>
|
||||
<field name="model">mail.channel</field>
|
||||
<field name="res_id" ref="mail.channel_best_sales_practices"/>
|
||||
<field name="body"><![CDATA[<p>When you sell a tablet PC, don't forget to propose a docking station with it. I offer 20% on the docking stating (not the tablet) and I have a 70% success rate with this combo.</p>]]></field>
|
||||
<field name="message_type">comment</field>
|
||||
<field name="subtype_id" ref="mt_comment"/>
|
||||
@@ -76,16 +76,16 @@
|
||||
|
||||
<!-- Pushed to all employees -->
|
||||
<record id="msg_empl_1" model="mail.message">
|
||||
<field name="model">mail.group</field>
|
||||
<field name="res_id" ref="mail.group_hr_policies"/>
|
||||
<field name="model">mail.channel</field>
|
||||
<field name="res_id" ref="mail.channel_hr_policies"/>
|
||||
<field name="body"><![CDATA[<p>Your monthly meal vouchers arrived. You can get them at the HR's office.</p>]]></field>
|
||||
<field name="message_type">comment</field>
|
||||
<field name="author_id" ref="base.partner_demo"/>
|
||||
<field name="date" eval="(DateTime.today() - timedelta(hours=1)).strftime('%Y-%m-%d %H:%M')"/>
|
||||
</record>
|
||||
<record id="msg_empl_1_1" model="mail.message">
|
||||
<field name="model">mail.group</field>
|
||||
<field name="res_id" ref="group_hr_policies"/>
|
||||
<field name="model">mail.channel</field>
|
||||
<field name="res_id" ref="channel_hr_policies"/>
|
||||
<field name="body"><![CDATA[<p>Oh, I had forgotten. This month you also get 250 EUR of eco-vouchers if you have been in the company for more than a year.</p>]]></field>
|
||||
<field name="parent_id" ref="msg_empl_1"/>
|
||||
<field name="message_type">comment</field>
|
||||
@@ -93,8 +93,8 @@
|
||||
<field name="date" eval="(DateTime.today() - timedelta(minutes=57)).strftime('%Y-%m-%d %H:%M')"/>
|
||||
</record>
|
||||
<record id="msg_empl_1_2" model="mail.message">
|
||||
<field name="model">mail.group</field>
|
||||
<field name="res_id" ref="group_hr_policies"/>
|
||||
<field name="model">mail.channel</field>
|
||||
<field name="res_id" ref="channel_hr_policies"/>
|
||||
<field name="body"><![CDATA[<p>Thanks! Could you please remind me where is Christine's office, if I may ask? I'm new here!</p>]]></field>
|
||||
<field name="parent_id" ref="msg_empl_1"/>
|
||||
<field name="message_type">comment</field>
|
||||
@@ -102,8 +102,8 @@
|
||||
<field name="date" eval="(DateTime.today() - timedelta(minutes=34)).strftime('%Y-%m-%d %H:%M')"/>
|
||||
</record>
|
||||
<record id="msg_empl_1_3" model="mail.message">
|
||||
<field name="model">mail.group</field>
|
||||
<field name="res_id" ref="group_hr_policies"/>
|
||||
<field name="model">mail.channel</field>
|
||||
<field name="res_id" ref="channel_hr_policies"/>
|
||||
<field name="body"><![CDATA[<p>Building B3, second floor on the right :-).</p>]]></field>
|
||||
<field name="parent_id" ref="msg_empl_1"/>
|
||||
<field name="message_type">comment</field>
|
||||
@@ -113,8 +113,8 @@
|
||||
|
||||
<!-- Board messages -->
|
||||
<record id="msg_board_1" model="mail.message">
|
||||
<field name="model">mail.group</field>
|
||||
<field name="res_id" ref="mail.group_board"/>
|
||||
<field name="model">mail.channel</field>
|
||||
<field name="res_id" ref="mail.channel_board"/>
|
||||
<field name="body"><![CDATA[
|
||||
<p>
|
||||
Dear Board Members,
|
||||
@@ -176,8 +176,8 @@
|
||||
|
||||
<!-- Whole Company messages -->
|
||||
<record id="msg_whole_1_1" model="mail.message">
|
||||
<field name="model">mail.group</field>
|
||||
<field name="res_id" ref="mail.group_all_employees"/>
|
||||
<field name="model">mail.channel</field>
|
||||
<field name="res_id" ref="mail.channel_all_employees"/>
|
||||
<field name="body"><![CDATA[
|
||||
<p>
|
||||
Great news!<br/>
|
||||
|
||||
@@ -5,26 +5,26 @@ from openerp import api, fields, models
|
||||
|
||||
class IrUiMenu(models.Model):
|
||||
""" Override of ir.ui.menu class. When adding mail_thread module, each
|
||||
new mail.group will create a menu entry. This overrides checks that
|
||||
the current user is in the mail.group followers. If not, the menu
|
||||
new mail.channel will create a menu entry. This overrides checks that
|
||||
the current user is in the mail.channel followers. If not, the menu
|
||||
entry is taken off the list of menu ids. This way the user will see
|
||||
menu entries for the mail.group he is following.
|
||||
menu entries for the mail.channel he is following.
|
||||
"""
|
||||
_inherit = 'ir.ui.menu'
|
||||
|
||||
mail_group_id = fields.Many2one('mail.group', 'Mail Group')
|
||||
mail_channel_id = fields.Many2one('mail.channel', 'Mail Group')
|
||||
|
||||
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
|
||||
""" Remove mail.group menu entries when the user is not a follower."""
|
||||
""" Remove mail.channel menu entries when the user is not a follower."""
|
||||
ids = super(IrUiMenu, self).search(cr, uid, args, offset=offset,
|
||||
limit=limit, order=order,
|
||||
context=context, count=False)
|
||||
if ids:
|
||||
cr.execute("""
|
||||
SELECT id FROM ir_ui_menu m
|
||||
WHERE m.mail_group_id IS NULL OR EXISTS (
|
||||
WHERE m.mail_channel_id IS NULL OR EXISTS (
|
||||
SELECT 1 FROM mail_followers
|
||||
WHERE res_model = 'mail.group' AND res_id = m.mail_group_id
|
||||
WHERE res_model = 'mail.channel' AND res_id = m.mail_channel_id
|
||||
AND partner_id = (SELECT partner_id FROM res_users WHERE id = %s)
|
||||
) AND id in %s
|
||||
""", (uid, tuple(ids)))
|
||||
|
||||
@@ -5,10 +5,10 @@ from openerp.exceptions import UserError
|
||||
|
||||
|
||||
class MailGroup(models.Model):
|
||||
""" A mail_group is a collection of users sharing messages in a discussion
|
||||
""" A mail.channel is a collection of users sharing messages in a discussion
|
||||
group. The group mechanics are based on the followers. """
|
||||
_description = 'Discussion group'
|
||||
_name = 'mail.group'
|
||||
_name = 'mail.channel'
|
||||
_mail_flat_thread = False
|
||||
_mail_post_access = 'read'
|
||||
_inherit = ['mail.thread']
|
||||
@@ -30,8 +30,8 @@ class MailGroup(models.Model):
|
||||
group_public_id = fields.Many2one('res.groups', string='Authorized Group',
|
||||
default=lambda self: self.env.ref('base.group_user'))
|
||||
group_ids = fields.Many2many(
|
||||
'res.groups', rel='mail_group_res_group_rel',
|
||||
id1='mail_group_id', id2='groups_id', string='Auto Subscription',
|
||||
'res.groups', rel='mail_channel_res_group_rel',
|
||||
id1='mail_channel_id', id2='groups_id', string='Auto Subscription',
|
||||
help="Members of those groups will automatically added as followers. "
|
||||
"Note that they will be able to manage their subscription manually "
|
||||
"if necessary.")
|
||||
@@ -79,8 +79,8 @@ class MailGroup(models.Model):
|
||||
# Create action window for this group and link the menu to it
|
||||
inbox_ref = self.env.ref('mail.action_mail_group_feeds')
|
||||
search_ref = self.env.ref('mail.view_message_search')
|
||||
act_domain = [('model', '=', 'mail.group'), ('res_id', '=', group.id)]
|
||||
act_context = {'default_model': 'mail.group',
|
||||
act_domain = [('model', '=', 'mail.channel'), ('res_id', '=', group.id)]
|
||||
act_context = {'default_model': 'mail.channel',
|
||||
'default_res_id': group.id,
|
||||
'options': {'view_mailbox': False,
|
||||
'view_inbox': True,
|
||||
@@ -97,7 +97,7 @@ class MailGroup(models.Model):
|
||||
'res_model': act_res_model,
|
||||
'search_view_id': act_search_view_id,
|
||||
'name': vals['name']})
|
||||
menu.write({'action': 'ir.actions.act_window,%d' % new_action.id, 'mail_group_id': group.id})
|
||||
menu.write({'action': 'ir.actions.act_window,%d' % new_action.id, 'mail_channel_id': group.id})
|
||||
|
||||
if vals.get('group_ids'):
|
||||
group._subscribe_users()
|
||||
@@ -108,15 +108,15 @@ class MailGroup(models.Model):
|
||||
aliases = self.mapped('alias_id')
|
||||
menus = self.mapped('menu_id')
|
||||
|
||||
# Delete mail_group
|
||||
# Delete mail.channel
|
||||
try:
|
||||
all_emp_group = self.env.ref('mail.group_all_employees')
|
||||
all_emp_group = self.env.ref('mail.channel_all_employees')
|
||||
except ValueError:
|
||||
all_emp_group = None
|
||||
if all_emp_group and all_emp_group in self:
|
||||
raise UserError(_('You cannot delete those groups, as the Whole Company group is required by other modules.'))
|
||||
res = super(MailGroup, self).unlink()
|
||||
# Cascade-delete mail aliases as well, as they should not exist without the mail group.
|
||||
# Cascade-delete mail aliases as well, as they should not exist without the mail.channel.
|
||||
aliases.sudo().unlink()
|
||||
# Cascade-delete menu entries as well
|
||||
menus.sudo().unlink()
|
||||
@@ -148,9 +148,9 @@ class MailGroup(models.Model):
|
||||
_generate_header_description = _get_header
|
||||
|
||||
def _subscribe_users(self):
|
||||
for mail_group in self:
|
||||
partner_ids = mail_group.mapped('group_ids').mapped('users').mapped('partner_id')
|
||||
mail_group.message_subscribe(partner_ids.ids)
|
||||
for mail_channel in self:
|
||||
partner_ids = mail_channel.mapped('group_ids').mapped('users').mapped('partner_id')
|
||||
mail_channel.message_subscribe(partner_ids.ids)
|
||||
|
||||
@api.multi
|
||||
def action_follow(self):
|
||||
|
||||
@@ -159,9 +159,9 @@ class Notification(models.Model):
|
||||
|
||||
# compute email body (signature, company data)
|
||||
body_html = message.body
|
||||
# add user signature except for mail groups, where users are usually adding their own signatures already
|
||||
# add user signature except for mail.channels, where users are usually adding their own signatures already
|
||||
user_id = message.author_id and message.author_id.user_ids and message.author_id.user_ids[0] and message.author_id.user_ids[0].id or None
|
||||
signature_company = self.get_signature_footer(user_id, res_model=message.model, res_id=message.res_id, user_signature=(user_signature and message.model != 'mail.group'))
|
||||
signature_company = self.get_signature_footer(user_id, res_model=message.model, res_id=message.res_id, user_signature=(user_signature and message.model != 'mail.channel'))
|
||||
if signature_company:
|
||||
body_html = tools.append_content_to_html(body_html, signature_company, plaintext=False, container_tag='div')
|
||||
|
||||
|
||||
@@ -123,9 +123,9 @@ class Users(models.Model):
|
||||
return dict((res_id, list()) for res_id in self._ids)
|
||||
|
||||
|
||||
class res_users_mail_group(models.Model):
|
||||
class res_users_mail_channel(models.Model):
|
||||
""" Update of res.users class
|
||||
- if adding groups to an user, check mail.groups linked to this user
|
||||
- if adding groups to an user, check mail.channels linked to this user
|
||||
group, and the user. This is done by overriding the write method.
|
||||
"""
|
||||
_name = 'res.users'
|
||||
@@ -133,18 +133,18 @@ class res_users_mail_group(models.Model):
|
||||
|
||||
@api.multi
|
||||
def write(self, vals):
|
||||
write_res = super(res_users_mail_group, self).write(vals)
|
||||
write_res = super(res_users_mail_channel, self).write(vals)
|
||||
if vals.get('groups_id'):
|
||||
# form: {'group_ids': [(3, 10), (3, 3), (4, 10), (4, 3)]} or {'group_ids': [(6, 0, [ids]}
|
||||
user_group_ids = [command[1] for command in vals['groups_id'] if command[0] == 4]
|
||||
user_group_ids += [id for command in vals['groups_id'] if command[0] == 6 for id in command[2]]
|
||||
self.env['mail.group'].search([('group_ids', 'in', user_group_ids)]).message_subscribe_users(self._ids)
|
||||
self.env['mail.channel'].search([('group_ids', 'in', user_group_ids)]).message_subscribe_users(self._ids)
|
||||
return write_res
|
||||
|
||||
|
||||
class res_groups_mail_group(models.Model):
|
||||
class res_groups_mail_channel(models.Model):
|
||||
""" Update of res.groups class
|
||||
- if adding users from a group, check mail.groups linked to this user
|
||||
- if adding users from a group, check mail.channels linked to this user
|
||||
group and subscribe them. This is done by overriding the write method.
|
||||
"""
|
||||
_name = 'res.groups'
|
||||
@@ -152,10 +152,10 @@ class res_groups_mail_group(models.Model):
|
||||
|
||||
@api.multi
|
||||
def write(self, vals, context=None):
|
||||
write_res = super(res_groups_mail_group, self).write(vals)
|
||||
write_res = super(res_groups_mail_channel, self).write(vals)
|
||||
if vals.get('users'):
|
||||
# form: {'group_ids': [(3, 10), (3, 3), (4, 10), (4, 3)]} or {'group_ids': [(6, 0, [ids]}
|
||||
user_ids = [command[1] for command in vals['users'] if command[0] == 4]
|
||||
user_ids += [id for command in vals['users'] if command[0] == 6 for id in command[2]]
|
||||
self.env['mail.group'].search([('group_ids', 'in', self._ids)]).message_subscribe_users(user_ids)
|
||||
self.env['mail.channel'].search([('group_ids', 'in', self._ids)]).message_subscribe_users(user_ids)
|
||||
return write_res
|
||||
|
||||
@@ -93,7 +93,7 @@ class publisher_warranty_contract(AbstractModel):
|
||||
# old behavior based on res.log; now on mail.message, that is not necessarily installed
|
||||
IMD = self.pool['ir.model.data']
|
||||
user = self.pool['res.users'].browse(cr, SUPERUSER_ID, SUPERUSER_ID)
|
||||
poster = IMD.xmlid_to_object(cr, SUPERUSER_ID, 'mail.group_all_employees', context=context)
|
||||
poster = IMD.xmlid_to_object(cr, SUPERUSER_ID, 'mail.channel_all_employees', context=context)
|
||||
if not (poster and poster.exists()):
|
||||
if not user.exists():
|
||||
return True
|
||||
|
||||
@@ -14,8 +14,8 @@ access_mail_notification_all,mail.notification.all,model_mail_notification,,1,0,
|
||||
access_mail_notification_portal,mail.notification.portal,model_mail_notification,base.group_portal,1,1,1,0
|
||||
access_mail_notification_user,mail.notification.user,model_mail_notification,base.group_user,1,1,1,0
|
||||
access_mail_notification_system,mail.notification.system,model_mail_notification,base.group_system,1,1,1,1
|
||||
access_mail_group_all,mail.group.all,model_mail_group,,1,0,0,0
|
||||
access_mail_group_user,mail.group.user,model_mail_group,base.group_user,1,1,1,1
|
||||
access_mail_channel_all,mail.group.all,model_mail_channel,,1,0,0,0
|
||||
access_mail_channel_user,mail.group.user,model_mail_channel,base.group_user,1,1,1,1
|
||||
access_mail_alias_all,mail.alias.all,model_mail_alias,,1,0,0,0
|
||||
access_mail_alias_user,mail.alias.user,model_mail_alias,base.group_user,1,1,1,0
|
||||
access_mail_alias_system,mail.alias.system,model_mail_alias,base.group_system,1,1,1,1
|
||||
|
||||
|
@@ -3,9 +3,9 @@
|
||||
<data noupdate="1">
|
||||
|
||||
<!-- RULES -->
|
||||
<record id="mail_group_public_and_joined" model="ir.rule">
|
||||
<field name="name">Mail.group: access only public and joined groups</field>
|
||||
<field name="model_id" ref="model_mail_group"/>
|
||||
<record id="mail_channel_rule" model="ir.rule">
|
||||
<field name="name">Mail.channel: access only public and joined groups</field>
|
||||
<field name="model_id" ref="model_mail_channel"/>
|
||||
<!-- This rule has to be improved for employee only groups -->
|
||||
<field name="domain_force">['|', '|', ('public', '=', 'public'), ('message_follower_ids', 'in', [user.partner_id.id]), '&', ('public','=','groups'), ('group_public_id','in', [g.id for g in user.groups_id])]</field>
|
||||
<field name="perm_create" eval="False"/>
|
||||
|
||||
@@ -3,28 +3,28 @@
|
||||
/* ------------------------------ */
|
||||
|
||||
/* Resize sheet width */
|
||||
.o_web_client .oe_form_sheetbg.o_web_client_mail_group_sheet {
|
||||
.o_web_client .oe_form_sheetbg.o_web_client_mail_channel_sheet {
|
||||
min-height: 0px;
|
||||
max-height: none;
|
||||
}
|
||||
|
||||
.o_web_client .oe_form_sheetbg.o_web_client_mail_group_sheet .oe_form_sheet {
|
||||
.o_web_client .oe_form_sheetbg.o_web_client_mail_channel_sheet .oe_form_sheet {
|
||||
min-height: 0px;
|
||||
max-height: none;
|
||||
padding: 0px 18px;
|
||||
}
|
||||
|
||||
.o_web_client .oe_form_sheetbg.o_web_client_mail_group_sheet .oe_avatar {
|
||||
.o_web_client .oe_form_sheetbg.o_web_client_mail_channel_sheet .oe_avatar {
|
||||
padding-top: 3px;
|
||||
}
|
||||
|
||||
/* Resize footer width */
|
||||
.o_web_client .oe_form div.oe_mail_group_footer {
|
||||
.o_web_client .oe_form div.oe_mail_channel_footer {
|
||||
max-width: 80%;
|
||||
}
|
||||
|
||||
/* Resize group description */
|
||||
.o_web_client .oe_form_sheetbg.o_web_client_mail_group_sheet .oe_form_field_text > textarea {
|
||||
.o_web_client .oe_form_sheetbg.o_web_client_mail_channel_sheet .oe_form_field_text > textarea {
|
||||
height: 60px;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class TestMail(common.SavepointCase):
|
||||
def format_and_process(self, template, to='groups@example.com, other@gmail.com', subject='Frogs',
|
||||
extra='', email_from='Sylvie Lelitre <test.sylvie.lelitre@agrolait.com>',
|
||||
cc='', msg_id='<1198923581.41972151344608186760.JavaMail@agrolait.com>',
|
||||
model=None, target_model='mail.group', target_field='name'):
|
||||
model=None, target_model='mail.channel', target_field='name'):
|
||||
self.assertFalse(self.env[target_model].search([(target_field, '=', subject)]))
|
||||
mail = template.format(to=to, subject=subject, cc=cc, extra=extra, email_from=email_from, msg_id=msg_id)
|
||||
self.env['mail.thread'].message_process(model, mail)
|
||||
@@ -115,7 +115,7 @@ class TestMail(common.SavepointCase):
|
||||
'notify_email': 'always'})
|
||||
|
||||
# Create test groups without followers and messages by default
|
||||
TestMailGroup = cls.env['mail.group'].with_context({
|
||||
TestMailGroup = cls.env['mail.channel'].with_context({
|
||||
'mail_create_nolog': True,
|
||||
'mail_create_nosubscribe': True
|
||||
})
|
||||
@@ -148,17 +148,17 @@ class TestMail(common.SavepointCase):
|
||||
'group_public_id': user_group_portal.id}
|
||||
).with_context({'mail_create_nosubscribe': False})
|
||||
|
||||
# groups@.. will cause the creation of new mail groups
|
||||
cls.mail_group_model = cls.env['ir.model'].search([('model', '=', 'mail.group')], limit=1)
|
||||
# groups@.. will cause the creation of new mail channels
|
||||
cls.mail_channel_model = cls.env['ir.model'].search([('model', '=', 'mail.channel')], limit=1)
|
||||
cls.alias = cls.env['mail.alias'].create({
|
||||
'alias_name': 'groups',
|
||||
'alias_user_id': False,
|
||||
'alias_model_id': cls.mail_group_model.id,
|
||||
'alias_model_id': cls.mail_channel_model.id,
|
||||
'alias_contact': 'everyone'})
|
||||
|
||||
# Set a first message on public group to test update and hierarchy
|
||||
cls.fake_email = cls.env['mail.message'].create({
|
||||
'model': 'mail.group',
|
||||
'model': 'mail.channel',
|
||||
'res_id': cls.group_public.id,
|
||||
'subject': 'Public Discussion',
|
||||
'message_type': 'email',
|
||||
|
||||
@@ -9,7 +9,7 @@ class TestInvite(TestMail):
|
||||
@mute_logger('openerp.addons.mail.models.mail_mail')
|
||||
def test_invite_email(self):
|
||||
mail_invite = self.env['mail.wizard.invite'].with_context({
|
||||
'default_res_model': 'mail.group',
|
||||
'default_res_model': 'mail.channel',
|
||||
'default_res_id': self.group_pigs.id
|
||||
}).sudo(self.user_employee.id).create({
|
||||
'partner_ids': [(4, self.user_portal.partner_id.id), (4, self.user_employee_2.partner_id.id)],
|
||||
|
||||
@@ -26,7 +26,7 @@ class TestMailGroup(TestMail):
|
||||
|
||||
# Create group: ko, no access rights
|
||||
with self.assertRaises(AccessError):
|
||||
self.env['mail.group'].sudo(self.user_public).create({'name': 'Test'})
|
||||
self.env['mail.channel'].sudo(self.user_public).create({'name': 'Test'})
|
||||
|
||||
# Update group: ko, no access rights
|
||||
with self.assertRaises(AccessError):
|
||||
@@ -43,7 +43,7 @@ class TestMailGroup(TestMail):
|
||||
self.group_pigs.sudo(self.user_employee).read()
|
||||
|
||||
# Employee can create a group
|
||||
self.env['mail.group'].sudo(self.user_employee).create({'name': 'Test'})
|
||||
self.env['mail.channel'].sudo(self.user_employee).create({'name': 'Test'})
|
||||
|
||||
# Employee update employee-based group: ok
|
||||
self.group_pigs.sudo(self.user_employee).write({'name': 'modified'})
|
||||
|
||||
@@ -48,7 +48,7 @@ class TestMailFeatures(TestMail):
|
||||
|
||||
def test_mail_notification_url_user_document(self):
|
||||
base_url = self.env['ir.config_parameter'].get_param('web.base.url')
|
||||
mail = self.env['mail.mail'].create({'state': 'exception', 'model': 'mail.group', 'res_id': self.group_pigs.id})
|
||||
mail = self.env['mail.mail'].create({'state': 'exception', 'model': 'mail.channel', 'res_id': self.group_pigs.id})
|
||||
url = mail._get_partner_access_link(self.user_employee.partner_id)
|
||||
self.assertIn(base_url, url)
|
||||
self.assertIn('db=%s' % self.env.cr.dbname, url,
|
||||
@@ -57,7 +57,7 @@ class TestMailFeatures(TestMail):
|
||||
'notification email: link should contain the redirect action')
|
||||
self.assertIn('login=%s' % self.user_employee.login, url,
|
||||
'notification email: link should contain the user login')
|
||||
self.assertIn('model=mail.group', url,
|
||||
self.assertIn('model=mail.channel', url,
|
||||
'notification email: link should contain the model when having not notification email on a record')
|
||||
self.assertIn('res_id=%s' % self.group_pigs.id, url,
|
||||
'notification email: link should contain the res_id when having not notification email on a record')
|
||||
@@ -78,7 +78,7 @@ class TestMailFeatures(TestMail):
|
||||
def test_inbox_redirection_document(self):
|
||||
""" Inbox redirection: document + read access: Doc """
|
||||
action = self.env['mail.thread'].with_context({
|
||||
'params': {'model': 'mail.group', 'res_id': self.group_pigs.id}
|
||||
'params': {'model': 'mail.channel', 'res_id': self.group_pigs.id}
|
||||
}).sudo(self.user_employee).message_redirect_action()
|
||||
self.assertEqual(
|
||||
action.get('type'), 'ir.actions.act_window',
|
||||
@@ -127,7 +127,7 @@ class TestMailFeatures(TestMail):
|
||||
""" Inbox redirection: document without read access: Inbox """
|
||||
inbox_act_id = self.ref('mail.action_mail_inbox_feeds')
|
||||
action = self.env['mail.thread'].with_context({
|
||||
'params': {'model': 'mail.group', 'res_id': self.group_pigs.id}
|
||||
'params': {'model': 'mail.channel', 'res_id': self.group_pigs.id}
|
||||
}).sudo(self.user_public).message_redirect_action()
|
||||
self.assertEqual(
|
||||
action.get('type'), 'ir.actions.act_window',
|
||||
@@ -239,8 +239,8 @@ class TestMessagePost(TestMail):
|
||||
self.assertEqual(msg.partner_ids, self.partner_1 | self.partner_2)
|
||||
self.assertEqual(msg.notified_partner_ids, self.partner_1 | self.partner_2 | self.user_employee_2.partner_id)
|
||||
# attachments
|
||||
self.assertEqual(set(msg.attachment_ids.mapped('res_model')), set(['mail.group']),
|
||||
'message_post: all atttachments should be linked to the mail.group model')
|
||||
self.assertEqual(set(msg.attachment_ids.mapped('res_model')), set(['mail.channel']),
|
||||
'message_post: all atttachments should be linked to the mail.channel model')
|
||||
self.assertEqual(set(msg.attachment_ids.mapped('res_id')), set([self.group_pigs.id]),
|
||||
'message_post: all atttachments should be linked to the pigs group')
|
||||
self.assertEqual(set([x.decode('base64') for x in msg.attachment_ids.mapped('datas')]),
|
||||
@@ -292,7 +292,7 @@ class TestMessagePost(TestMail):
|
||||
self.assertEqual(msg.parent_id.id, parent_msg.id)
|
||||
self.assertEqual(msg.notified_partner_ids, self.partner_1)
|
||||
self.assertEqual(parent_msg.notified_partner_ids, self.partner_1)
|
||||
self.assertTrue(all('openerp-%d-mail.group' % self.group_pigs.id in m['references'] for m in self._mails))
|
||||
self.assertTrue(all('openerp-%d-mail.channel' % self.group_pigs.id in m['references'] for m in self._mails))
|
||||
new_msg = self.group_pigs.sudo(self.user_employee).message_post(
|
||||
body=_body, subject=_subject,
|
||||
message_type='comment', subtype='mt_comment', parent_id=msg.id)
|
||||
@@ -304,14 +304,14 @@ class TestMessagePost(TestMail):
|
||||
def test_message_compose(self):
|
||||
composer = self.env['mail.compose.message'].with_context({
|
||||
'default_composition_mode': 'comment',
|
||||
'default_model': 'mail.group',
|
||||
'default_model': 'mail.channel',
|
||||
'default_res_id': self.group_pigs.id,
|
||||
}).sudo(self.user_employee).create({
|
||||
'body': '<p>Test Body</p>',
|
||||
'partner_ids': [(4, self.partner_1.id), (4, self.partner_2.id)]
|
||||
})
|
||||
self.assertEqual(composer.composition_mode, 'comment')
|
||||
self.assertEqual(composer.model, 'mail.group')
|
||||
self.assertEqual(composer.model, 'mail.channel')
|
||||
self.assertEqual(composer.subject, 'Re: %s' % self.group_pigs.name)
|
||||
self.assertEqual(composer.record_name, self.group_pigs.name)
|
||||
|
||||
@@ -324,7 +324,7 @@ class TestMessagePost(TestMail):
|
||||
'default_parent_id': message.id
|
||||
}).sudo(self.user_employee).create({})
|
||||
|
||||
self.assertEqual(composer.model, 'mail.group')
|
||||
self.assertEqual(composer.model, 'mail.channel')
|
||||
self.assertEqual(composer.res_id, self.group_pigs.id)
|
||||
self.assertEqual(composer.parent_id, message)
|
||||
self.assertEqual(composer.subject, 'Re: %s' % self.group_pigs.name)
|
||||
@@ -335,7 +335,7 @@ class TestMessagePost(TestMail):
|
||||
def test_message_compose_mass_mail(self):
|
||||
composer = self.env['mail.compose.message'].with_context({
|
||||
'default_composition_mode': 'mass_mail',
|
||||
'default_model': 'mail.group',
|
||||
'default_model': 'mail.channel',
|
||||
'default_res_id': False,
|
||||
'active_ids': [self.group_pigs.id, self.group_public.id]
|
||||
}).sudo(self.user_employee).create({
|
||||
@@ -379,7 +379,7 @@ class TestMessagePost(TestMail):
|
||||
# self.assertIn(message2.id, messages.ids, 'compose wizard: Bird did not receive its mass mailing message')
|
||||
|
||||
# check followers ?
|
||||
# Test: mail.group followers: author not added as follower in mass mail mode
|
||||
# Test: mail.channel followers: author not added as follower in mass mail mode
|
||||
# self.assertEqual(set(group_pigs.message_follower_ids.ids), set([self.partner_admin_id, p_b.id, p_c.id, p_d.id]),
|
||||
# 'compose wizard: mail_post_autofollow and mail_create_nosubscribe context keys not correctly taken into account')
|
||||
# self.assertEqual(set(group_bird.message_follower_ids.ids), set([self.partner_admin_id]),
|
||||
@@ -389,7 +389,7 @@ class TestMessagePost(TestMail):
|
||||
def test_message_compose_mass_mail_active_domain(self):
|
||||
composer = self.env['mail.compose.message'].with_context({
|
||||
'default_composition_mode': 'mass_mail',
|
||||
'default_model': 'mail.group',
|
||||
'default_model': 'mail.channel',
|
||||
'active_ids': [self.group_pigs.id],
|
||||
'active_domain': [('name', 'in', ['%s' % self.group_pigs.name, '%s' % self.group_public.name])],
|
||||
}).sudo(self.user_employee).create({
|
||||
|
||||
@@ -8,16 +8,16 @@ class TestMailFollowers(TestMail):
|
||||
def setUp(self):
|
||||
super(TestMailFollowers, self).setUp()
|
||||
Subtype = self.env['mail.message.subtype']
|
||||
self.mt_mg_def = Subtype.create({'name': 'mt_mg_def', 'default': True, 'res_model': 'mail.group'})
|
||||
self.mt_mg_def = Subtype.create({'name': 'mt_mg_def', 'default': True, 'res_model': 'mail.channel'})
|
||||
self.mt_cl_def = Subtype.create({'name': 'mt_cl_def', 'default': True, 'res_model': 'crm.lead'})
|
||||
self.mt_al_def = Subtype.create({'name': 'mt_al_def', 'default': True, 'res_model': False})
|
||||
self.mt_mg_nodef = Subtype.create({'name': 'mt_mg_nodef', 'default': False, 'res_model': 'mail.group'})
|
||||
self.mt_mg_nodef = Subtype.create({'name': 'mt_mg_nodef', 'default': False, 'res_model': 'mail.channel'})
|
||||
self.mt_al_nodef = Subtype.create({'name': 'mt_al_nodef', 'default': False, 'res_model': False})
|
||||
self.default_group_subtypes = Subtype.search([('default', '=', True), '|', ('res_model', '=', 'mail.group'), ('res_model', '=', False)])
|
||||
self.default_group_subtypes = Subtype.search([('default', '=', True), '|', ('res_model', '=', 'mail.channel'), ('res_model', '=', False)])
|
||||
|
||||
def test_message_follower_ids_commands(self):
|
||||
# Create some dummy data on other groups to ensure they are not altered
|
||||
group_dummy = self.env['mail.group'].with_context({'mail_create_nolog': True}).create({'name': 'Dummy group'})
|
||||
group_dummy = self.env['mail.channel'].with_context({'mail_create_nolog': True}).create({'name': 'Dummy group'})
|
||||
self.env['mail.followers'].create({'res_model': 'mail.thread', 'res_id': group_dummy.id, 'partner_id': self.partner_1.id})
|
||||
|
||||
# Add 2 followers through the (4, ID) command
|
||||
@@ -51,7 +51,7 @@ class TestMailFollowers(TestMail):
|
||||
self.group_pigs.message_subscribe_users(user_ids=[self.user_employee.id])
|
||||
self.assertEqual(self.group_pigs.message_follower_ids, self.user_employee.partner_id)
|
||||
follower = self.env['mail.followers'].search([
|
||||
('res_model', '=', 'mail.group'),
|
||||
('res_model', '=', 'mail.channel'),
|
||||
('res_id', '=', self.group_pigs.id),
|
||||
('partner_id', '=', self.user_employee.partner_id.id)])
|
||||
self.assertEqual(len(follower), 1)
|
||||
@@ -61,7 +61,7 @@ class TestMailFollowers(TestMail):
|
||||
self.group_pigs.sudo(self.user_employee).message_subscribe_users(subtype_ids=[self.mt_mg_nodef.id])
|
||||
self.assertEqual(self.group_pigs.message_follower_ids, self.user_employee.partner_id)
|
||||
follower = self.env['mail.followers'].search([
|
||||
('res_model', '=', 'mail.group'),
|
||||
('res_model', '=', 'mail.channel'),
|
||||
('res_id', '=', self.group_pigs.id),
|
||||
('partner_id', '=', self.user_employee.partner_id.id)])
|
||||
self.assertEqual(len(follower), 1)
|
||||
@@ -71,7 +71,7 @@ class TestMailFollowers(TestMail):
|
||||
self.group_pigs.sudo(self.user_employee).message_subscribe_users(subtype_ids=[self.mt_mg_nodef.id])
|
||||
self.assertEqual(self.group_pigs.message_follower_ids, self.user_employee.partner_id)
|
||||
follower = self.env['mail.followers'].search([
|
||||
('res_model', '=', 'mail.group'),
|
||||
('res_model', '=', 'mail.channel'),
|
||||
('res_id', '=', self.group_pigs.id),
|
||||
('partner_id', '=', self.user_employee.partner_id.id)])
|
||||
self.assertEqual(len(follower), 1)
|
||||
@@ -80,7 +80,7 @@ class TestMailFollowers(TestMail):
|
||||
self.group_pigs.sudo(self.user_employee).message_subscribe_users(subtype_ids=[self.mt_mg_nodef.id, self.mt_al_nodef.id])
|
||||
self.assertEqual(self.group_pigs.message_follower_ids, self.user_employee.partner_id)
|
||||
follower = self.env['mail.followers'].search([
|
||||
('res_model', '=', 'mail.group'),
|
||||
('res_model', '=', 'mail.channel'),
|
||||
('res_id', '=', self.group_pigs.id),
|
||||
('partner_id', '=', self.user_employee.partner_id.id)])
|
||||
self.assertEqual(len(follower), 1)
|
||||
|
||||
@@ -214,7 +214,7 @@ class TestMailgateway(TestMail):
|
||||
new_groups = self.format_and_process(MAIL_TEMPLATE, subject='My Frogs', to='groups@example.com, other@gmail.com')
|
||||
|
||||
# Test: one group created by mailgateway administrator
|
||||
self.assertEqual(len(new_groups), 1, 'message_process: a new mail.group should have been created')
|
||||
self.assertEqual(len(new_groups), 1, 'message_process: a new mail.channel should have been created')
|
||||
res = new_groups.get_metadata()[0].get('create_uid') or [None]
|
||||
self.assertEqual(res[0], self.env.uid,
|
||||
'message_process: group should have been created by uid as alias_user_id is False on the alias')
|
||||
@@ -243,7 +243,7 @@ class TestMailgateway(TestMail):
|
||||
new_groups = self.format_and_process(MAIL_TEMPLATE, to='groups@example.com, other@gmail.com')
|
||||
|
||||
# Test: one group created by mailgateway administrator
|
||||
self.assertEqual(len(new_groups), 1, 'message_process: a new mail.group should have been created')
|
||||
self.assertEqual(len(new_groups), 1, 'message_process: a new mail.channel should have been created')
|
||||
res = new_groups.get_metadata()[0].get('create_uid') or [None]
|
||||
self.assertEqual(res[0], self.user_employee.id,
|
||||
'message_process: group should have been created by alias_user_id')
|
||||
@@ -297,7 +297,7 @@ class TestMailgateway(TestMail):
|
||||
""" Incoming email from unknown partner / not follower partner on a Followers only alias -> bounce """
|
||||
self.alias.write({
|
||||
'alias_contact': 'followers',
|
||||
'alias_parent_model_id': self.mail_group_model.id,
|
||||
'alias_parent_model_id': self.mail_channel_model.id,
|
||||
'alias_parent_thread_id': self.group_pigs.id})
|
||||
|
||||
# Test: unknown on followers alias -> bounce
|
||||
@@ -320,7 +320,7 @@ class TestMailgateway(TestMail):
|
||||
new_groups = self.format_and_process(MAIL_TEMPLATE, email_from='Valid Lelitre <valid.lelitre@agrolait.com>', to='groups@example.com, valid.other@gmail.com')
|
||||
|
||||
# Test: one group created by alias user
|
||||
self.assertEqual(len(new_groups), 1, 'message_process: a new mail.group should have been created')
|
||||
self.assertEqual(len(new_groups), 1, 'message_process: a new mail.channel should have been created')
|
||||
|
||||
# Test: one message that is the incoming email
|
||||
self.assertEqual(len(new_groups.message_ids), 1,
|
||||
@@ -331,13 +331,13 @@ class TestMailgateway(TestMail):
|
||||
""" Incoming email from a parent document follower on a Followers only alias -> ok """
|
||||
self.alias.write({
|
||||
'alias_contact': 'followers',
|
||||
'alias_parent_model_id': self.mail_group_model.id,
|
||||
'alias_parent_model_id': self.mail_channel_model.id,
|
||||
'alias_parent_thread_id': self.group_pigs.id})
|
||||
self.group_pigs.message_subscribe(partner_ids=[self.partner_1.id])
|
||||
new_groups = self.format_and_process(MAIL_TEMPLATE, email_from='Valid Lelitre <valid.lelitre@agrolait.com>', to='groups@example.com, other6@gmail.com')
|
||||
|
||||
# Test: one group created by Raoul (or Sylvie maybe, if we implement it)
|
||||
self.assertEqual(len(new_groups), 1, 'message_process: a new mail.group should have been created')
|
||||
self.assertEqual(len(new_groups), 1, 'message_process: a new mail.channel should have been created')
|
||||
|
||||
@mute_logger('openerp.addons.mail.models.mail_thread', 'openerp.models', 'openerp.addons.mail.models.mail_mail')
|
||||
def test_message_process_alias_update(self):
|
||||
@@ -393,7 +393,7 @@ class TestMailgateway(TestMail):
|
||||
self.format_and_process,
|
||||
MAIL_TEMPLATE, email_from='valid.lelitre@agrolait.com',
|
||||
to='noone@example.com', subject='spam',
|
||||
extra='In-Reply-To: <12321321-openerp-%d-mail.group@%s>' % (self.group_public.id, socket.gethostname()),
|
||||
extra='In-Reply-To: <12321321-openerp-%d-mail.channel@%s>' % (self.group_public.id, socket.gethostname()),
|
||||
msg_id='<1198923581.41972151344608186802.JavaMail.diff1@agrolait.com>')
|
||||
|
||||
# when 6.1 messages are present, compat mode is available
|
||||
@@ -403,7 +403,7 @@ class TestMailgateway(TestMail):
|
||||
MAIL_TEMPLATE, email_from='other5@gmail.com',
|
||||
msg_id='<1.2.JavaMail.new@agrolait.com>',
|
||||
to='noone@example.com>', subject='spam',
|
||||
extra='In-Reply-To: <12321321-openerp-%d-mail.group@%s>' % (self.group_public.id, socket.gethostname()))
|
||||
extra='In-Reply-To: <12321321-openerp-%d-mail.channel@%s>' % (self.group_public.id, socket.gethostname()))
|
||||
|
||||
# 3''. 6.1 compat mode should not work if hostname does not match!
|
||||
self.assertRaises(ValueError,
|
||||
@@ -411,13 +411,13 @@ class TestMailgateway(TestMail):
|
||||
MAIL_TEMPLATE, email_from='other5@gmail.com',
|
||||
msg_id='<1.3.JavaMail.new@agrolait.com>',
|
||||
to='noone@example.com>', subject='spam',
|
||||
extra='In-Reply-To: <12321321-openerp-%d-mail.group@neighbor.com>' % frog_groups.id)
|
||||
extra='In-Reply-To: <12321321-openerp-%d-mail.channel@neighbor.com>' % frog_groups.id)
|
||||
|
||||
# 4. Subject contains [<ID>] + model passed to message+process -> only attached to group, but not to mail (not in msg1.child_ids)
|
||||
self.format_and_process(
|
||||
MAIL_TEMPLATE,
|
||||
to='erroneous@example.com', email_from='other6@gmail.com',
|
||||
extra='', subject='Re: [%s] 1' % self.group_public.id, model='mail.group',
|
||||
extra='', subject='Re: [%s] 1' % self.group_public.id, model='mail.channel',
|
||||
msg_id='<1198923581.41972151344608186803.JavaMail.5@agrolait.com>')
|
||||
|
||||
# Test created messages
|
||||
@@ -494,10 +494,10 @@ class TestMailgateway(TestMail):
|
||||
def test_message_process_fallback(self):
|
||||
""" Incoming email with model that accepting incoming emails as fallback """
|
||||
frog_groups = self.format_and_process(
|
||||
MAIL_TEMPLATE, to='noone@example.com', subject='Spammy', extra='', model='mail.group',
|
||||
MAIL_TEMPLATE, to='noone@example.com', subject='Spammy', extra='', model='mail.channel',
|
||||
msg_id='<1198923581.41972151344608186760.JavaMail.new6@agrolait.com>')
|
||||
self.assertEqual(len(frog_groups), 1,
|
||||
'message_process: erroneous email but with a fallback model should have created a new mail.group')
|
||||
'message_process: erroneous email but with a fallback model should have created a new mail.channel')
|
||||
|
||||
@mute_logger('openerp.addons.mail.models.mail_thread', 'openerp.models')
|
||||
def test_message_process_plain_text(self):
|
||||
@@ -505,7 +505,7 @@ class TestMailgateway(TestMail):
|
||||
frog_groups = self.format_and_process(
|
||||
MAIL_TEMPLATE_PLAINTEXT, to='groups@example.com', subject='Frogs Return', extra='',
|
||||
msg_id='<deadcafe.1337@smtp.agrolait.com>')
|
||||
self.assertEqual(len(frog_groups), 1, 'message_process: a new mail.group should have been created')
|
||||
self.assertEqual(len(frog_groups), 1, 'message_process: a new mail.channel should have been created')
|
||||
msg = frog_groups.message_ids[0]
|
||||
self.assertIn('<pre>\nPlease call me as soon as possible this afternoon!\n\n--\nSylvie\n</pre>', msg.body,
|
||||
'message_process: plaintext incoming email incorrectly parsed')
|
||||
@@ -517,7 +517,7 @@ class TestMailgateway(TestMail):
|
||||
|
||||
# Do: Raoul writes to Bert and Administrator, with a thread_model in context that should not be taken into account
|
||||
msg1 = self.env['mail.thread'].with_context({
|
||||
'thread_model': 'mail.group'
|
||||
'thread_model': 'mail.channel'
|
||||
}).sudo(self.user_employee).message_post(partner_ids=msg1_pids, subtype='mail.mt_comment')
|
||||
|
||||
# Test: message recipients
|
||||
|
||||
@@ -16,7 +16,7 @@ class TestMailMessage(TestMail):
|
||||
'datas_fname': 'doc.txt'})
|
||||
self.message = self.env['mail.message'].create({
|
||||
'body': 'My Body',
|
||||
'model': 'mail.group',
|
||||
'model': 'mail.channel',
|
||||
'res_id': self.group_private.id,
|
||||
'attachment_ids': [(4, self.attachment.id)],
|
||||
})
|
||||
@@ -65,10 +65,10 @@ class TestMailMessage(TestMail):
|
||||
self.env['ir.config_parameter'].search([('key', '=', 'mail.catchall.domain')]).unlink()
|
||||
|
||||
msg = self.env['mail.message'].sudo(self.user_employee).create({
|
||||
'model': 'mail.group',
|
||||
'model': 'mail.channel',
|
||||
'res_id': self.group_pigs.id
|
||||
})
|
||||
self.assertIn('-openerp-%d-mail.group' % self.group_pigs.id, msg.message_id, 'mail_message: message_id for a void message should be a "private" one')
|
||||
self.assertIn('-openerp-%d-mail.channel' % self.group_pigs.id, msg.message_id, 'mail_message: message_id for a void message should be a "private" one')
|
||||
self.assertEqual(msg.reply_to, '%s <%s>' % (self.user_employee.name, self.user_employee.email))
|
||||
self.assertEqual(msg.email_from, '%s <%s>' % (self.user_employee.name, self.user_employee.email))
|
||||
|
||||
@@ -78,10 +78,10 @@ class TestMailMessage(TestMail):
|
||||
self.env['ir.config_parameter'].search([('key', '=', 'mail.catchall.alias')]).unlink()
|
||||
|
||||
msg = self.env['mail.message'].sudo(self.user_employee).create({
|
||||
'model': 'mail.group',
|
||||
'model': 'mail.channel',
|
||||
'res_id': self.group_pigs.id
|
||||
})
|
||||
self.assertIn('-openerp-%d-mail.group' % self.group_pigs.id, msg.message_id, 'mail_message: message_id for a void message should be a "private" one')
|
||||
self.assertIn('-openerp-%d-mail.channel' % self.group_pigs.id, msg.message_id, 'mail_message: message_id for a void message should be a "private" one')
|
||||
self.assertEqual(msg.reply_to, '%s %s <%s@%s>' % (self._company_name, self.group_pigs.name, self.group_pigs.alias_name, alias_domain))
|
||||
self.assertEqual(msg.email_from, '%s <%s@%s>' % (self.user_employee.name, self.user_employee.alias_name, alias_domain))
|
||||
|
||||
@@ -92,21 +92,21 @@ class TestMailMessage(TestMail):
|
||||
self.env['ir.config_parameter'].set_param('mail.catchall.alias', alias_catchall)
|
||||
|
||||
msg = self.env['mail.message'].sudo(self.user_employee).create({
|
||||
'model': 'mail.group',
|
||||
'model': 'mail.channel',
|
||||
'res_id': self.group_pigs.id
|
||||
})
|
||||
self.assertIn('-openerp-%d-mail.group' % self.group_pigs.id, msg.message_id, 'mail_message: message_id for a void message should be a "private" one')
|
||||
self.assertIn('-openerp-%d-mail.channel' % self.group_pigs.id, msg.message_id, 'mail_message: message_id for a void message should be a "private" one')
|
||||
self.assertEqual(msg.reply_to, '%s %s <%s@%s>' % (self._company_name, self.group_pigs.name, self.group_pigs.alias_name, alias_domain))
|
||||
self.assertEqual(msg.email_from, '%s <%s@%s>' % (self.user_employee.name, self.user_employee.alias_name, alias_domain))
|
||||
|
||||
def test_mail_message_values_no_auto_thread(self):
|
||||
msg = self.env['mail.message'].sudo(self.user_employee).create({
|
||||
'model': 'mail.group',
|
||||
'model': 'mail.channel',
|
||||
'res_id': self.group_pigs.id,
|
||||
'no_auto_thread': True,
|
||||
})
|
||||
self.assertIn('reply_to', msg.message_id)
|
||||
self.assertNotIn('mail.group', msg.message_id)
|
||||
self.assertNotIn('mail.channel', msg.message_id)
|
||||
self.assertNotIn('-%d-' % self.group_pigs.id, msg.message_id)
|
||||
|
||||
@mute_logger('openerp.addons.mail.models.mail_mail')
|
||||
@@ -119,18 +119,18 @@ class TestMailMessage(TestMail):
|
||||
'partner_ids': [(6, 0, [self.user_public.partner_id.id])]})
|
||||
msg3 = self.env['mail.message'].create({
|
||||
'subject': '_Test', 'body': 'A Pigs', 'subtype_id': False,
|
||||
'model': 'mail.group', 'res_id': self.group_pigs.id})
|
||||
'model': 'mail.channel', 'res_id': self.group_pigs.id})
|
||||
msg4 = self.env['mail.message'].create({
|
||||
'subject': '_Test', 'body': 'A+P Pigs', 'subtype_id': self.ref('mail.mt_comment'),
|
||||
'model': 'mail.group', 'res_id': self.group_pigs.id,
|
||||
'model': 'mail.channel', 'res_id': self.group_pigs.id,
|
||||
'partner_ids': [(6, 0, [self.user_public.partner_id.id])]})
|
||||
msg5 = self.env['mail.message'].create({
|
||||
'subject': '_Test', 'body': 'A+E Pigs', 'subtype_id': self.ref('mail.mt_comment'),
|
||||
'model': 'mail.group', 'res_id': self.group_pigs.id,
|
||||
'model': 'mail.channel', 'res_id': self.group_pigs.id,
|
||||
'partner_ids': [(6, 0, [self.user_employee.partner_id.id])]})
|
||||
msg6 = self.env['mail.message'].create({
|
||||
'subject': '_Test', 'body': 'A Birds', 'subtype_id': self.ref('mail.mt_comment'),
|
||||
'model': 'mail.group', 'res_id': self.group_private.id})
|
||||
'model': 'mail.channel', 'res_id': self.group_private.id})
|
||||
msg7 = self.env['mail.message'].sudo(self.user_employee).create({
|
||||
'subject': '_Test', 'body': 'B', 'subtype_id': self.ref('mail.mt_comment')})
|
||||
msg8 = self.env['mail.message'].sudo(self.user_employee).create({
|
||||
@@ -190,7 +190,7 @@ class TestMailMessage(TestMail):
|
||||
self.message.sudo(self.user_employee).read()
|
||||
|
||||
def test_mail_message_access_read_doc(self):
|
||||
self.message.write({'model': 'mail.group', 'res_id': self.group_public.id})
|
||||
self.message.write({'model': 'mail.channel', 'res_id': self.group_public.id})
|
||||
# Test: Bert reads the message, ok because linked to a doc he is allowed to read
|
||||
self.message.sudo(self.user_employee).read()
|
||||
|
||||
@@ -198,34 +198,34 @@ class TestMailMessage(TestMail):
|
||||
def test_mail_message_access_create_crash_public(self):
|
||||
# Do: Bert creates a message on Pigs -> ko, no creation rights
|
||||
with self.assertRaises(AccessError):
|
||||
self.env['mail.message'].sudo(self.user_public).create({'model': 'mail.group', 'res_id': self.group_pigs.id, 'body': 'Test'})
|
||||
self.env['mail.message'].sudo(self.user_public).create({'model': 'mail.channel', 'res_id': self.group_pigs.id, 'body': 'Test'})
|
||||
|
||||
# Do: Bert create a message on Jobs -> ko, no creation rights
|
||||
with self.assertRaises(AccessError):
|
||||
self.env['mail.message'].sudo(self.user_public).create({'model': 'mail.group', 'res_id': self.group_public.id, 'body': 'Test'})
|
||||
self.env['mail.message'].sudo(self.user_public).create({'model': 'mail.channel', 'res_id': self.group_public.id, 'body': 'Test'})
|
||||
|
||||
@mute_logger('openerp.models')
|
||||
def test_mail_message_access_create_crash(self):
|
||||
# Do: Bert create a private message -> ko, no creation rights
|
||||
with self.assertRaises(except_orm):
|
||||
self.env['mail.message'].sudo(self.user_employee).create({'model': 'mail.group', 'res_id': self.group_private.id, 'body': 'Test'})
|
||||
self.env['mail.message'].sudo(self.user_employee).create({'model': 'mail.channel', 'res_id': self.group_private.id, 'body': 'Test'})
|
||||
|
||||
@mute_logger('openerp.models')
|
||||
def test_mail_message_access_create_doc(self):
|
||||
# TODO Change the except_orm to Warning
|
||||
Message = self.env['mail.message'].sudo(self.user_employee)
|
||||
# Do: Raoul creates a message on Jobs -> ok, write access to the related document
|
||||
Message.create({'model': 'mail.group', 'res_id': self.group_public.id, 'body': 'Test'})
|
||||
Message.create({'model': 'mail.channel', 'res_id': self.group_public.id, 'body': 'Test'})
|
||||
# Do: Raoul creates a message on Priv -> ko, no write access to the related document
|
||||
with self.assertRaises(except_orm):
|
||||
Message.create({'model': 'mail.group', 'res_id': self.group_private.id, 'body': 'Test'})
|
||||
Message.create({'model': 'mail.channel', 'res_id': self.group_private.id, 'body': 'Test'})
|
||||
|
||||
def test_mail_message_access_create_private(self):
|
||||
self.env['mail.message'].sudo(self.user_employee).create({'body': 'Test'})
|
||||
|
||||
def test_mail_message_access_create_reply(self):
|
||||
self.env['mail.notification'].create({'message_id': self.message.id, 'partner_id': self.user_employee.partner_id.id})
|
||||
self.env['mail.message'].sudo(self.user_employee).create({'model': 'mail.group', 'res_id': self.group_private.id, 'body': 'Test', 'parent_id': self.message.id})
|
||||
self.env['mail.message'].sudo(self.user_employee).create({'model': 'mail.channel', 'res_id': self.group_private.id, 'body': 'Test', 'parent_id': self.message.id})
|
||||
|
||||
def test_message_set_star(self):
|
||||
msg = self.group_pigs.message_post(body='My Body', subject='1')
|
||||
|
||||
@@ -30,7 +30,7 @@ class TestMailTemplate(TestMail):
|
||||
self.email_2 = 'test2@example.com'
|
||||
self.email_3 = self.partner_1.email
|
||||
self.email_template = self.env['mail.template'].create({
|
||||
'model_id': self.env['ir.model'].search([('model', '=', 'mail.group')], limit=1).id,
|
||||
'model_id': self.env['ir.model'].search([('model', '=', 'mail.channel')], limit=1).id,
|
||||
'name': 'Pigs Template',
|
||||
'subject': '${object.name}',
|
||||
'body_html': '${object.description}',
|
||||
@@ -43,13 +43,13 @@ class TestMailTemplate(TestMail):
|
||||
def test_composer_template_onchange(self):
|
||||
composer = self.env['mail.compose.message'].with_context({
|
||||
'default_composition_mode': 'comment',
|
||||
'default_model': 'mail.group',
|
||||
'default_model': 'mail.channel',
|
||||
'default_res_id': self.group_pigs.id,
|
||||
'default_use_template': False,
|
||||
'default_template_id': False
|
||||
}).create({'subject': 'Forget me subject', 'body': 'Dummy body'})
|
||||
|
||||
values = composer.onchange_template_id(self.email_template.id, 'comment', 'mail.group', self.group_pigs.id)['value']
|
||||
values = composer.onchange_template_id(self.email_template.id, 'comment', 'mail.channel', self.group_pigs.id)['value']
|
||||
recipients = self.env['res.partner'].browse(values['partner_ids'])
|
||||
attachments = self.env['ir.attachment'].browse(values['attachment_ids'])
|
||||
test_recipients = self.env['res.partner'].search([('email', 'in', ['test1@example.com', 'test2@example.com'])]) | self.partner_1 | self.partner_2 | self.user_employee.partner_id
|
||||
@@ -66,7 +66,7 @@ class TestMailTemplate(TestMail):
|
||||
def test_composer_template_send(self):
|
||||
composer = self.env['mail.compose.message'].with_context({
|
||||
'default_composition_mode': 'comment',
|
||||
'default_model': 'mail.group',
|
||||
'default_model': 'mail.channel',
|
||||
'default_res_id': self.group_pigs.id,
|
||||
'default_use_template': False,
|
||||
'default_template_id': self.email_template.id,
|
||||
@@ -78,7 +78,7 @@ class TestMailTemplate(TestMail):
|
||||
self.assertEqual(message.body, '<p>%s</p>' % self.group_pigs.description)
|
||||
self.assertEqual(message.partner_ids, test_recipients)
|
||||
self.assertEqual(message.notified_partner_ids, test_recipients)
|
||||
self.assertEqual(set(message.attachment_ids.mapped('res_model')), set(['mail.group']))
|
||||
self.assertEqual(set(message.attachment_ids.mapped('res_model')), set(['mail.channel']))
|
||||
self.assertEqual(set(message.attachment_ids.mapped('res_id')), set([self.group_pigs.id]))
|
||||
# self.assertIn((attach.datas_fname, base64.b64decode(attach.datas)), _attachments_test,
|
||||
# 'mail.message attachment name / data incorrect')
|
||||
@@ -88,12 +88,12 @@ class TestMailTemplate(TestMail):
|
||||
composer = self.env['mail.compose.message'].with_context({
|
||||
'default_composition_mode': 'mass_mail',
|
||||
'default_notify': True,
|
||||
'default_model': 'mail.group',
|
||||
'default_model': 'mail.channel',
|
||||
'default_res_id': self.group_pigs.id,
|
||||
'default_template_id': self.email_template.id,
|
||||
'active_ids': [self.group_pigs.id, self.group_public.id]
|
||||
}).create({})
|
||||
values = composer.onchange_template_id(self.email_template.id, 'mass_mail', 'mail.group', self.group_pigs.id)['value']
|
||||
values = composer.onchange_template_id(self.email_template.id, 'mass_mail', 'mail.channel', self.group_pigs.id)['value']
|
||||
composer.write(values)
|
||||
composer.send_mail()
|
||||
|
||||
@@ -117,15 +117,15 @@ class TestMailTemplate(TestMail):
|
||||
def test_message_compose_template_save(self):
|
||||
self.env['mail.compose.message'].with_context(
|
||||
{'default_composition_mode': 'comment',
|
||||
'default_model': 'mail.group',
|
||||
'default_model': 'mail.channel',
|
||||
'default_res_id': self.group_pigs.id,
|
||||
'active_ids': [self.group_pigs.id, self.group_public.id]
|
||||
}).create({
|
||||
'subject': 'Forget me subject',
|
||||
'body': '<p>Dummy body</p>'
|
||||
}).with_context({'default_model': 'mail.group'}).save_as_template()
|
||||
}).with_context({'default_model': 'mail.channel'}).save_as_template()
|
||||
# Test: email_template subject, body_html, model
|
||||
last_template = self.env['mail.template'].search([('model', '=', 'mail.group'), ('subject', '=', 'Forget me subject')], limit=1)
|
||||
last_template = self.env['mail.template'].search([('model', '=', 'mail.channel'), ('subject', '=', 'Forget me subject')], limit=1)
|
||||
self.assertEqual(last_template.body_html, '<p>Dummy body</p>', 'email_template incorrect body_html')
|
||||
|
||||
def test_add_context_action(self):
|
||||
|
||||
@@ -34,19 +34,19 @@ class TestMessageRead(TestMail):
|
||||
self.assertEqual(msg_ids, self.msg_ids[2:4], 'message_read with direct ids should read only the requested ids')
|
||||
|
||||
def test_message_read_domain(self):
|
||||
messages = self.env['mail.message'].sudo(self.user_employee).message_read(domain=[('model', '=', 'mail.group'), ('res_id', '=', self.group_pigs.id)], limit=200, child_limit=200)
|
||||
messages = self.env['mail.message'].sudo(self.user_employee).message_read(domain=[('model', '=', 'mail.channel'), ('res_id', '=', self.group_pigs.id)], limit=200, child_limit=200)
|
||||
read_msg_list = [msg for thread in messages['threads'] for msg in thread]
|
||||
read_msg_ids = [msg.get('id') for msg in read_msg_list]
|
||||
self.assertEqual(read_msg_ids, self.msg_ids, 'message_read flat with domain on Pigs should equal all messages of Pigs')
|
||||
|
||||
def test_message_read_domain_thread(self):
|
||||
messages = self.env['mail.message'].sudo(self.user_employee).message_read(domain=[('model', '=', 'mail.group'), ('res_id', '=', self.group_pigs.id)], thread_level=1, limit=200, child_limit=200)
|
||||
messages = self.env['mail.message'].sudo(self.user_employee).message_read(domain=[('model', '=', 'mail.channel'), ('res_id', '=', self.group_pigs.id)], thread_level=1, limit=200, child_limit=200)
|
||||
read_msg_list = [msg for thread in messages['threads'] for msg in thread]
|
||||
read_msg_ids = [msg.get('id') for msg in read_msg_list]
|
||||
self.assertEqual(read_msg_ids, self.ordered_msg_ids, 'message_read threaded with domain on Pigs should equal all messages of Pigs, and sort them with newer thread first, last message last in thread')
|
||||
|
||||
def test_message_read_expandable(self):
|
||||
messages = self.env['mail.message'].sudo(self.user_employee).message_read(domain=[('model', '=', 'mail.group'), ('res_id', '=', self.group_pigs.id)], thread_level=1, limit=1, child_limit=1)
|
||||
messages = self.env['mail.message'].sudo(self.user_employee).message_read(domain=[('model', '=', 'mail.channel'), ('res_id', '=', self.group_pigs.id)], thread_level=1, limit=1, child_limit=1)
|
||||
read_msg_list = [msg for thread in messages['threads'] for msg in thread]
|
||||
read_msg_ids = [msg.get('id') for msg in read_msg_list if msg.get('message_type') != 'expandable']
|
||||
read_ancestor_ids = [msg.get('parent_id') if msg.get('parent_id') != 0 else msg.get('id') for msg in read_msg_list if msg.get('message_type') != 'expandable']
|
||||
@@ -88,7 +88,7 @@ class TestMessageRead(TestMail):
|
||||
self.assertIsNotNone(new_threads_exp, 'message_read on last Pigs message should have returned a new threads expandable')
|
||||
domain = new_threads_exp.get('domain', [])
|
||||
# Test: expandable, conditions in domain
|
||||
for condition in [('model', '=', 'mail.group'), ('res_id', '=', self.group_pigs.id)]:
|
||||
for condition in [('model', '=', 'mail.channel'), ('res_id', '=', self.group_pigs.id)]:
|
||||
self.assertIn(condition, domain, 'new threads expandable domain should contain the message_read domain parameter')
|
||||
self.assertFalse(new_threads_exp.get('parent_id'), 'new threads expandable should not have an parent_id')
|
||||
# Do: message_read with domain, thread_level=1 (should be imposed by JS)
|
||||
@@ -125,7 +125,7 @@ class TestMessageRead(TestMail):
|
||||
self.assertIsNotNone(new_threads_exp, 'message_read should have returned a new threads expandable')
|
||||
domain = new_threads_exp.get('domain', [])
|
||||
# Test: expandable, conditions in domain
|
||||
for condition in [('model', '=', 'mail.group'), ('res_id', '=', self.group_pigs.id)]:
|
||||
for condition in [('model', '=', 'mail.channel'), ('res_id', '=', self.group_pigs.id)]:
|
||||
self.assertIn(condition, domain, 'general expandable domain should contain the message_read domain parameter')
|
||||
# Do: message_read with domain, thread_level=1 (should be imposed by JS)
|
||||
messages = self.env['mail.message'].sudo(self.user_employee).message_read(domain=domain, thread_level=1, limit=1, child_limit=1)
|
||||
@@ -141,7 +141,7 @@ class TestMessageRead(TestMail):
|
||||
# ----------------------------------------
|
||||
|
||||
# Do: read 2 lasts message, flat
|
||||
messages = self.env['mail.message'].sudo(self.user_employee).message_read(domain=[('model', '=', 'mail.group'), ('res_id', '=', self.group_pigs.id)], thread_level=0, limit=2)
|
||||
messages = self.env['mail.message'].sudo(self.user_employee).message_read(domain=[('model', '=', 'mail.channel'), ('res_id', '=', self.group_pigs.id)], thread_level=0, limit=2)
|
||||
read_msg_list = [msg for thread in messages['threads'] for msg in thread]
|
||||
read_msg_ids = [msg.get('id') for msg in read_msg_list if msg.get('message_type') != 'expandable']
|
||||
# Test: structure content, ancestor is added to the read messages, ordered by id, ancestor is not set, 1 expandable
|
||||
@@ -158,7 +158,7 @@ class TestMessageRead(TestMail):
|
||||
self.assertIsNotNone(new_msg_exp, 'message_read flat on the 2 last Pigs messages should have returns a new threads expandable')
|
||||
domain = new_msg_exp.get('domain', [])
|
||||
# Test: expandable, conditions in domain
|
||||
for condition in [('model', '=', 'mail.group'), ('res_id', '=', self.group_pigs.id)]:
|
||||
for condition in [('model', '=', 'mail.channel'), ('res_id', '=', self.group_pigs.id)]:
|
||||
self.assertIn(condition, domain, 'new threads expandable domain should contain the message_read domain parameter')
|
||||
# Do: message_read with domain, thread_level=0 (should be imposed by JS)
|
||||
messages = self.env['mail.message'].sudo(self.user_employee).message_read(domain=domain, thread_level=0, limit=20)
|
||||
|
||||
@@ -77,14 +77,14 @@ class TestTracking(TestMail):
|
||||
elif 'group_public_id' in init_values and not record.group_public_id:
|
||||
return 'mail.mt_group_public_unset'
|
||||
return False
|
||||
self.registry('mail.group')._patch_method('_track_subtype', _track_subtype)
|
||||
self.registry('mail.channel')._patch_method('_track_subtype', _track_subtype)
|
||||
|
||||
visibility = {
|
||||
'public': 'onchange',
|
||||
'name': 'always',
|
||||
'group_public_id': 'onchange'
|
||||
}
|
||||
cls = type(self.env['mail.group'])
|
||||
cls = type(self.env['mail.channel'])
|
||||
for key in visibility:
|
||||
self.assertFalse(hasattr(getattr(cls, key), 'track_visibility'))
|
||||
getattr(cls, key).track_visibility = visibility[key]
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
|
||||
<!-- Group Kanban View !-->
|
||||
<record model="ir.ui.view" id="view_group_kanban">
|
||||
<field name="name">mail.group.kanban</field>
|
||||
<field name="model">mail.group</field>
|
||||
<field name="name">mail.channel.kanban</field>
|
||||
<field name="model">mail.channel</field>
|
||||
<field name="priority" eval="10"/>
|
||||
<field name="arch" type="xml">
|
||||
<kanban>
|
||||
@@ -32,7 +32,7 @@
|
||||
<t t-name="kanban-box">
|
||||
<div t-attf-class="{record.message_is_follower.raw_value} oe_group_vignette oe_semantic_html_override">
|
||||
<div class="oe_group_image">
|
||||
<a type="open"><img t-att-src="kanban_image('mail.group', 'image_medium', record.id.value)" class="oe_group_photo" tooltip="kanban-description"/></a>
|
||||
<a type="open"><img t-att-src="kanban_image('mail.channel', 'image_medium', record.id.value)" class="oe_group_photo" tooltip="kanban-description"/></a>
|
||||
</div>
|
||||
<div class="oe_group_details">
|
||||
<h4><a type="open"><field name="name"/></a></h4>
|
||||
@@ -59,12 +59,12 @@
|
||||
|
||||
<!-- Group Form View !-->
|
||||
<record model="ir.ui.view" id="view_group_form">
|
||||
<field name="name">mail.group.form</field>
|
||||
<field name="model">mail.group</field>
|
||||
<field name="name">mail.channel.form</field>
|
||||
<field name="model">mail.channel</field>
|
||||
<field name="priority" eval="10"/>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Group Form">
|
||||
<sheet class="openerp_mail_group_sheet">
|
||||
<sheet class="openerp_mail_channel_sheet">
|
||||
<field name="image" widget='image' class="oe_avatar oe_left" options='{"preview_image": "image_small"}'/>
|
||||
<div class="oe_title">
|
||||
<div class="oe_edit_only">
|
||||
@@ -116,8 +116,8 @@
|
||||
|
||||
<!-- Group List View !-->
|
||||
<record model="ir.ui.view" id="view_group_tree">
|
||||
<field name="name">mail.group.tree</field>
|
||||
<field name="model">mail.group</field>
|
||||
<field name="name">mail.channel.tree</field>
|
||||
<field name="model">mail.channel</field>
|
||||
<field name="priority" eval="10"/>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Groups">
|
||||
@@ -128,8 +128,8 @@
|
||||
|
||||
<!-- Group Search View !-->
|
||||
<record model="ir.ui.view" id="view_group_search">
|
||||
<field name="name">mail.group.search</field>
|
||||
<field name="model">mail.group</field>
|
||||
<field name="name">mail.channel.search</field>
|
||||
<field name="model">mail.channel</field>
|
||||
<field name="priority" eval="10"/>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search Groups">
|
||||
@@ -141,7 +141,7 @@
|
||||
<!-- group record !-->
|
||||
<record id="action_view_groups" model="ir.actions.act_window">
|
||||
<field name="name">Join a group</field>
|
||||
<field name="res_model">mail.group</field>
|
||||
<field name="res_model">mail.channel</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">kanban,tree,form</field>
|
||||
<field name="search_view_id" ref="view_group_search"/>
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
<data noupdate="1">
|
||||
<!-- notify all employees of module installation -->
|
||||
<record model="mail.message" id="module_install_notification">
|
||||
<field name="model">mail.group</field>
|
||||
<field name="res_id" ref="mail.group_all_employees"/>
|
||||
<field name="model">mail.channel</field>
|
||||
<field name="res_id" ref="mail.channel_all_employees"/>
|
||||
<field name="message_type">notification</field>
|
||||
<field name="subtype_id" ref="mail.mt_comment"/>
|
||||
<field name="subject">MRP application installed!</field>
|
||||
|
||||
@@ -36,8 +36,8 @@
|
||||
|
||||
<!-- notify all employees of module installation -->
|
||||
<record model="mail.message" id="module_install_notification">
|
||||
<field name="model">mail.group</field>
|
||||
<field name="res_id" ref="mail.group_all_employees"/>
|
||||
<field name="model">mail.channel</field>
|
||||
<field name="res_id" ref="mail.channel_all_employees"/>
|
||||
<field name="message_type">notification</field>
|
||||
<field name="subtype_id" ref="mail.mt_comment"/>
|
||||
<field name="subject">Point of Sale application installed!</field>
|
||||
|
||||
@@ -14,7 +14,7 @@ class test_portal(TestMail):
|
||||
# Do: Chell creates a mail.compose.message record on Pigs, because he uses the wizard
|
||||
compose = self.env['mail.compose.message'].with_context({
|
||||
'default_composition_mode': 'comment',
|
||||
'default_model': 'mail.group',
|
||||
'default_model': 'mail.channel',
|
||||
'default_res_id': self.group_portal.id
|
||||
}).sudo(self.user_portal).create({
|
||||
'subject': 'Subject',
|
||||
@@ -41,7 +41,7 @@ class test_portal(TestMail):
|
||||
# Do: create a mail_wizard_invite, validate it
|
||||
self._init_mock_build_email()
|
||||
mail_invite = self.env['mail.wizard.invite'].with_context({
|
||||
'default_res_model': 'mail.group',
|
||||
'default_res_model': 'mail.channel',
|
||||
'default_res_id': group_pigs.id}).create({
|
||||
'partner_ids': [(4, partner_carine.id)], 'send_mail': True})
|
||||
mail_invite.add_followers()
|
||||
|
||||
@@ -121,8 +121,8 @@
|
||||
|
||||
<!-- notify all employees of module installation -->
|
||||
<record model="mail.message" id="module_install_notification">
|
||||
<field name="model">mail.group</field>
|
||||
<field name="res_id" ref="mail.group_all_employees"/>
|
||||
<field name="model">mail.channel</field>
|
||||
<field name="res_id" ref="mail.channel_all_employees"/>
|
||||
<field name="message_type">notification</field>
|
||||
<field name="subtype_id" ref="mail.mt_comment"/>
|
||||
<field name="subject">Project Management application installed!</field>
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
<!-- notify all employees of module installation -->
|
||||
<record model="mail.message" id="module_install_notification">
|
||||
<field name="model">mail.group</field>
|
||||
<field name="res_id" ref="mail.group_all_employees"/>
|
||||
<field name="model">mail.channel</field>
|
||||
<field name="res_id" ref="mail.channel_all_employees"/>
|
||||
<field name="message_type">notification</field>
|
||||
<field name="subtype_id" ref="mail.mt_comment"/>
|
||||
<field name="subject">Issue Tracker application installed!</field>
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
<!-- notify all employees of module installation -->
|
||||
<record model="mail.message" id="module_install_notification">
|
||||
<field name="model">mail.group</field>
|
||||
<field name="res_id" ref="mail.group_all_employees"/>
|
||||
<field name="model">mail.channel</field>
|
||||
<field name="res_id" ref="mail.channel_all_employees"/>
|
||||
<field name="message_type">notification</field>
|
||||
<field name="subtype_id" ref="mail.mt_comment"/>
|
||||
<field name="subject">Purchase Management application installed!</field>
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
|
||||
<!-- notify all employees of module installation -->
|
||||
<record model="mail.message" id="module_install_notification">
|
||||
<field name="model">mail.group</field>
|
||||
<field name="res_id" ref="mail.group_all_employees"/>
|
||||
<field name="model">mail.channel</field>
|
||||
<field name="res_id" ref="mail.channel_all_employees"/>
|
||||
<field name="message_type">notification</field>
|
||||
<field name="subtype_id" ref="mail.mt_comment"/>
|
||||
<field name="subject">Sales Management application installed!</field>
|
||||
|
||||
@@ -81,8 +81,8 @@
|
||||
<data noupdate="1">
|
||||
<!-- notify all employees of module installation -->
|
||||
<record model="mail.message" id="module_install_notification">
|
||||
<field name="model">mail.group</field>
|
||||
<field name="res_id" ref="mail.group_all_employees"/>
|
||||
<field name="model">mail.channel</field>
|
||||
<field name="res_id" ref="mail.channel_all_employees"/>
|
||||
<field name="message_type">notification</field>
|
||||
<field name="subtype_id" ref="mail.mt_comment"/>
|
||||
<field name="subject">Warehouse Management application installed!</field>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<openerp>
|
||||
<data noupdate="1">
|
||||
|
||||
<record model="mail.group" id="group_all_employees">
|
||||
<record model="mail.channel" id="channel_all_employees">
|
||||
<field name="name">Discussion Group</field>
|
||||
<field name="public">public</field>
|
||||
<field name="description">Public Discussion Group</field>
|
||||
|
||||
@@ -16,7 +16,7 @@ class MailGroup(http.Controller):
|
||||
def _get_archives(self, group_id):
|
||||
MailMessage = request.registry['mail.message']
|
||||
groups = MailMessage.read_group(
|
||||
request.cr, request.uid, [('model', '=', 'mail.group'), ('res_id', '=', group_id)], ['subject', 'date'],
|
||||
request.cr, request.uid, [('model', '=', 'mail.channel'), ('res_id', '=', group_id)], ['subject', 'date'],
|
||||
groupby="date", orderby="date desc", context=request.context)
|
||||
for group in groups:
|
||||
begin_date = datetime.datetime.strptime(group['__domain'][0][2], tools.DEFAULT_SERVER_DATETIME_FORMAT).date()
|
||||
@@ -28,7 +28,7 @@ class MailGroup(http.Controller):
|
||||
@http.route("/groups", type='http', auth="public", website=True)
|
||||
def view(self, **post):
|
||||
cr, uid, context = request.cr, request.uid, request.context
|
||||
group_obj = request.registry.get('mail.group')
|
||||
group_obj = request.registry.get('mail.channel')
|
||||
mail_message_obj = request.registry.get('mail.message')
|
||||
group_ids = group_obj.search(cr, uid, [('alias_id', '!=', False), ('alias_id.alias_name', '!=', False)], context=context)
|
||||
groups = group_obj.browse(cr, uid, group_ids, context)
|
||||
@@ -37,7 +37,7 @@ class MailGroup(http.Controller):
|
||||
month_date = datetime.datetime.today() - relativedelta.relativedelta(months=1)
|
||||
result = mail_message_obj.read_group(
|
||||
cr, SUPERUSER_ID,
|
||||
[('model', '=', 'mail.group'), ('date', '>=', month_date.strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT))],
|
||||
[('model', '=', 'mail.channel'), ('date', '>=', month_date.strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT))],
|
||||
[], ['res_id'],
|
||||
context=context)
|
||||
result = dict([(x['res_id'], x['res_id_count']) for x in result])
|
||||
@@ -47,13 +47,13 @@ class MailGroup(http.Controller):
|
||||
group_data[group.id] = {'monthly_message_nbr': result.get(group.id, 0)}
|
||||
|
||||
values = {'groups': groups, 'group_data': group_data}
|
||||
return request.website.render('website_mail_channel.mail_groups', values)
|
||||
return request.website.render('website_mail_channel.mail_channels', values)
|
||||
|
||||
@http.route(["/groups/subscription/"], type='json', auth="user")
|
||||
def subscription(self, group_id=0, action=False, **post):
|
||||
""" TDE FIXME: seems dead code """
|
||||
cr, uid, context = request.cr, request.uid, request.context
|
||||
group_obj = request.registry.get('mail.group')
|
||||
group_obj = request.registry.get('mail.channel')
|
||||
if action:
|
||||
group_obj.message_subscribe_users(cr, uid, [group_id], context=context)
|
||||
else:
|
||||
@@ -61,14 +61,14 @@ class MailGroup(http.Controller):
|
||||
return []
|
||||
|
||||
@http.route([
|
||||
"/groups/<model('mail.group'):group>",
|
||||
"/groups/<model('mail.group'):group>/page/<int:page>"
|
||||
"/groups/<model('mail.channel'):group>",
|
||||
"/groups/<model('mail.channel'):group>/page/<int:page>"
|
||||
], type='http', auth="public", website=True)
|
||||
def thread_headers(self, group, page=1, mode='thread', date_begin=None, date_end=None, **post):
|
||||
cr, uid, context = request.cr, request.uid, request.context
|
||||
thread_obj = request.registry.get('mail.message')
|
||||
|
||||
domain = [('model', '=', 'mail.group'), ('res_id', '=', group.id)]
|
||||
domain = [('model', '=', 'mail.channel'), ('res_id', '=', group.id)]
|
||||
if mode == 'thread':
|
||||
domain += [('parent_id', '=', False)]
|
||||
if date_begin and date_end:
|
||||
@@ -97,15 +97,15 @@ class MailGroup(http.Controller):
|
||||
return request.website.render('website_mail_channel.group_messages', values)
|
||||
|
||||
@http.route([
|
||||
'''/groups/<model('mail.group'):group>/<model('mail.message', "[('model','=','mail.group'), ('res_id','=',group[0])]"):message>''',
|
||||
'''/groups/<model('mail.channel'):group>/<model('mail.message', "[('model','=','mail.channel'), ('res_id','=',group[0])]"):message>''',
|
||||
], type='http', auth="public", website=True)
|
||||
def thread_discussion(self, group, message, mode='thread', date_begin=None, date_end=None, **post):
|
||||
cr, uid, context = request.cr, request.uid, request.context
|
||||
Message = request.registry['mail.message']
|
||||
if mode == 'thread':
|
||||
base_domain = [('model', '=', 'mail.group'), ('res_id', '=', group.id), ('parent_id', '=', message.parent_id and message.parent_id.id or False)]
|
||||
base_domain = [('model', '=', 'mail.channel'), ('res_id', '=', group.id), ('parent_id', '=', message.parent_id and message.parent_id.id or False)]
|
||||
else:
|
||||
base_domain = [('model', '=', 'mail.group'), ('res_id', '=', group.id)]
|
||||
base_domain = [('model', '=', 'mail.channel'), ('res_id', '=', group.id)]
|
||||
next_message = None
|
||||
next_message_ids = Message.search(cr, uid, base_domain + [('date', '<', message.date)], order="date DESC", limit=1, context=context)
|
||||
if next_message_ids:
|
||||
@@ -128,7 +128,7 @@ class MailGroup(http.Controller):
|
||||
return request.website.render('website_mail_channel.group_message', values)
|
||||
|
||||
@http.route(
|
||||
'''/groups/<model('mail.group'):group>/<model('mail.message', "[('model','=','mail.group'), ('res_id','=',group[0])]"):message>/get_replies''',
|
||||
'''/groups/<model('mail.channel'):group>/<model('mail.message', "[('model','=','mail.channel'), ('res_id','=',group[0])]"):message>/get_replies''',
|
||||
type='json', auth="public", methods=['POST'], website=True)
|
||||
def render_messages(self, group, message, **post):
|
||||
last_displayed_id = post.get('last_displayed_id')
|
||||
@@ -148,7 +148,7 @@ class MailGroup(http.Controller):
|
||||
}
|
||||
return request.registry['ir.ui.view'].render(request.cr, request.uid, 'website_mail_channel.messages_short', values, engine='ir.qweb', context=request.context)
|
||||
|
||||
@http.route("/groups/<model('mail.group'):group>/get_alias_info", type='json', auth='public', website=True)
|
||||
@http.route("/groups/<model('mail.channel'):group>/get_alias_info", type='json', auth='public', website=True)
|
||||
def get_alias_info(self, group, **post):
|
||||
return {
|
||||
'alias_name': group.alias_id and group.alias_id.alias_name and group.alias_id.alias_domain and '%s@%s' % (group.alias_id.alias_name, group.alias_id.alias_domain) or False
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from openerp.osv import osv
|
||||
from openerp import tools
|
||||
from openerp.tools.translate import _
|
||||
from openerp.tools.safe_eval import safe_eval as eval
|
||||
from openerp.addons.website.models.website import slug
|
||||
|
||||
|
||||
class MailGroup(osv.Model):
|
||||
_inherit = 'mail.group'
|
||||
_inherit = 'mail.channel'
|
||||
|
||||
def message_get_email_values(self, cr, uid, id, notif_mail=None, context=None):
|
||||
res = super(MailGroup, self).message_get_email_values(cr, uid, id, notif_mail=notif_mail, context=context)
|
||||
|
||||
@@ -15,16 +15,16 @@ class MailMail(osv.Model):
|
||||
# TDE: temporary addition (mail was parameter) due to semi-new-API
|
||||
mail = self.browse(cr, uid, ids[0], context=context)
|
||||
|
||||
if mail.model == 'mail.group' and mail.res_id:
|
||||
if mail.model == 'mail.channel' and mail.res_id:
|
||||
# no super() call on purpose, no private links that could be quoted!
|
||||
group = self.pool['mail.group'].browse(cr, uid, mail.res_id, context=context)
|
||||
channel = self.pool['mail.channel'].browse(cr, uid, mail.res_id, context=context)
|
||||
base_url = self.pool['ir.config_parameter'].get_param(cr, uid, 'web.base.url')
|
||||
vals = {
|
||||
'maillist': _('Mailing-List'),
|
||||
'post_to': _('Post to'),
|
||||
'unsub': _('Unsubscribe'),
|
||||
'mailto': 'mailto:%s@%s' % (group.alias_name, group.alias_domain),
|
||||
'group_url': '%s/groups/%s' % (base_url, slug(group)),
|
||||
'mailto': 'mailto:%s@%s' % (channel.alias_name, channel.alias_domain),
|
||||
'group_url': '%s/groups/%s' % (base_url, slug(channel)),
|
||||
'unsub_url': '%s/groups?unsubscribe' % (base_url,),
|
||||
}
|
||||
footer = """_______________________________________________
|
||||
|
||||
@@ -18,11 +18,11 @@ snippet_editor.options.subscribe = snippet_editor.Option.extend({
|
||||
window_title: _t("Add a Subscribe Button"),
|
||||
select: _t("Discussion List"),
|
||||
init: function (field) {
|
||||
return new Model('mail.group')
|
||||
return new Model('mail.channel')
|
||||
.call('name_search', ['', [['public','=','public']]], { context: website.get_context() });
|
||||
},
|
||||
}).then(function (mail_group_id) {
|
||||
self.$target.attr("data-id", mail_group_id);
|
||||
}).then(function (mail_channel_id) {
|
||||
self.$target.attr("data-id", mail_channel_id);
|
||||
});
|
||||
},
|
||||
drop_and_build_snippet: function() {
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
<div class="oe_snippet_body js_follow_alias"
|
||||
data-id="0"
|
||||
data-object="mail.group"
|
||||
data-object="mail.channel"
|
||||
data-follow="off">
|
||||
<div class="input-group js_mg_follow_form">
|
||||
<input
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="mail_groups" name="Mailing Lists">
|
||||
<template id="mail_channels" name="Mailing Lists">
|
||||
<t t-call="website.layout">
|
||||
<div id="wrap" class="oe_structure oe_empty">
|
||||
<section class="bg-primary jumbotron mt0 mb0">
|
||||
|
||||
@@ -419,7 +419,7 @@ class ir_mail_server(osv.osv):
|
||||
|
||||
x_forge_to = message['X-Forge-To']
|
||||
if x_forge_to:
|
||||
# `To:` header forged, e.g. for posting on mail.groups, to avoid confusion
|
||||
# `To:` header forged, e.g. for posting on mail.channels, to avoid confusion
|
||||
del message['X-Forge-To']
|
||||
del message['To'] # avoid multiple To: headers!
|
||||
message['To'] = x_forge_to
|
||||
|
||||
Reference in New Issue
Block a user