Skip to Content
Menu
This question has been flagged
5 Replies
3632 Views

Hello,

I have code that I'm running in automated actions on the sales order.order lines that loops through the records and finds a product and updates the line-item to a new value.

This code was working until ODOO 12, now I'm in 13 and its stalling the interface with a wait symbol.

Code Below:

for line in record.order_line:
if (line.product_id.categ_id.parent_id.name=="SLA"):
if(line.product_id.categ_id.name == "Gold"):
calcAmount = (record.amount_total - line.price_total) * 0.12
line.update({"price_unit": calcAmount})
if(line.product_id.categ_id.name == "Silver"):
calcAmount = (record.amount_total - line.price_total) * 0.08
line.update({"price_unit": calcAmount})
if(line.product_id.categ_id.name == "Platinum"):
calcAmount = (record.amount_total - line.price_total) * 0.15
line.update({"price_unit": calcAmount})

Can you give any pointers on this?


Thank you in advance

Avatar
Discard
Best Answer

Hi Edward:

You may want to check the Odoo server log to see if it provides any clues to what is happening.

Avatar
Discard
Best Answer

I'm no expert, but would it help if you set calcAmount = 0 before the calculation?  

for line in record.order_line:

calcAmount = 0
if (line.product_id.categ_id.parent_id.name=="SLA"):
if(line.product_id.categ_id.name == "Gold"):
calcAmount = (record.amount_total - line.price_total) * 0.12
line.update({"price_unit": calcAmount})
if(line.product_id.categ_id.name == "Silver"):
calcAmount = (record.amount_total - line.price_total) * 0.08
line.update({"price_unit": calcAmount})
if(line.product_id.categ_id.name == "Platinum"):
calcAmount = (record.amount_total - line.price_total) * 0.15
line.update({"price_unit": calcAmount})


Avatar
Discard
Author

Chris - thanks for the reply. In Automated actions, variable creation is implicit based upon data type - so it's already set to zero prior to starting the process. This original code works, but it goes into "spinning" wheel of death - which is so much fun.

Thank you for your comments - though - they are appreciated.

Cheers!

OK, I had a similar problem (Automated Action worked in 12 but not in 13) and this did help, but I have to admit that I didn't understand why!!