Browse Source

Add message delete functionality

pull/1/head
Veronika Kotovich 9 years ago
parent
commit
0495092612
  1. 10
      mail_move_message_models.py
  2. 2
      mail_move_message_views.xml
  3. 7
      static/src/js/mail_move_message.js

10
mail_move_message_models.py

@ -27,13 +27,13 @@ class wizard(models.TransientModel):
message_moved_by_message_id = fields.Many2one('mail.message', related='message_id.moved_by_message_id', string='Moved with', readonly=True) message_moved_by_message_id = fields.Many2one('mail.message', related='message_id.moved_by_message_id', string='Moved with', readonly=True)
message_moved_by_user_id = fields.Many2one('res.users', related='message_id.moved_by_user_id', string='Moved by', readonly=True) 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) 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', default=_default_model) model = fields.Selection(_model_selection, string='Model', default=_default_model)
res_id = fields.Integer(string='Record ID', default=_default_res) res_id = fields.Integer(string='Record ID', default=_default_res)
record_url = fields.Char('Link to record', readonly=True) record_url = fields.Char('Link to record', readonly=True)
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')
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')
@api.depends('message_id') @api.depends('message_id')
@ -79,6 +79,7 @@ class wizard(models.TransientModel):
def on_change_partner(self): def on_change_partner(self):
domain = {'res_id': []} domain = {'res_id': []}
if self.model and self.filter_by_partner and self.partner_id: if self.model and self.filter_by_partner and self.partner_id:
self.res_id = None
fields = self.env[self.model].fields_get(False) fields = self.env[self.model].fields_get(False)
contact_field = False contact_field = False
for n, f in fields.iteritems(): for n, f in fields.iteritems():
@ -147,6 +148,11 @@ class wizard(models.TransientModel):
'type': 'ir.actions.act_window', 'type': 'ir.actions.act_window',
} }
@api.one
def delete(self):
self.message_id.unlink()
return {}
class mail_message(models.Model): class mail_message(models.Model):
_inherit = 'mail.message' _inherit = 'mail.message'

2
mail_move_message_views.xml

@ -53,7 +53,7 @@
<field name="message_body"/> <field name="message_body"/>
</div> </div>
<separator/> <separator/>
<button name="delete" string="Delete message" type="object" class="oe_highlight"/>
<button name="delete" string="Delete message" type="object" class="oe_highlight" confirm="Do you really want to delete this message?"/>
</form> </form>
</field> </field>
</record> </record>

7
static/src/js/mail_move_message.js

@ -10,6 +10,7 @@ openerp.mail_move_message = function (session) {
this.$('.oe_move').on('click', this.on_move_message) this.$('.oe_move').on('click', this.on_move_message)
}, },
on_move_message: function(event){ on_move_message: function(event){
var self = this;
var context = { var context = {
'default_message_id': this.id 'default_message_id': this.id
} }
@ -24,7 +25,11 @@ openerp.mail_move_message = function (session) {
context: context, context: context,
}; };
this.do_action(action);
self.do_action(action, {
'on_close': function(){
self.check_for_rerender();
}
});
} }
}) })

Loading…
Cancel
Save