Improving multi-company currency management

Bug #768197 reported by Ferdinand
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Confirmed
Wishlist
OpenERP R&D Addons Team 3

Bug Description

in supplier invoices it is possible to select a currency which belongs to another company.

missing rule
['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]

Revision history for this message
Ferdinand (office-chricar) wrote :

I have to amend my previous comment

IMHO res.currency should not have set a company at all.

the table is standard

what could make sens is to have different res_currency_rate for different companies. but this is not implemented.

Revision history for this message
Ferdinand (office-chricar) wrote :

what happens with standard config:
the currency table is fille using the first company_id when it is created.

the second company uses the existing currency from the first company as the rule mentioned in #1 is missing.

* implementing rule #1 causen an access error.

Please advise how this is designed.

Revision history for this message
Stéphane Bidoul (Acsone) (sbi) wrote :

Hi,

I think I'm hitting a similar issue. I'm using the 6.0 series.

I'm working with two companies, both using EUR as currency. In the currency table, however as Ferdinand mentions above, the system has only one set of currencies by default, all associated with the first company. So both companies point to the same currency object.

Now, in invoice.py, onchange_company_id(), it seems that the system expects to have on different currency object linked to each company.

        if currency_id and company_id:
            currency = self.pool.get('res.currency').browse(cr, uid, currency_id)
            if currency.company_id and currency.company_id.id != company_id:
                val['currency_id'] = False
            else:
                val['currency_id'] = currency.id
        if company_id:
            company = self.pool.get('res.company').browse(cr, uid, company_id)
            if company.currency_id.company_id and company.currency_id.company_id.id != company_id:
                val['currency_id'] = False
            else:
                val['currency_id'] = company.currency_id.id

So should I really duplicate each currency for each company? Or should the code above be relaxed in case currencty.company_id does not mache the invoice company_id?

Best regards,

-sbi

summary: - currency - not multi company ready
+ Improving multi-company currency management
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Hello,

Let me explain a little bit the rationale behind the design in 6.0.
As you said, the list of currencies is usually not something that changes from company to company. However, in order to still allow it, they can be assigned to a specific company. We could have done it on the rates instead, with the consequence that only the rates would be able to vary from company to company, with the list of currencies totally global (Note: that option is still open for the future, but we cannot change that in 6.0, as it implies a change of model).

In addition to this, there is no default rule for filtering the currencies per company, in order to have the system behave by default as if they really were global.

So... if you want to have different currencies/rates per company, you normally need 2 steps:

1. Create a dedicated rule for filtering, as you suggested, such as:
     ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] (if child companies need to share with parent)
         or
     ['|',('company_id','=',False),('company_id','=',user.company_id.id)] (if each company needs their own)

2. Remove the company that is assigned on the currencies you want to share globally, and make sure to duplicate the other ones according to the rule you selected in 1.

If that doesn't work, what kind of error do you get?

@Stephane: the code you're quoting from the on_change() on invoice is only present to help the user select an appropriate currency in case you have decided to have them per-company. This probably leads to some confusion due to the fact by default the currencies belong to the initial main company.
To improve usability we could perhaps change the default currencies so they have no company set at all, making them properly 'global' in all ways. I guess this would avoid strange behaviors when changing an invoice's company.

What are your thoughts, for 6.0 and trunk? For trunk, ideas could also be submitted on feedback.openerp.com to see what people think.

Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 3 (openerp-dev-addons3)
importance: Undecided → Wishlist
status: New → Confirmed
Revision history for this message
Stéphane Bidoul (Acsone) (sbi) wrote :

Hello Olivier,

Thanks a lot for the detailed explanation. Now that I see that the currency.company_id is optional, everything makes sense.

To avoid confusing new users, setting up default currencies with company_id = null would be better indeed.

Regarding trunk I can't really judge, as I don't have a requirement of varying rates per company. I assume the current code gives the most flexibility.

Best regards,

-sbi

Revision history for this message
jugglefish (pniederlag) wrote :

thx for the detailed explanation. In 6.1 the main_company is still assigned to all res.currency.
are there any more experiences yet as wether it is better to duplicate all res,currency for second company or wether it works when setting company_id=NULL on res.currency?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.