config_at: Konsumiere Tour erstellt jetzt nur ein Eintrag pro User und Tour

develop
Ahmed Aly 2017-11-27 13:40:58 +01:00
parent 99a7b88ee2
commit 549beeb41e
1 changed files with 14 additions and 5 deletions

View File

@ -769,6 +769,7 @@ class DatenpolFunctions:
def consume_tours(self): def consume_tours(self):
"""Odoo-Touren auf konsumiert setzen""" """Odoo-Touren auf konsumiert setzen"""
web_tour_obj = self.odoo.env['web_tour.tour']
tours = [ tours = [
'crm_tour', 'crm_tour',
@ -782,13 +783,21 @@ class DatenpolFunctions:
'event', 'event',
] ]
already_set_tours = []
for uid in self.odoo.env['res.users'].search([]): for uid in self.odoo.env['res.users'].search([]):
user_webtours = web_tour_obj.browse(web_tour_obj.search([('name', 'in', tours), ('user_id', '=', uid)]))
for user_webtour in user_webtours:
if user_webtour.name in tours:
already_set_tours.append(user_webtour.name)
for t in tours: for t in tours:
if t not in already_set_tours:
vals = { vals = {
'name': t, 'name': t,
'user_id': uid, 'user_id': uid,
} }
self.odoo.env['web_tour.tour'].create(vals) web_tour_obj.create(vals)
already_set_tours = []
return True return True