multi currency + pricelist + discount => completely wrong sale orders and invoices

Bug #1229232 reported by Alexandre Fayolle - camptocamp
24
This bug affects 5 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Undecided
OpenERP Publisher's Warranty Team

Bug Description

Using different currencies with pricelist with the discount on sale order lines or invoice lines enabled gives completely wrong results.

Instance setup:

* Enable multiple pricelists
* Enable multiple currencies management in the instance
* Enable discount on sale order lines
* Enable purchase pricelists
* Create a new public pricelist in USD, based on the default pricelist with the formula: BasePrice * (1+0.00) + 10
* Create a new purchase price list in USD, based on the standard purchase pricelist with the formula BasePrice * (1+0.00) + 7
* Edit the partner Delta PC: set him as customer, and give him the new Public Pricelist USD as sales pricelist and the new Purchase price list USD as purchase price list
* Edit the Belle-Vue Kriek product, set the cost price to 0.25

Steps to reproduce issue with sale orders
===================================

* Create a new Sale order for Delta PC, add a sale order line, choose "Belle-Vue Kriek" as the product, save the draft sale order.

Expected:

A sale order with a total amount of USD 0.83*1.5289+10 = 11.27, with 1 line with a unit price of 11.27, a discount of 0% and an amount of 11.27

Actual:

A sale order with a total amount of USD 11.27, with 1 line with a unit price of 0.83, a discount of -1257.71% and an amount of 11.27

Steps to reproduce issue with customer invoice
==============================================

* Create a new customer invoice for Delta PC, add an invoice line, choose "Belle-Vue Kriek" as the product, save the draft invoice.

Expected:

A sale order with a total amount of USD 0.83*1.5289+10 = 11.27, with 1 line with a unit price of 11.27, a discount of 0% and an amount of 11.27

Actual:

A sale order with a total amount of EUR 11.27, with 1 line with a unit price of 0.83, a discount of -1257.71% and an amount of 11.27

(note that in addition to the sale order, the currency is incorrect, although the amount is correct)

Steps to reproduce issue with supplier invoice
==============================================

* Create a new Supplier invoice for Delta PC, add an invoice line, choose "Belle-Vue Kriek" as the product, save the draft invoice.

Expected:

A sale order with a total amount of USD 0.25*1.5289+7 = 7.38, with 1 line with a unit price of 7.38, a discount of 0% and an amount of 7.38

Actual:

A sale order with a total amount of EUR 7.38, with 1 line with a unit price of 0.83, a discount of -789.42% and an amount of 7.38

Steps to reproduce with purchase order
======================================

There seem to be *no bug* on purchase order:

* create a new purchase order from Delta PC, add a PO line, choose "Belle-Vue Kriek" as the product, save the draft PO

Expected:

A PO with a total amount of USD 0.25*1.5289+7 = 7.38, with 1 line with
a unit price of 7.38 and an amount of 7.38

Actual: the same.

Tags: maintenance
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

I've reproduced this on runbot build 20771

Changed in openobject-addons:
assignee: nobody → OpenERP Publisher's Warranty Team (openerp-opw)
tags: added: maintenance
Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

Dear OpenERP team,

Please add a YAML test for this issue that need to be corrected and guarantee in the future. A simple fix won't be enough here, and everybody will save hundred time the time spend to wirte this little test. You can easily take the example provided here by Alexandre.

Thanks for your effort,

Regards,

Joël

Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :
description: updated
Revision history for this message
Martin Trigaux (OpenERP) (mat-openerp) wrote :

Hello,

Thanks for the long description but some remarks

- Seeing the behaviour, I think you have the module product_visible_discount installed. This one change the computation to explicitly show the difference as a discount, The fact that you have got a negative discount is on the other hand not normal. This was fixed in 7.0 (revision 9580)

- The fact that you have pricelist applied in invoice is not the expected behaviour. It was an inconsistent behaviour of product_visible_discount (we do that nowhere else). We have fixed that too in addons 7.0 (revision 9580)

If believe there is a issue without product_visible_discount, please let us know.

Regards

Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

Hello Martin

Thanks for looking into this.

After digging a bit in the code, I agree with your analysis : the fault is in the interaction between product_visible_discount and the pricelist which gives very strange results, esp. when the pricelist involves currencies.

Changed in openobject-addons:
status: New → Fix Released
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.