Browse Source

Filtered models in relocate dialog

pull/1/head
Veronika Kotovich 9 years ago
parent
commit
d081989836
  1. 4
      i18n/mail_move_message.pot
  2. 13
      mail_move_message_models.py

4
i18n/mail_move_message.pot

@ -157,3 +157,7 @@ msgstr ""
msgid "You cannot move this message. It was already moved with a message bellow. Open one and apply changes there." msgid "You cannot move this message. It was already moved with a message bellow. Open one and apply changes there."
msgstr "" msgstr ""
#. module: mail_move_message
#: help:mail_move_message.wizard,model_id:0
msgid "List available Models is configured at Settings\Technical\Emails\Mail Relocation. Empty for unassigned email"
msgstr ""

13
mail_move_message_models.py

@ -10,7 +10,7 @@ class wizard(models.TransientModel):
message_moved_by_user_id = fields.Many2one('res.users', related='message_id.moved_by_user_id', string='Moved by', readonly=True) message_moved_by_user_id = fields.Many2one('res.users', related='message_id.moved_by_user_id', string='Moved by', readonly=True)
message_is_moved = fields.Boolean(string='Is Moved', related='message_id.is_moved', readonly=True) message_is_moved = fields.Boolean(string='Is Moved', related='message_id.is_moved', readonly=True)
parent_id = fields.Many2one('mail.message', string='Search by name') parent_id = fields.Many2one('mail.message', string='Search by name')
model_id = fields.Many2one('ir.model', string='Record type')
model_id = fields.Many2one('ir.model', string='Model')
res_id = fields.Integer('Record ID') res_id = fields.Integer('Record ID')
record_url = fields.Char('Link to record', readonly=True) record_url = fields.Char('Link to record', readonly=True)
can_move = fields.Boolean('Can move', compute='get_can_move') can_move = fields.Boolean('Can move', compute='get_can_move')
@ -113,6 +113,17 @@ class wizard(models.TransientModel):
'type': 'ir.actions.act_window', 'type': 'ir.actions.act_window',
} }
@api.model
def fields_get(self, fields=None, write_access=True, attributes=None):
config_parameters = self.env['ir.config_parameter']
res = super(wizard, self).fields_get(fields, write_access=write_access, attributes=attributes)
if 'model_id' in res:
model_names = config_parameters.get_param('mail_relocation_models')
if model_names:
model_names = model_names.split(',')
res['model_id']['domain'] = [('model', 'in', model_names)]
return res
class mail_message(models.Model): class mail_message(models.Model):
_inherit = 'mail.message' _inherit = 'mail.message'

Loading…
Cancel
Save