Browse Source

code cleanup; handled button Mark Read and Close; remove url field

pull/1/head
Veronika Kotovich 9 years ago
parent
commit
c7a21b7034
  1. 16
      mail_move_message_models.py
  2. 3
      mail_move_message_views.xml

16
mail_move_message_models.py

@ -25,6 +25,7 @@ class wizard(models.TransientModel):
res_id = self.env[res['model']].search([], order='id desc', limit=1)
res['res_id'] = res_id and res_id[0].id
if 'message_id' in res:
email_from = self.env['mail.message'].browse(res['message_id']).email_from
parts = email_split(email_from.replace(' ',','))
if parts:
@ -45,7 +46,6 @@ class wizard(models.TransientModel):
parent_id = fields.Many2one('mail.message', string='Search by name', )
model = fields.Selection(_model_selection, string='Model')
res_id = fields.Integer(string='Record ID')
record_url = fields.Char('Link to record', readonly=True)
can_move = fields.Boolean('Can move', compute='get_can_move')
move_back = fields.Boolean('Move to origin', help='Move message and submessages to original place')
partner_id = fields.Many2one('res.partner', string='Author', related='message_id.author_id')
@ -83,15 +83,6 @@ class wizard(models.TransientModel):
self.model = None
self.res_id = None
@api.onchange('model', 'res_id')
def on_change_res(self):
if not ( self.model and self.res_id ):
self.record_url = ''
return
self.record_url = '/web#id=%s&model=%s' % (self.res_id, self.model)
@api.onchange('model', 'filter_by_partner', 'partner_id')
def on_change_partner(self):
domain = {'res_id': []}
@ -194,6 +185,11 @@ class wizard(models.TransientModel):
context.update({'default_%s' % contact_field: partner_id})
return context
@api.one
def read_close(self):
self.message_id.set_message_read(True)
return {'type': 'ir.actions.act_window_close'}
class mail_message(models.Model):
_inherit = 'mail.message'

3
mail_move_message_views.xml

@ -29,7 +29,7 @@
<group attrs="{'invisible':[('can_move', '=', False)]}" colspan="2">
<label for="model"/>
<div>
<field name="model" widget="polymorphic" polymorphic="res_id" style="width:100%"/>
<field name="model" widget="polymorphic" polymorphic="res_id" class="oe_inline"/>
</div>
<label for="filter_by_partner"/>
<div>
@ -40,7 +40,6 @@
<label for="res_id"/>
<div>
<field name="res_id" context="{'extended_name_with_contact':1}" widget="many2one" attrs="{'readonly': [('model','=',False)]}" style="width:50%"/>
<field name="record_url" widget="url" class="oe_inline" text="Open in new tab"/>
<button string="Create new record" name="create_record" type="object" class="oe_highlight" attrs="{'invisible':['|',('model','=',False),('res_id','!=',False)]}" special="quick_create" field="res_id" use_for_mail_move_message="True"/>
</div>
</group>

Loading…
Cancel
Save