diff --git a/setup/lib/functions.py b/setup/lib/functions.py index dd680f15..36077f76 100644 --- a/setup/lib/functions.py +++ b/setup/lib/functions.py @@ -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