Help

0

[Odoo 13][methods] [python] Problem with process_cancel_backorder

Hi !


I made a python script that update odoo stock.move, line and oders in a workflow with my shipping partner.

I use a call to stock_model.button_validate move lines after an quantity done update.

this method call the popup backorder confirmation.

So I managed it by this command :

back_order_exec.process_cancel_backorder([id]) to "click" on the "cancel" button.
But from time to time this call cause the famous :

TypeError: 'bool' object has no attribute '__getitem__'

_-_-_-_-_-_-_-_-_-_-_-  here is my code :

for indy in range(0,len(Stratos_data)):    ##  Stratos_data is an array of array from a csv file

var_num_bc = Stratos_data[indy][0].strip()

var_upc = Stratos_data[indy][8].strip() 

move_lkp = move_model.search_read([('origin','=',var_num_bc),('product_id','ilike',var_upc)],['reference','product_id','quantity_done','origin','product_uom_qty','state']) #('origin','=',var_num_bc),

for move_line in move_lkp: 

move_qty = move_model.write([move_line['id']], {'quantity_done': int(Stratos_data[indy][9])}) 

# End Move line

print (" ----------- BL Validation--------  <BR>")

# 2nd round for valid

#activate button validation  

var_num_bdc_prec="1er"

for indy in range(0,len(Stratos_data)):

var_num_bc = Stratos_data[indy][0].strip()

var_upc = Stratos_data[indy][8].strip() 

if var_num_bc != var_num_bdc_prec: ## same stock.move ?

#lookup id BDC 

bdc_id_lkp = stock_model.search_read([('origin','=',var_num_bc)],['create_date','display_name','origin'])

for bdc_id_line in bdc_id_lkp:

num_id_bdc_lkp = bdc_id_line['id']

toto=stock_model.button_validate([num_id_bdc_lkp])  

# activate button cancel backorder

tata=back_order_exec.process_cancel_backorder([toto['res_id']])   

print (tata) # for checking

move_lkp = move_model.search_read([('origin','=',var_num_bc),('product_id','ilike',var_upc)],['reference','product_id','quantity_done','origin','product_uom_qty','state']) #('origin','=',var_num_bc),

for move_line in move_lkp:

move_done = move_model.write([move_line['id']], {'state': 'done'})   

else:

print (var_num_bc),( " = "),(var_num_bdc_prec),(" deja valid&eacute; !<BR>")

#store actual id in var var_num_bdc_prec  for if condition

var_num_bdc_prec = var_num_bc

#End of indy loop

-_-_-_-_-_-_-_-

I anyone have an idea ?
Thanks a lot !
Avatar
Negeren
1 Antwoord
0
Beste antwoord

Anyone ? No idea ?

Avatar
Negeren