-
Notifications
You must be signed in to change notification settings - Fork 0
/
cancel_shifts.py
executable file
·51 lines (42 loc) · 1.58 KB
/
cancel_shifts.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#! /usr/bin/env python3
# -*- encoding: utf-8 -*-
import sys
import erppeek
import csv
import unidecode
import traceback
from cfg_secret_configuration\
import odoo_configuration_user_test as odoo_configuration_user
###############################################################################
# Odoo Connection
###############################################################################
def init_openerp(url, login, password, database):
openerp = erppeek.Client(url)
uid = openerp.login(login, password=password, database=database)
user = openerp.ResUsers.browse(uid)
tz = user.tz
return openerp, uid, tz
openerp, uid, tz = init_openerp(
odoo_configuration_user['url'],
odoo_configuration_user['login'],
odoo_configuration_user['password'],
odoo_configuration_user['database'])
###############################################################################
# Configuration
###############################################################################
###############################################################################
# Script
###############################################################################
date_begin = "2021-06-07"
date_end = "2021-08-29"
for shift in openerp.ShiftShift.browse([("active", "=", True),
"&", ("date_begin", ">=", date_begin), ("date_begin", "<=", date_end)]):
print(shift)
for ticket in shift.shift_ticket_ids:
if ticket.shift_type == 'ftop':
ticket.seats_max = 0
print(ticket.available_seat_ftop)
try:
shift.button_cancel()
except:
pass