Skip to Content
Menu
This question has been flagged
1 Reply
1632 Views

Impacted versions: 10

Steps to reproduce:
I have an onchange method for calculating the price and price_taxed

@api.onchange('price', 'tax_rate')
    def onchange_price(self):
        price = self.price_taxed / (1 + self.tax_rate * 0.01) 
        decimal = self.env.ref('core.decimal_price')
        if float_compare(price, self.price, precision_digits=decimal.digits) != 0:
            self.price_taxed = self.price * (1 + self.tax_rate * 0.01)

It can help me figure out priceo or price_taxed,But sometimes, it doesn't work,
I wonder if api.onchang doesn't work when the network is unstable?
I don't understand a method sometimes works and sometimes doesn't.


Avatar
Discard
Best Answer

Hi,

You can solve this issue by adding 

@api.depends('price', 'tax_rate') along with current code


Avatar
Discard
Author

thank you for response, But I don't need a computed field, I want it to be updated in real time on the page

try the above it will act as real time, no compute function required