stock_no_negative bug in Subcontracting process
stock_no_negative bug in Subcontracting process
Module
stock_no_negative
Describe the bug
There is a bug in module stock_no_negative version "14.0.1.0.1" that prevents the default process of production by subcontracting. by default when we receive the final product from the Subcontractor, Odoo will trigger production process automatically by decrease the amount of raw material in subcontractor location and increase the amount of the final product in that location(Manufacturing process). But after installing this module, we will lose this Odoo default feature and when we want to receive the product from subcontractor by validate the receipt operation, this module will not allow us and it says negative stock in subcontracting location is not allowed, even the result of this transaction does not lead to make negative amount of product in subcontracting location.
To Reproduce
Affected versions: "14.0.1.0.1"
Steps to reproduce the behavior:
- Try to use Odoo 14 default routing for subcontracting a product when the raw material is available in subcontractor location.
- Try to receive the final product from subcontractor by validate the corresponding Receipts operation.
Expected behavior If Negative Stock is not allowed for subcontractor location then the module should prevent the user from receiving the final product from subcontractor only if there is not sufficient raw material in stock for that quantity of final product based on related BoM. But if there are enough amount of raw material in subcontracting location the module should not prevent the default process.
Additional context Actually this process is exactly same as internal production, which this module does not have any problem with that, we expected the same behavior in Subcontracting production process as well.
There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.
I confirm this bug.
The problem comes from mrp_subcontracting: when the user validates the incoming picking, Odoo will:
- as usual, move the product from source location to destination location
- run the manufacturing order
So, between 1) and 2), the stock becomes negative on the subcontracting location.
If you update the code of mrp_subcontracting to switch the order:
- run the manufacturing order
- move the product from source location to destination location
it will work without error.
Here is a patch on mrp_subcontracting to change the order: fix-bug-mrp_subcontracting-no_negative.diff.zip
The problem is still present in mrp_subcontracting in master branch, cf https://github.com/odoo/odoo/blob/master/addons/mrp_subcontracting/models/stock_picking.py#L44
We can propose a PR on odoo master to change that.
We should also update the README of the module stock_no_negative about the problem and this solution.
Could someone with the appropriate rights re-open the issue ?
I already depicted and solved the problem for 13.0 in https://github.com/odoo/odoo/pull/75065, because subcontracting does the reception move before producing. but it seems nobody at Odoo cares.
Related: https://github.com/OCA/stock-logistics-workflow/pull/1284 https://github.com/OCA/manufacture/pull/1025
https://github.com/odoo/odoo/pull/110667
If you update the code of mrp_subcontracting to switch the order:
- run the manufacturing order
- move the product from source location to destination location
it will work without error.
Here is a patch on mrp_subcontracting to change the order: fix-bug-mrp_subcontracting-no_negative.diff.zip
I think contribution to Odoo is not so straight forward as my similar attempt https://github.com/odoo/odoo/pull/110667 broke Odoo unit tests, so needs to review them too.
I encountered this error in version 13, when using subcontracting orders, my product enabled a series number. After creating a purchase order, I need to send the raw materials to the supplier, and the supplier will send the finished products after production. Because during the verification of the warehouse receipt, raw materials are deducted and finished products are generated simultaneously. So it is not allowed to fail the verification of the receipt after negative inventory
There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.