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):
"""Odoo-Touren auf konsumiert setzen"""
web_tour_obj = self.odoo.env['web_tour.tour']
tours = [
'crm_tour',
@ -782,13 +783,21 @@ class DatenpolFunctions:
'event',
]
already_set_tours = []
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:
vals = {
'name': t,
'user_id': uid,
}
self.odoo.env['web_tour.tour'].create(vals)
if t not in already_set_tours:
vals = {
'name': t,
'user_id': uid,
}
web_tour_obj.create(vals)
already_set_tours = []
return True