From d0819898369177adb319b54eb6b5a19c29df22fa Mon Sep 17 00:00:00 2001 From: Veronika Kotovich Date: Thu, 27 Aug 2015 13:27:45 +0300 Subject: [PATCH] Filtered models in relocate dialog --- i18n/mail_move_message.pot | 4 ++++ mail_move_message_models.py | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/i18n/mail_move_message.pot b/i18n/mail_move_message.pot index 333da78..f1ed98b 100644 --- a/i18n/mail_move_message.pot +++ b/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." 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 "" \ No newline at end of file diff --git a/mail_move_message_models.py b/mail_move_message_models.py index 9fb7068..dd0d17a 100644 --- a/mail_move_message_models.py +++ b/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_is_moved = fields.Boolean(string='Is Moved', related='message_id.is_moved', readonly=True) 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') record_url = fields.Char('Link to record', readonly=True) can_move = fields.Boolean('Can move', compute='get_can_move') @@ -113,6 +113,17 @@ class wizard(models.TransientModel): '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): _inherit = 'mail.message'