Browse Source

[IMP] interface improvements + small fix

pull/1/head
Ivan Yelizariev 9 years ago
parent
commit
3d3bbc81bf
  1. 16
      mail_move_message_models.py
  2. 9
      mail_move_message_views.xml

16
mail_move_message_models.py

@ -31,9 +31,6 @@ class wizard(models.TransientModel):
if model_fields['model']['selection']: if model_fields['model']['selection']:
res['model'] = model_fields['model']['selection'] and model_fields['model']['selection'][0][0] res['model'] = model_fields['model']['selection'] and model_fields['model']['selection'][0][0]
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: if 'message_id' in res:
message = self.env['mail.message'].browse(res['message_id']) message = self.env['mail.message'].browse(res['message_id'])
email_from = message.email_from email_from = message.email_from
@ -48,6 +45,9 @@ class wizard(models.TransientModel):
if message.author_id and self.env.uid not in [u.id for u in message.author_id.user_ids]: if message.author_id and self.env.uid not in [u.id for u in message.author_id.user_ids]:
res['filter_by_partner'] = True res['filter_by_partner'] = True
if message.author_id and res.get('model'):
res_id = self.env[res['model']].search([], order='id desc', limit=1)
res['res_id'] = res_id and res_id[0].id
res['uid'] = self.env.uid res['uid'] = self.env.uid
@ -60,13 +60,14 @@ class wizard(models.TransientModel):
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 = fields.Selection(_model_selection, string='Model') model = fields.Selection(_model_selection, string='Model')
res_id = fields.Integer(string='Record ID')
res_id = fields.Integer(string='Record')
can_move = fields.Boolean('Can move', compute='get_can_move') 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')
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') partner_id = fields.Many2one('res.partner', string='Author', related='message_id.author_id')
filter_by_partner = fields.Boolean('Filter Records by partner') filter_by_partner = fields.Boolean('Filter Records by partner')
message_email_from = fields.Char() message_email_from = fields.Char()
message_name_from = fields.Char() message_name_from = fields.Char()
# FIXME message_to_read should be True even if current message or any his childs are unread
message_to_read = fields.Boolean(related='message_id.to_read') message_to_read = fields.Boolean(related='message_id.to_read')
uid = fields.Integer() uid = fields.Integer()
@ -82,7 +83,7 @@ class wizard(models.TransientModel):
return return
self.parent_id = self.message_id.moved_from_parent_id self.parent_id = self.message_id.moved_from_parent_id
model = self.message_id.moved_from_model model = self.message_id.moved_from_model
if model in [s[0] for s in self._model_selection()]:
if self.message_id.is_moved:
self.model = model self.model = model
self.res_id = self.message_id.moved_from_res_id self.res_id = self.message_id.moved_from_res_id
@ -114,7 +115,7 @@ class wizard(models.TransientModel):
break break
if contact_field: if contact_field:
domain['res_id'] = [(contact_field, '=', self.partner_id.id)] domain['res_id'] = [(contact_field, '=', self.partner_id.id)]
if self.model:
if self.model and self.partner_id:
res_id = self.env[self.model].search(domain['res_id'], order='id desc', limit=1) res_id = self.env[self.model].search(domain['res_id'], order='id desc', limit=1)
self.res_id = res_id and res_id[0].id self.res_id = res_id and res_id[0].id
else: else:
@ -211,6 +212,7 @@ class wizard(models.TransientModel):
@api.one @api.one
def read_close(self): def read_close(self):
self.message_id.set_message_read(True) self.message_id.set_message_read(True)
self.message_id.child_ids.set_message_read(True)
return {'type': 'ir.actions.act_window_close'} return {'type': 'ir.actions.act_window_close'}

9
mail_move_message_views.xml

@ -42,7 +42,7 @@
<label for="res_id"/> <label for="res_id"/>
<div> <div>
<field name="res_id" context="{'extended_name_with_contact':1}" widget="many2one" attrs="{'readonly': [('model','=',False)]}" style="width:50%"/> <field name="res_id" context="{'extended_name_with_contact':1}" widget="many2one" attrs="{'readonly': [('model','=',False)]}" style="width:50%"/>
<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"/>
<button string="Create new record" name="create_record" type="object" class="oe_highlight" attrs="{'invisible':['|',('model','=',False)]}" special="quick_create" field="res_id" use_for_mail_move_message="True"/>
</div> </div>
<label for="move_back" attrs="{'invisible':[('message_is_moved','=',False)]}"/> <label for="move_back" attrs="{'invisible':[('message_is_moved','=',False)]}"/>
<div attrs="{'invisible':[('message_is_moved','=',False)]}"> <div attrs="{'invisible':[('message_is_moved','=',False)]}">
@ -51,14 +51,17 @@
</group> </group>
<button name="move" string="Move" type="object" class="oe_highlight" attrs="{'invisible':[('can_move', '=', False)]}"/> <button name="move" string="Move" type="object" class="oe_highlight" attrs="{'invisible':[('can_move', '=', False)]}"/>
<button string="Close" class="" special="cancel" /> <button string="Close" class="" special="cancel" />
<button name="read_close" string="Mark as read and Close" type="object" class="oe_highlight" attrs="{'invisible':[('message_to_read','=',False)]}"/>
<separator string="Message"/> <separator string="Message"/>
<div> <div>
<field name="message_id" invisible="1"/> <field name="message_id" invisible="1"/>
<field name="message_body"/> <field name="message_body"/>
</div> </div>
<footer> <footer>
<button name="delete" string="Delete message" type="object" class="oe_highlight" confirm="Do you really want to delete this message?" attrs="{'invisible':[('uid','!=',1)]}"/>
<button name="read_close" string="Mark as read and Close" type="object" class="oe_highlight"/> or
<button special="cancel" string="Close" class="oe_link"/>
<button name="delete" string="Delete message" type="object" class="oe_highlight oe_right" confirm="Do you really want to delete this message?" attrs="{'invisible':[('uid','!=',1)]}"/>
</footer> </footer>
</form> </form>
</field> </field>

Loading…
Cancel
Save