Hi,
i'm trying to customize code of sale_order,
some field value is not updating.
i'm try to inherit base field (amount_untaxed).
and try to update it.
i'm using this code,
@api.depends('order_line.product_uom_qty','order_line.price_total')
def compute_discount(self):
import pdb;pdb.set_trace()
total_order_qty=0
sale_order_line=self.env['sale.order.line'].search([('order_id','=',self.id)])
for product_qty in sale_order_line:
total_order_qty+=product_qty.product_uom_qty
if(total_order_qty>=10 and total_order_qty<20):
applied_discount="10%"
extra_discount_amount=(self.amount_untaxed*10)/100
amount_untaxed=self.amount_untaxed-extra_discount_amount
print(applied_discount,extra_discount_amount,amount_untaxed)
values={
'amount_untaxed':amount_untaxed,
'extra_discount_amount':extra_discount_amount,
'applied_discount':applied_discount,
}
self.update(values)
Thanks