Skip to content
Snippets Groups Projects
Commit 38594f13 authored by Hansun (hale)'s avatar Hansun (hale)
Browse files

[FIX] event{._sms}: event: access right for admins of event app


1. Install [Events]

2. On [Settings], create an admin for Events (uncheck all other rights)

3. Click on Events, enter an event

3. Click on [Communication] tab, and try adding a line

Issue: accessing ir.model is blocked
Solution: Find another way

Original fix in 15.0: #112527
Fix of the fix in 15.0: #115881
Original forward-port in 16.0: #115101

This commit is fixing the original forward-port in 16.0 and includes
the fix of the fix.

affected branch: 16.0-master
opw-3163138, 3193659

closes odoo/odoo#116221

Signed-off-by: default avatarNicolas Lempereur (nle) <nle@odoo.com>
parent 7f70d990
No related branches found
No related tags found
No related merge requests found
......@@ -84,7 +84,8 @@ class EventMailScheduler(models.Model):
def set_template_ref_model(self):
mail_model = self.env['mail.template']
if self.notification_type == 'mail':
self.template_ref = "{},{}".format('mail.template', mail_model.search([('model', '=', 'event.registration')], limit=1).id)
record = mail_model.search([('model', '=', 'event.registration')], limit=1)
self.template_ref = "{},{}".format('mail.template', record.id) if record else False
event_id = fields.Many2one('event.event', string='Event', required=True, ondelete='cascade')
sequence = fields.Integer('Display order')
......
......@@ -79,7 +79,7 @@
<field name="sequence" widget="handle"/>
<field name="notification_type"/>
<field name="template_model_id" invisible="1"/>
<field name="template_ref" options="{'model_field': 'template_model_id', 'no_quick_create': True}" context="{'filter_template_on_event': True, 'default_model': 'event.registration'}"/>
<field name="template_ref" options="{'hide_model': True, 'no_quick_create': True}" context="{'filter_template_on_event': True, 'default_model': 'event.registration'}"/>
<field name="interval_nbr" attrs="{'readonly':[('interval_unit','=','now')]}"/>
<field name="interval_unit"/>
<field name="interval_type"/>
......
......@@ -12,8 +12,7 @@
<group>
<field name="event_id"/>
<field name="notification_type"/>
<field name="template_model_id" invisible="1"/>
<field name="template_ref" options="{'model_field': 'template_model_id', 'no_quick_create': True}" context="{'filter_template_on_event': True, 'default_model': 'event.registration'}"/>
<field name="template_ref" options="{'hide_model': True, 'no_quick_create': True}" context="{'filter_template_on_event': True, 'default_model': 'event.registration'}"/>
<field name="mail_state"/>
</group>
<group>
......@@ -49,8 +48,7 @@
<tree string="Event Mail Schedulers">
<field name="event_id"/>
<field name="notification_type"/>
<field name="template_model_id" invisible="1"/>
<field name="template_ref" options="{'model_field': 'template_model_id', 'no_quick_create': True}" context="{'filter_template_on_event': True, 'default_model': 'event.registration'}"/>
<field name="template_ref" options="{'hide_model': True, 'no_quick_create': True}" context="{'filter_template_on_event': True, 'default_model': 'event.registration'}"/>
<field name="scheduled_date"/>
<field name="mail_count_done"/>
<field name="mail_state" widget="event_icon_selection" string=" " nolabel="1"
......
This diff is collapsed.
......@@ -65,7 +65,8 @@ class EventMailScheduler(models.Model):
super().set_template_ref_model()
mail_model = self.env['sms.template']
if self.notification_type == 'sms':
self.template_ref = "{},{}".format('sms.template', mail_model.search([('model', '=', 'event.registration')], limit=1).id)
record = mail_model.search([('model', '=', 'event.registration')], limit=1)
self.template_ref = "{},{}".format('sms.template', record.id) if record else False
class EventMailRegistration(models.Model):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment