Browse Source

delete button fix

pull/1/head
Veronika Kotovich 9 years ago
parent
commit
8040cccfe5
  1. 15
      mail_move_message_models.py
  2. 3
      mail_move_message_views.xml

15
mail_move_message_models.py

@ -36,6 +36,8 @@ class wizard(models.TransientModel):
res['message_name_from'] = name
res['message_email_from'] = email
res['uid'] = self.env.uid
return res
message_id = fields.Many2one('mail.message', string='Message')
@ -53,6 +55,7 @@ class wizard(models.TransientModel):
message_email_from = fields.Char()
message_name_from = fields.Char()
message_to_read = fields.Boolean(related='message_id.to_read')
uid = fields.Integer()
@api.depends('message_id')
@api.one
@ -193,18 +196,6 @@ class wizard(models.TransientModel):
self.message_id.set_message_read(True)
return {'type': 'ir.actions.act_window_close'}
@api.model
def fields_view_get(self, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
res = super(wizard, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=False)
doc = etree.XML(res['arch'])
nodes = doc.xpath("//button[@name='delete']")
for node in nodes:
if self.env.uid != 1:
node.set('invisible', "1")
res['arch'] = etree.tostring(doc)
return res
class mail_message(models.Model):
_inherit = 'mail.message'

3
mail_move_message_views.xml

@ -19,6 +19,7 @@
<field name="message_name_from" invisible="1"/>
<field name="message_email_from" invisible="1"/>
<field name="message_to_read" invisible="1"/>
<field name="uid" invisible="1"/>
<p attrs="{'invisible':[('can_move', '!=', False)]}">You cannot move this message. It was already moved with a message bellow. Open one and apply changes there.</p>
<group attrs="{'invisible':[('can_move', '!=', False)]}">
@ -57,7 +58,7 @@
<field name="message_body"/>
</div>
<footer>
<button name="delete" string="Delete message" type="object" class="oe_highlight" confirm="Do you really want to delete this message?"/>
<button name="delete" string="Delete message" type="object" class="oe_highlight" confirm="Do you really want to delete this message?" attrs="{'invisible':[('uid','!=',1)]}"/>
</footer>
</form>
</field>

Loading…
Cancel
Save