Skip to Content
Menu
This question has been flagged
647 Views

Hi,


I created an automated action that creates list of different prices based on some products characteristics and returns the values in some custom fields.


My issue is: When I saved my Sales Order and I decide to edit it after by deleting an Order Line, the price does not update accordingly to the deleted line. If I delete a second order line, the price then updates but not correctly.

Does anyone have a solution for this?

Thank you

Here is my code:


listOfRecurrentPrice = []
listOfRecurrentTax = []
listOfTotalRecurrent = []
listOfOneShotPrice = []
listOfOneShotTax = []
listOfTotalOneShot = []

articlePrice = record.product_uom_qty * (record.price_unit - (record.price_unit * (record.discount/100)))

isSubscription = record.product_id.recurring_invoice

for id in record.order_id.order_line:

if isSubscription == True:

record['x_studio_recurrent_price'] = articlePrice
recurrentPrice = id.x_studio_recurrent_price
recurrentPriceTax = recurrentPrice * (record.tax_id.amount/100)
totalRecurrent = recurrentPrice + recurrentPriceTax

listOfRecurrentPrice.append(recurrentPrice)
listOfRecurrentTax.append(recurrentPriceTax)
listOfTotalRecurrent.append(totalRecurrent)

record.order_id['x_studio_total_recurring'] = sum(listOfRecurrentPrice)
record.order_id['x_studio_recurring_taxes'] = sum(listOfRecurrentTax)
record.order_id['x_studio_total_recurring_1'] = sum(listOfTotalRecurrent)

else:

record['x_studio_one_shot_price'] = articlePrice
oneShotPrice = id.x_studio_one_shot_price
oneShotPriceTax = oneShotPrice * (record.tax_id.amount/100)
totalOneShot = oneShotPrice + oneShotPriceTax

listOfOneShotPrice.append(oneShotPrice)
listOfOneShotTax.append(oneShotPriceTax)
listOfTotalOneShot.append(totalOneShot)

record.order_id['x_studio_total_one_shot'] = sum(listOfOneShotPrice)
record.order_id['x_studio_one_shot_taxes'] = sum(listOfOneShotTax)
record.order_id['x_studio_total_one_shot_1'] = sum(listOfTotalOneShot)

Avatar
Discard