Initialze order_id attribute of OdooShell

We need this attribute to be initialized as we use it in error handling
to cancel the order.

Change-Id: Ifb31eac46ded8debe1fe03aea46d41d2e2586921
This commit is contained in:
Lingxian Kong 2016-03-02 17:26:40 +13:00 committed by Fei Long Wang
parent 7df79856c8
commit 9509113d39
2 changed files with 13 additions and 5 deletions

1
odoo/.gitignore vendored
View File

@ -1,2 +1,3 @@
glue.ini
*.pyc
failed_tenants.txt

View File

@ -242,13 +242,16 @@ def check_odoo_duplicate(shell, partner_id, tenant_id, billing_date):
('state', '!=', 'cancel')
]
)
for o_id in orders:
order = shell.Order.read(o_id)
if tenant_id in order['note']:
print('ERROR: order of tenant %s has been already generated. '
'Billing date: %s.' % (tenant_id, billing_date))
return True
print(
'ERROR: order of tenant %s has been already generated. '
'Quotation name: %s, Billing date: %s.' %
(tenant_id, order['name'], billing_date)
)
return True
return False
@ -343,7 +346,10 @@ def do_quote(shell, args):
build_sales_order(shell, args, pricelist, usage, partner,
tenant.name, tenant.id, billing_date)
except Exception as e:
print "Failed to create sales order for tenant: %s" % tenant.name
print (
"\nFailed to create sales order for tenant: %s(%s)\n"
% (tenant.name, tenant.id)
)
with open('failed_tenants.txt', 'a') as f:
f.write(tenant.id + "\n")
@ -535,6 +541,7 @@ def get_price(shell, pricelist, product, volume):
def build_sales_order(shell, args, pricelist, usage, partner, tenant_name,
tenant_id, billing_date):
log(shell.debug, 'Building sale.order')
shell.order_id = None
try:
order_dict = {