[7.0] Wrong average cost computation when price type currency is different from company currency

Bug #1238525 reported by Frederic Clementi - Camptocamp
32
This bug affects 6 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Invalid
Undecided
OpenERP Publisher's Warranty Team
OpenERP Community Backports (Addons)
Status tracked in 7.0
7.0
Fix Released
High
Joël Grand-Guillaume @ camptocamp

Bug Description

Test done with : http://7-0-22302.runbot.openerp.com/?db=7-0-22302-base

Prerequisites
----------------------
* Install Warehouse management & Purchase
* Go to setting / Configuaration / Purchases and activate 'Manage pricelist per supplier' & 'Compute product cost price based on average cost'
* Go to setting / Configuration / Invoicing and activate 'Allow multi-currency'
* Give the Admin user the Technical Features rights and Financial Manager
* The company is in EUR
* Go to Purchases / Configuration / Pricelists / Price Types
* Modify the currency of the Price type 'Cost Price' to : USD
(This means cost price in all product form are now USD costs.)
* Ensure the current rate of USD is : 1.528900
* Ensure the cost of product 'USB Adapter' is 13.00 and current Qty in inventory is : 0

How to reproduce the bug ?
------------------------------------------------
* Create a new Supplier quotation to ASUStek with product 'USB Adapter' – Qty : 1 – Change the unit price to 20.(This quotation is in EUR)
* Confirm Order
* Receive Products effectively
* Go to Product form and see that the Cost price is 20 → WRONG
EXPECTED : it should be 20€ * 1.528900 = 30.58 $ since my price type is in USD.

Thanks

Frederic Clementi
Camptocamp SA

Tags: maintenance

Related branches

Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

Hi,

Well, this is a very nasty one I must admit. I'm providing here a whole set of YAML test that reveal the bug. 3 tets, only the one with pricelist in different currency is ok.

Please, add and commit those tests in the "purchase" core module to ensure no more regression on that topic in the future will appear. It's too critical for a company.

Thanks !

Changed in ocb-addons:
status: New → Confirmed
importance: Undecided → High
assignee: nobody → Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c)
Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :
Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :
Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :
Changed in ocb-addons:
status: Confirmed → Fix Committed
Changed in openobject-addons:
status: New → Confirmed
Amit Parik (amit-parik)
Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 2 (openerp-dev-addons2)
importance: Undecided → Medium
Changed in openobject-addons:
assignee: OpenERP R&D Addons Team 2 (openerp-dev-addons2) → OpenERP Publisher's Warranty Team (openerp-opw)
Revision history for this message
Somesh Khare (somesh.khare) wrote :

Hello Joel and Frédéric,

Thanks for your contribution on this bug. I have checked this issue at my end and with your patch I can calculate the correct average price when the price type (eg: Cost Price type have different currency such as USD) is other than the company currency. I have fixed this issue with your patch into lp:~openerp-dev/openobject-addons/7.0-opw-599153-skh branch,

Revision ID: <email address hidden>
Revision Number:9527

Soon our experts will review this branch and it will be merged into the stable 7.0 after the approval. Once again thanks for your participation and for your patch.

Regards,
Somesh Khare

Changed in openobject-addons:
status: Confirmed → Fix Committed
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

I don't think this bug report describes a valid use case, if I understand it correctly. The main reason is that the sentence "This means cost price in all product form are now USD costs." is incorrect.

The default cost price and list price of any product are always meant to be expressed in the currency of the company, and the average price calculation is based on that currency and nothing else. This is one of the reasons why OpenERP does not yet support sharing products between companies, especially in case of average costing.

The price types are not meant to be used to change the semantics/currency of the "list price" and "cost price" fields of all products. That would be strange, dangerous, and make existing values suddenly wrong - a bit like changing a company's currency. The price type are exclusively designed to be used for pricelist calculations - and the currency should only be relevant for multi-company cases or extra/custom price fields.
You could have "Cost Price USD" and "Cost Price EUR" price types and use them appropriately in your USD-based and EUR-based companies. But the average cost of each product should always be expressed in the currency of the owner company!

