Odoo Help

Welcome!

This community 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.

0

Odoo 9: How to get compute field values in Create ORM method

By
deep
on 8/31/16, 2:35 AM 420 views

In Odoo 9:

am not finding a way to get the value of compute fields in the create method. However the same had achieved in other version by calling the function of compute-fields,


Say for instance in Sale Order:

'amount_total' is a compute field which calls the function "_amount_all" to calculate the amount.


Now in create method, the value for amount_total is yet  to be filled hence in order to access it, one can just call the function _amount_all which will evaluate and return the value of amount_total.

So same way I would like to do in Odoo 9  as well, but not sure whether it is due to this api decorator or so, am unable to achieve .

Any thoughts are welcomed.

Thanks

0
ayman mohammed adam
On 8/31/16, 5:12 AM

dear deep,

you need to do something like this,

 @api.one

@api.depends('amount_currency','currency_id')

@api.onchange('amount_currency','currency_id')

def _amount_in_words(self):

"""

this Function uses to get the ratification amount in words.

"""

self.amount_words_letters = amount_to_text((self.amount_currency or 0.00))

amount_text= fields.Char(compute='_amount_in_words', string='Amount In Words', store=True)


I hope I helped you.

Wish I could say it helped me, but sadly no, Thanks for the reply.

deep
on 9/17/16, 3:30 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 8/31/16, 2:35 AM
Seen: 420 times
Last updated: 11/10/16, 6:03 AM