-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path27_correct_barcode_member.py
50 lines (41 loc) · 1.67 KB
/
27_correct_barcode_member.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
#! /usr/bin/env python
# -*- encoding: utf-8 -*-
import erppeek
from cfg_secret_configuration import 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, database
openerp, uid, tz, db = init_openerp(
odoo_configuration_user['url'],
odoo_configuration_user['login'],
odoo_configuration_user['password'],
odoo_configuration_user['database'])
###############################################################################
# Script
###############################################################################
def update_barcode_member():
barcode_rule_id = openerp.BarcodeRule.browse(
[('for_type_A_capital_subscriptor', '=', True)], limit=1)
print '\n\n>>>>', barcode_rule_id
if barcode_rule_id and barcode_rule_id.generate_type[0] == 'sequence':
partners = openerp.ResPartner.browse([
('is_member', '=', True),
('barcode_rule_id.for_associated_people', '=', True),
])
print '\n\n>>>>>>>members', partners
for partner in partners:
partner.barcode_rule_id = barcode_rule_id.id[0]
partner.generate_base()
partner.generate_barcode()
return True
# Run the update function
if not openerp:
print ">>>>>>>> Cannot connect to Server <<<<<<<<<"
else:
update_barcode_member()