Trying to change this to allow a flawed use case can only lead to more hidden problem and inconsistencies down the road, in my opinion.
For example, your test and patch only consider the first price type based on "standard_price", but there could be many and there is no way to say which one is relevant for a product/company, because that's not their purpose...?

Changed in openobject-addons:
importance: Medium → Undecided
status: Fix Committed → Incomplete
Changed in openobject-addons:
status: Incomplete → Invalid
Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

Hi Olivier,

Thanks for your input here, I can understand your point of view, but I find it sad :( Yes Product prices are meant to be in company currency, but OpenERP allow to setup that differently.. So IMO or remove the possibility to define a standard price in an other currency than company, or fix that bug. Currently you can make mistakes and that's not good.

Sharing product is possible using the price_type as it was originally designed to (years ago) by adding a company_id on it. Here is the module that allow a right price computation per company (and as well add the historization of prices) for both averageor standard price management :

https://code.launchpad.net/~camptocamp/openerp-product-attributes/port-add-product_multi_company_7.0-bis-jge/+merge/192872

Note that this is also inspired from the last WMS work made by Quentin. So OpenERP seems to be agreed on this way to go (or I miss something may be).

What we want is having one field for cost price for all companies , but having various values for them (like properties), but with history. I know we can't address all stuffs. But as long as you can make this setup in OpenERP, I don't see the point not to fix that issue ?

To answer yo here:

Tying to change this to allow a flawed use case can only lead to more hidden problem and inconsistencies down the road, in my opinion.
For example, your test and patch only consider the first price type based on "standard_price", but there could be many and there is no way to say which one is relevant for a product/company, because that's not their purpose...?

=> I say without the module suggested here: https://code.launchpad.net/~camptocamp/openerp-product-attributes/port-add-product_multi_company_7.0-bis-jge/+merge/192872

Company that want to share products need to define a currency for cost price (standard_price). My fix here allow to deal with the use case here:

- One company in Germany (EUR)
- One company in France (EUR)

=> They want to share product and average cost computation => Why not allow them to do that

Same apply with :

- One company in Switzerlan (CHF)
- One company in France (EUR)

=> In that case you need the suggested fix here ! It's true that all compagnies must agree on the currency of the standard price, as it will be the same for all, but it can work perfectly.

My arguements to fix is :

- We need it in that last use
- OpenERP allow to configure stuff like this, so it is a bug if the computation is wrong !
- I don't introduce an regression for all people here
- I even provide the tests that ensure it ;)
- Saying we're not supose to configure like that is not a valid arguments IMO to refuse a fix... Or you remove the possibility to do so

Regards,

Joël

Revision history for this message
Nhomar - Vauxoo (nhomar) wrote : Re: [Bug 1238525] Re: [7.0] Wrong average cost computation when price type currency is different from company currency

2013/11/5 Joël Grand-Guillaume @ camptocamp <
<email address hidden>>

> My arguements to fix is :
>
> - We need it in that last use
> - OpenERP allow to configure stuff like this, so it is a bug if the
> computation is wrong !
> - I don't introduce an regression for all people here
> - I even provide the tests that ensure it ;)
> - Saying we're not supose to configure like that is not a valid arguments
> IMO to refuse a fix... Or you remove the possibility to do so
>

Hello Oliver.

I will complete Joel Arguments.

In the book:

https://doc.openerp.com/book/1/1_3_Real_Case/1_3_Real_Case_db_setup/#creating-products-and-their-categories

- You mention "Multi company enviroments".
- In any place we say "Explicitly" -products don't support multi company-
- We have 90 percent of field property_* on products Is not this to set up
multi company?
- We have an ACL which allow see a product between companies.

Then as Joel says, What is the porpuse to open a lot of miss conceptions
"Officially" and don't accept a solution from community?

