Odoo Help

2

0
4 Answers
1
Avatar

Akhil P Sivan India

--Akhil P Sivan--

5967
| 6 5 9
Kochi, India
--Akhil P Sivan--

Odoo Developer

email-id : akhilpsivan01@gmail.com

Akhil P Sivan India
10/12/15, 10:38 PM

Hi,

Hope you are working with v8. I don't think, you need to override the onchange function.

If your tax_amount depends only on product uom, you can define the tax_amount as a compute field which depends on product_uom. onchange is default in compute fields. If tax_amount depends on more fields, you can include that also. For eg:

class sale_order_line(models.Model):
_inherit = 'sale.order.line'

tax_amount = fields.Float(compute='_get_tax_amount', string='Tax Amount')

@api.one
@api.depends('product_uom', 'product_id')
def _get_tax_amount(self):

//Your code here that calculates the tax value
self.tax_amount = tax value
0
Sharmila India
5/12/17, 8:41 AM

Hi,

You can call the function field method from onchange method.

class sale_order_line(models.Model):
_inherit = 'sale.order.line'

tax_amount = fields.Float(compute='_get_tax_amount', string='Tax Amount')

@api.one
@api.depends('product_uom', 'product_id')
def _get_tax_amount(self):

//Your code here that calculates the tax value
self.tax_amount = tax value

0
Avatar

René Schuster Germany

--René Schuster--
1788
| 7 7 10
Weinheim, Germany
--René Schuster--

Challenge Everything!

René Schuster Germany
6/26/14, 7:43 AM

Simply call your function from within the on_change method.

Take care of the scope and use self.function_name.

An example can be found in the hr_holidays module: onchange_date_from calls _get_number_of_days

 

Regards.

1 Comment
Vikram India
6/26/14, 10:07 AM

Yes! You can call a function(Normal) from onchange, but need to call a function _amount_tax_line (function field defined in column of sale.order.line class). A function field column is called when you press Save button but need to call from onchange_product_id function from sale.order.line...

Ask a Question
Writer
Keep Informed
2 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now