-
Notifications
You must be signed in to change notification settings - Fork 4
/
07_update_ignore_product_history.py
59 lines (46 loc) · 1.76 KB
/
07_update_ignore_product_history.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
#! /usr/bin/env python
# -*- encoding: utf-8 -*-
'''
Ticket S#13136: product_history stock shortage
Content:
- Update the history to ignored for history line with outgoing = 0
'''
from cfg_secret_configuration import odoo_configuration_user
import erppeek
import sys
###############################################################################
# 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'])
###############################################################################
# Script
###############################################################################
def update_ignore_product_history():
'''
@Function run by erppeek to update data for product history
'''
print ">>>>>>> START UPDATING PRODUCT HISTORY >>>>>>>>>>"
# Search for all product history with outgoing = 0
product_histories = openerp.ProductHistory.browse(
[('outgoing_qty', '=', 0),
('ignored', '=', False)])
total_line = len(product_histories)
counter = 0
print ">>>> Number of Product History Lines found: %d" % total_line
for line in product_histories:
line.ignore_line()
counter += 1
sys.stdout.write("\rCompleted: %d / %d" % (counter, total_line))
sys.stdout.flush()
print "\n>>>>>>> DONE >>>>>>>>>>"
update_ignore_product_history()