-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathodoo_open_mo.py
80 lines (53 loc) · 2.1 KB
/
odoo_open_mo.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env python3
import pandas as pd
import xmlrpc.client
import ssl
try:
_create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
# Legacy Python that doesn't verify HTTPS certificates by default
pass
else:
# Handle target environment that doesn't support HTTPS verification
ssl._create_default_https_context = _create_unverified_https_context
url = ""
db = ""
username = ""
password = ""
models = xmlrpc.client.ServerProxy('{}/xmlrpc/2/object'.format(url))
common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url))
uid = common.authenticate(db, username, password, {})
sales_to_check_mo = []
orginal_sales_order = models.execute_kw(db, uid, password,
'sale.order', 'search_read',
[[['state', '!=', 'cancel'],
['state', '!=', 'draft']]])
for sales in orginal_sales_order:
print(sales['name'])
sales_to_check_mo.append(sales['name'])
sales_to_check_mo_no_duopes = list(set(sales_to_check_mo))
orders = []
products = []
qty = []
for each_order in sales_to_check_mo_no_duopes:
check_mo = models.execute_kw(db, uid, password,
'mrp.production', 'search_read',
[[['origin', '=', str(each_order)],
'!',
['state', '=', "cancel"], '!',
['state', '=', "done"]]],
)
if not check_mo:
print('No MO record found')
else:
for mo in check_mo:
print(mo)
orders.append(mo['origin'])
products.append(mo['product_id'][1])
qty.append(mo['product_qty'])
df = pd.DataFrame()
df['Order Number'] = orders
df['Product'] = products
df['Remaining to make'] = qty
# Converting to excel
df.to_excel('Odoo_open_MO_to_make.xlsx', index=False)