IMHO your argument starts in an incorrect principle "Products are not
supported multicompany", because you can not be gray here, or Black or
White, or we don't have only 1 single multi company field and ACL or we
have all them right.

It is my humble opinion.

Thanks Joel for the correction.
Thanks Oliver for take the time.

Regards.

--
--------------------
Saludos Cordiales

Nhomar G. Hernandez M.
+58-414-4110269
Skype: nhomar00
Web-Blog: http://geronimo.com.ve
Servicios IT: http://vauxoo.com
Linux-Counter: 467724
Correos:
<email address hidden>
<email address hidden>
twitter @nhomar

Revision history for this message
Graeme Gellatly (gdgellatly) wrote :
Download full text (4.1 KiB)

What I've never quite got here is that it is very simple to convert
cost_price to be a property field, and also to be a field of product. This
very simple change (OK it requires some migration sometimes) just makes
everything work as expected in a multicompany environment - seperate
average costs for each individual product in each company regardless of
variant use, currencies or anything else really. Been running in
production for 2.5 years, never a problem.

On Wed, Nov 6, 2013 at 2:41 AM, Nhomar - Vauxoo <email address hidden> wrote:

> 2013/11/5 Joël Grand-Guillaume @ camptocamp <
> <email address hidden>>
>
> > My arguements to fix is :
> >
> > - We need it in that last use
> > - OpenERP allow to configure stuff like this, so it is a bug if the
> > computation is wrong !
> > - I don't introduce an regression for all people here
> > - I even provide the tests that ensure it ;)
> > - Saying we're not supose to configure like that is not a valid arguments
> > IMO to refuse a fix... Or you remove the possibility to do so
> >
>
> Hello Oliver.
>
> I will complete Joel Arguments.
>
> In the book:
>
> https://doc.openerp.com/book/1/1_3_Real_Case/1_3_Real_Case_db_setup
> /#creating-products-and-their-categories
>
> - You mention "Multi company enviroments".
> - In any place we say "Explicitly" -products don't support multi company-
> - We have 90 percent of field property_* on products Is not this to set up
> multi company?
> - We have an ACL which allow see a product between companies.
>
> Then as Joel says, What is the porpuse to open a lot of miss conceptions
> "Officially" and don't accept a solution from community?
>
> IMHO your argument starts in an incorrect principle "Products are not
> supported multicompany", because you can not be gray here, or Black or
> White, or we don't have only 1 single multi company field and ACL or we
> have all them right.
>
> It is my humble opinion.
>
> Thanks Joel for the correction.
> Thanks Oliver for take the time.
>
> Regards.
>
>
>
> --
> --------------------
> Saludos Cordiales
>
> Nhomar G. Hernandez M.
> +58-414-4110269
> Skype: nhomar00
> Web-Blog: http://geronimo.com.ve
> Servicios IT: http://vauxoo.com
> Linux-Counter: 467724
> Correos:
> <email address hidden>
> <email address hidden>
> twitter @nhomar
>
> --
> You received this bug notification because you are subscribed to OpenERP
> Addons.
> https://bugs.launchpad.net/bugs/1238525
>
> Title:
> [7.0] Wrong average cost computation when price type currency is
> different from company currency
>
> Status in OpenERP Community Backports (Addons):
> Fix Committed
> Status in OpenERP Addons (modules):
> Invalid
>
> Bug description:
> Test done with :
> http://7-0-22302.runbot.openerp.com/?db=7-0-22302-base
>
> Prerequisites
> ----------------------
> * Install Warehouse management & Purchase
> * Go to setting / Configuaration / Purchases and activate 'Manage
> pricelist per supplier' & 'Compute product cost price based on average cost'
> * Go to setting / Configuration / Invoicing and activate 'Allow
> multi-currency'
> * Give the Admin user the Technical Features rights and Financial Manager
> * The company is in EUR...

Read more...

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.