Browse Source

Added configuration of models

pull/1/head
Veronika Kotovich 9 years ago
parent
commit
c5252914ed
  1. 1
      __openerp__.py
  2. 9
      data/mail_move_message_data.xml
  3. 25
      mail_move_message_models.py
  4. 31
      mail_move_message_views.xml

1
__openerp__.py

@ -10,6 +10,7 @@
'images': ['images/inbox.png'], 'images': ['images/inbox.png'],
'data':[ 'data':[
'mail_move_message_views.xml', 'mail_move_message_views.xml',
'data/mail_move_message_data.xml',
], ],
'qweb': [ 'qweb': [
'static/src/xml/mail_move_message_main.xml', 'static/src/xml/mail_move_message_main.xml',

9
data/mail_move_message_data.xml

@ -0,0 +1,9 @@
<?xml version="1.0"?>
<openerp>
<data noupdate="1">
<record id="mail_relocation_models" model="ir.config_parameter">
<field name="key">mail_relocation_models</field>
<field name="value">crm.lead,project.task</field>
</record>
</data>
</openerp>

25
mail_move_message_models.py

@ -193,3 +193,28 @@ class mail_message(models.Model):
res = super(mail_message, self)._message_read_dict(cr, uid, message, parent_id, context) res = super(mail_message, self)._message_read_dict(cr, uid, message, parent_id, context)
res['is_moved'] = message.is_moved res['is_moved'] = message.is_moved
return res return res
class mail_move_message_configuration(models.TransientModel):
_name = 'mail_move_message.config.settings'
_inherit = 'res.config.settings'
model_ids = fields.Many2many(comodel_name='ir.model', string='Models')
def get_default_model_ids(self, cr, uid, fields, context=None):
config_parameters = self.pool.get('ir.config_parameter')
model_obj = self.pool.get('ir.model')
model_names = config_parameters.get_param(cr, uid, 'mail_relocation_models', context=context)
if not model_names:
return {}
model_names = model_names.split(',')
model_ids = model_obj.search(cr, uid, [('model', 'in', model_names)], context=context)
return {'model_ids': model_ids}
@api.multi
def set_model_ids(self):
config_parameters = self.env['ir.config_parameter']
model_names = ''
for record in self:
model_names = ','.join([m.model for m in record.model_ids])
config_parameters.set_param('mail_relocation_models', model_names)

31
mail_move_message_views.xml

@ -40,5 +40,36 @@
</field> </field>
</record> </record>
<!-- Relocation config wizard -->
<record id="view_mail_move_message_config_settings" model="ir.ui.view">
<field name="name">relocation settings</field>
<field name="model">mail_move_message.config.settings</field>
<field name="arch" type="xml">
<form string="Configure Mail Relocation" class="oe_form_configuration">
<header>
<button string="Apply" type="object" name="execute" class="oe_highlight"/>
or
<button string="Cancel" type="object" name="cancel" class="oe_link"/>
</header>
<div name="general">
<separator string="Models"/>
<field name="model_ids" widget="many2many_tags"/>
</div>
</form>
</field>
</record>
<record id="action_mail_move_message_config" model="ir.actions.act_window">
<field name="name">Mail Relocation</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mail_move_message.config.settings</field>
<field name="view_id" ref="view_mail_move_message_config_settings"/>
<field name="view_mode">form</field>
<field name="target">inline</field>
</record>
<!-- Add menu entry in Settings/Email -->
<menuitem name="Mail Relocation" id="menu_mail_move_message" parent="base.menu_email" sequence="20" action="action_mail_move_message_config"/>
</data> </data>
</openerp> </openerp>
Loading…
Cancel
Save