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

Leonardo Donelli

--Leonardo Donelli--
1040
| 5 4 8
Cave, Italy
--Leonardo Donelli--

Physics student and part-time developer.

Leonardo Donelli
On 6/15/16, 4:11 AM

The company model (res.company) has a many2one to the company currency, so in v8 and later you can use:

self.env.ref('base.main_company').currency_id
-1

Nehal

--Nehal--
2090
| 5 2 8
Ahmadabad, India
--Nehal--
Nehal
On 7/19/14, 12:16 AM

Hi,

You can do as following:

    def _get_currency(self, cr, uid, context=None):
        user_obj = self.pool.get('res.users')
        currency_obj = self.pool.get('res.currency')
        user = user_obj.browse(cr, uid, uid, context=context)

        if user.company_id:
            return user.company_id.currency_id.id
        else:
            return currency_obj.search(cr, uid, [('rate', '=', 1.0)])[0]
_defaults = {      
        'currency': _get_currency,
 }

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

2 follower(s)

Stats

Asked: 7/18/14, 2:09 PM
Seen: 1838 times
Last updated: 6/15/16, 6:19 AM