c31ca41c6005316a12ff355983d61e52bc41beab
In some conditions, confirming an invoice will raise an Odoo Server
Error due to a division by zero.
To reproduce the issue:
(Need sale_management)
1. Create a product category PC:
- Costing Method: Average Cost (AVCO)
- Inventory Valuation: Automated
2. Create a product P:
- Product Type: Storable
- Category: PC
- Cost: 50
3. Create a sale order SO:
- 5 x P
4. Confirm and process the delivery D
5. Edit P:
- Cost: 40
6. Open D and create a return R:
- 1 x P without "Update quantities on SO/PO"
7. Process R
8. In Inventory, create a transfer T:
- Operation Type: Receipt
- 1 x P
9. Process T
10. Back to SO, create an invoice and post it
Error: an Odoo Server Error is raised: "ZeroDivisionError: float
division by zero"
When validating the transfer T, a stock valuation layer is created with
a zero quantity and is linked to the first SO.order_line.move_ids (i.e.,
the SM from Stock to Customer with 5 x P)
https://github.com/odoo/odoo/blob/dfab388fdf8c7597774ff1738a1b09295c12fb49/addons/stock_account/models/product.py#L439-L450
Then, when posting the invoice, this SVL is used to make a division:
https://github.com/odoo/odoo/blob/dfab388fdf8c7597774ff1738a1b09295c12fb49/addons/stock_account/models/product.py#L690-L691
In such cases, we should ignore this SVL and use the standard price:
https://github.com/odoo/odoo/blob/dfab388fdf8c7597774ff1738a1b09295c12fb49/addons/stock_account/models/product.py#L695-L699
OPW-2647921
OPW-2646419
closes odoo/odoo#77909
X-original-commit: d5eccda583e28a15e8a74a4e82f9e76ec32d0806
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
…
…
Odoo
Odoo is a suite of web based open source business apps.
The main Odoo Apps include an Open Source CRM, Website Builder, eCommerce, Warehouse Management, Project Management, Billing & Accounting, Point of Sale, Human Resources, Marketing, Manufacturing, ...
Odoo Apps can be used as stand-alone applications, but they also integrate seamlessly so you get a full-featured Open Source ERP when you install several Apps.
Getting started with Odoo
For a standard installation please follow the Setup instructions from the documentation.
To learn the software, we recommend the Odoo eLearning, or Scale-up, the business game. Developers can start with the developer tutorials
Languages
Python
49.6%
JavaScript
47.8%
SCSS
2%
CSS
0.3%
HTML
0.2%