Wednesday, July 31, 2024
3 changes · saas-17.3
Miscellaneous changes
This commit optimizes the `_accumulate_amounts` method. Previously, when there were many stock moves per PoS order, the '_compute_average_price' would be called for each move, resulting in multiple identical queries for each valuation layer in each stock move. Now, the stock moves and valuation layers for an order are prefetched at once, significantly reducing the number of database queries. This results in a performance improvement, especially when processing a large number of PoS orders and
Original PR description
This commit optimizes the `_accumulate_amounts` method. Previously, when there were many stock moves per PoS order, the '_compute_average_price' would be called for each move, resulting in multiple identical queries for each valuation layer in each stock move. Now, the stock moves and valuation layers for an order are prefetched at once, significantly reducing the number of database queries. This results in a performance improvement, especially when processing a large number of PoS orders and stock moves. | Scenario | Before Optimization (seconds) | After Optimization (seconds) | |----------|------------------------------|-----------------------------| | 100 orders, 1,000 stock moves | 20 | 5 | | 300 orders, 100,000 stock moves | 617 | 23 | opw-3980597 --- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr Forward-Port-Of: odoo/odoo#171955 Forward-Port-Of: odoo/odoo#168963
[FIX] stock.landed.cost: Use invoice date currency exchange rate for landed cost computation Fixes an issue where the landed cost computation was based on the exchange rate of the accounting date instead of the invoice date, causing discrepancies in valuation and vendor bill. Now, the exchange rate of the invoice date is correctly utilized for accurate landed cost calculation. To reproduce the issue: 1. Create a purchase order 2. Receive the product 3. Create a vendor bill
Original PR description
[FIX] stock.landed.cost: Use invoice date currency exchange rate for landed cost computation Fixes an issue where the landed cost computation was based on the exchange rate of the accounting date…
[FIX] stock.landed.cost: Use invoice date currency exchange rate for landed cost computation
Fixes an issue where the landed cost computation was based on the exchange rate of the accounting date instead of the invoice date, causing discrepancies in valuation and vendor bill. Now, the exchange rate of the invoice date is correctly utilized for accurate landed cost calculation.
To reproduce the issue:
1. Create a purchase order
2. Receive the product
3. Create a vendor bill for landed cost product in a different currency
4. Click on the "Create Landed Cost" button in the vendor bill
Error: The landed cost is computed using the exchange rate of the accounting date, while the total on the invoice is calculated using the invoice date's exchange rate. This results in a discrepancy between the bill price and the valuation.
The fix ensures that the exchange rate of the invoice date is used for computing the total for the landed cost.
opw-3862915
---
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr
Forward-Port-Of: odoo/odoo#171039
Forward-Port-Of: odoo/odoo#165155**Steps to reproduce the bug:** - Create a consumable product “Kit 1” with the following BoM: - component: X1 - Create a repair order to repair one unit of Kit 1: - Don’t add any part - confirm and Start the repair - try to end the repair **Problem:** A traceback is triggered: “raise ValueError("Expected singleton: %s" % self) Value Error: Expected singleton: stock.location() “ When the "action_repair_end" is called, a move is created with the kit product, and
Original PR description
**Steps to reproduce the bug:** - Create a consumable product “Kit 1” with the following BoM: - component: X1 - Create a repair order to repair one unit of Kit 1: - Don’t add any part - confirm and…
**Steps to reproduce the bug:**
- Create a consumable product “Kit 1” with the following BoM:
- component: X1
- Create a repair order to repair one unit of Kit 1:
- Don’t add any part
- confirm and Start the repair
- try to end the repair
**Problem:**
A traceback is triggered:
“raise ValueError("Expected singleton: %s" % self)
Value Error: Expected singleton: stock.location()
“
When the "action_repair_end" is called, a move is created with the kit
product, and then we attempt to confirm it:
https://github.com/odoo/odoo/blob/eaa6e1a08c3d2cdcb558689523e5bd332978f5e4/addons/repair/models/stock_move.py#L80
Since the product is a kit, it is exploded into two moves with products
“X1” and “X2”. We then try to assign them a “repair” picking_type_id:
https://github.com/odoo/odoo/blob/eaa6e1a08c3d2cdcb558689523e5bd332978f5e4/addons/repair/models/stock_move.py#L74
So, the write method is used and since the “picking_type_id” is in the
vals, and the product in the move (X1) is not the same as the one in the
repair order, we consider this product a “Part” of the repair.
Therefore, we try to use its location_id and location_dest_id, which we
fetch based on the “repair_line_type” that will be False because it is
not a part of the repair but rather the product to be repaired:
https://github.com/odoo/odoo/blob/eaa6e1a08c3d2cdcb558689523e5bd332978f5e4/addons/repair/models/stock_move.py#L93-L94
The first error is triggered during the “should_by_pass” check because
there is no location set in the move:
https://github.com/odoo/odoo/blob/c7b947364d34cc6ccfb1eb7a2c16b6bba226d8e7/addons/stock/models/stock_move.py#L1051-L1052
If we fix this error, we will still encounter an error because both
moves will be confirmed. However, we will return to the first loop to
continue calling the “_trigger_scheduler” function for the first move
with the “Kit” product, which will be already deleted because it was
exploded, resulting in a user error:
“odoo.exceptions.MissingError: Record does not exist or has been deleted.
(Record: stock.move(253,), User: 1)
“
opw-[3942297](https://www.odoo.com/web#id=3942297&view_type=form&model=project.task)
Forward-Port-Of: odoo/odoo#170352
Forward-Port-Of: odoo/odoo#168227