Browse Source

[IMP] : override unlink method to remove deprecated web.shortcut object

[IMP] : add ondelete cascade on menu_id field
[IMP] : change class name from web_shortcut to WebShortcut
pull/159/head
Adil Houmadi 10 years ago
parent
commit
aeb9ac3105
  1. 16
      web_shortcuts/model/web_shortcut.py

16
web_shortcuts/model/web_shortcut.py

@ -22,11 +22,11 @@
from openerp import models, fields, api
class web_shortcut(models.Model):
class WebShortcut(models.Model):
_name = 'web.shortcut'
name = fields.Char('Shortcut Name', size=64)
menu_id = fields.Many2one('ir.ui.menu')
menu_id = fields.Many2one('ir.ui.menu', ondelete='cascade')
user_id = fields.Many2one('res.users', 'User Ref.', required=True,
ondelete='cascade', select=True,
default=lambda obj, cr, uid, context: uid)
@ -52,3 +52,15 @@ class web_shortcut(models.Model):
}
)
return res
class IrUiView(models.Model):
_inherit = 'ir.ui.menu'
@api.multi
def unlink(self):
res = super(IrUiView, self).unlink()
shortcuts = self.env['web.shortcut'].search([('menu_id', '=', False)])
for shortcut in shortcuts:
shortcut.unlink()
return res
Loading…
Cancel
Save