You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Without going into much detail, the logic that Odoo is doing only works when the invoice lines related to the purchase order line are not including the stock journal items. Otherwise, the revaluation does not happen and the feature is lost.
You can test in a V16 odoo standard with a FIFO Automated product. The expected result would be like the following:
1- Warehouse receipt
2- Vendor Bill
3- Automatically generated entry for the difference
Solution
Two solutions come to mind:
Use a new field in account_move_line_purchase_info to relate all journal items for a purchase.
Propose a hook to Odoo in order to filter out the stock journal items in the affected method.
I think it is best to add a new field in the account_move_line_purchase_info to relate all journal items for a purchase.
At first it may be a pain (there are a couple of modules that depends on this one) but in the long term this is the less time consuming solution. Maintaining a hook module would be more time consuming and I don't think Odoo is willing to merge such hooks in v16.
Problem
Since Odoo V16, automatic revaluation is handled whenever the vendor bill price and the purchase price is different for a product with FIFO costing method. This is done when the invoice is posted: https://github.com/odoo/odoo/blob/05ce1a521d9702ce490100354d2b19007c35bb62/addons/purchase_stock/models/account_invoice.py#L159
The method
_generate_price_difference_vals
(https://github.com/odoo/odoo/blob/05ce1a521d9702ce490100354d2b19007c35bb62/addons/purchase_stock/models/account_move_line.py#L157) is used to prepare the values for the new layer adjusting the stock value, and Odoo will afterwards automatically reconcile the difference with the other stock interim account journal items.The problem comes when Odoo loops through the invoice lines related to the purchase order line of the layer: https://github.com/odoo/odoo/blob/05ce1a521d9702ce490100354d2b19007c35bb62/addons/purchase_stock/models/account_move_line.py#L171. Due to the module account_move_line_purchase_info, the stock journal items created when products from a purchase order are received are being related to the purchase order line. As a result, the invoice lines related to a purchase order line are also including the stock journal items.
Without going into much detail, the logic that Odoo is doing only works when the invoice lines related to the purchase order line are not including the stock journal items. Otherwise, the revaluation does not happen and the feature is lost.
You can test in a V16 odoo standard with a FIFO Automated product. The expected result would be like the following:
1- Warehouse receipt
2- Vendor Bill
3- Automatically generated entry for the difference
Solution
Two solutions come to mind:
Looking forward to your feedback
CC @OCA/accounting-maintainers @ForgeFlow
The text was updated successfully, but these errors were encountered: