e3a074160c249b6dd25648900097d8c0ebf12a9b
[odoo/odoo.git] / addons / web_tip / web_tip.py
1 ##############################################################################
2 #
3 #    OpenERP, Open Source Management Solution
4 #    Copyright (C) 2009-Today OpenERP SA (<http://www.openerp.com>)
5 #
6 #    This program is free software: you can redistribute it and/or modify
7 #    it under the terms of the GNU Affero General Public License as
8 #    published by the Free Software Foundation, either version 3 of the
9 #    License, or (at your option) any later version
10 #
11 #    This program is distributed in the hope that it will be useful,
12 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 #    GNU Affero General Public License for more details
15 #
16 #    You should have received a copy of the GNU Affero General Public License
17 #    along with this program.  If not, see <http://www.gnu.org/licenses/>
18 #
19 ##############################################################################
20
21 from openerp import models, fields, api
22
23
24 class tip(models.Model):
25     _name = 'web.tip'
26     _description = 'Tips'
27
28     @api.one
29     @api.depends('user_ids')
30     def _is_consumed(self):
31         if self.env.uid in self.user_ids:
32             self.is_consumed = True
33         else:
34             self.is_consumed = False
35
36     title = fields.Char('Tip title')
37     description = fields.Html('Tip Description', required=True)
38     action_id = fields.Many2one('ir.actions.act_window', string="Action",
39         help="The action that will trigger the tip")
40     model = fields.Char("Model", help="Model name on which to trigger the tip, e.g. 'res.partner'.")
41     type = fields.Char("Type", help="Model type, e.g. lead or opportunity for crm.lead")
42     mode = fields.Char("Mode", help="Mode, e.g. kanban, form")
43     trigger_selector = fields.Char('Trigger selector', help='CSS selectors used to trigger the tip, separated by a comma (ANDed).')
44     highlight_selector = fields.Char('Highlight selector', help='CSS selector for the element to highlight')
45     end_selector = fields.Char('End selector', help='CSS selector used to end the tip')
46     end_event = fields.Char('End event', help='Event to end the tip', default='click')
47     placement = fields.Char('Placement', help='Popover placement, bottom, top, left or right', default='auto')
48     user_ids = fields.Many2many('res.users', string='Consumed by')
49     is_consumed = fields.Boolean(string='Tip consumed', compute='_is_consumed')
50
51     @api.multi
52     def consume(self):
53        self.write({'user_ids': [(4, self.env.uid)]})