mirror of
https://github.com/bringout/oca-ocb-web.git
synced 2026-04-22 09:51:59 +02:00
Initial commit: Web packages
This commit is contained in:
commit
cd458d4b85
791 changed files with 410049 additions and 0 deletions
|
|
@ -0,0 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import ir_http
|
||||
from . import tour
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
16
odoo-bringout-oca-ocb-web_tour/web_tour/models/ir_http.py
Normal file
16
odoo-bringout-oca-ocb-web_tour/web_tour/models/ir_http.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import models
|
||||
|
||||
|
||||
class Http(models.AbstractModel):
|
||||
_inherit = 'ir.http'
|
||||
|
||||
def session_info(self):
|
||||
result = super().session_info()
|
||||
if result['is_admin']:
|
||||
demo_modules_count = self.env['ir.module.module'].sudo().search_count([('demo', '=', True)])
|
||||
result['web_tours'] = self.env['web_tour.tour'].get_consumed_tours()
|
||||
result['tour_disable'] = demo_modules_count > 0
|
||||
return result
|
||||
30
odoo-bringout-oca-ocb-web_tour/web_tour/models/tour.py
Normal file
30
odoo-bringout-oca-ocb-web_tour/web_tour/models/tour.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class Tour(models.Model):
|
||||
|
||||
_name = "web_tour.tour"
|
||||
_description = "Tours"
|
||||
_log_access = False
|
||||
|
||||
name = fields.Char(string="Tour name", required=True)
|
||||
user_id = fields.Many2one('res.users', string='Consumed by')
|
||||
|
||||
@api.model
|
||||
def consume(self, tour_names):
|
||||
""" Sets given tours as consumed, meaning that
|
||||
these tours won't be active anymore for that user """
|
||||
if not self.env.user.has_group('base.group_user'):
|
||||
# Only internal users can use this method.
|
||||
# TODO master: update ir.model.access records instead of using sudo()
|
||||
return
|
||||
for name in tour_names:
|
||||
self.sudo().create({'name': name, 'user_id': self.env.uid})
|
||||
|
||||
@api.model
|
||||
def get_consumed_tours(self):
|
||||
""" Returns the list of consumed tours for the current user """
|
||||
return [t.name for t in self.search([('user_id', '=', self.env.uid)])]
|
||||
Loading…
Add table
Add a link
Reference in a new issue