- Mailing Lists
- Contributors
- Re: stock: Retroactively removing lots from incompatible products in stock move history
Archives
- By thread 1419
-
By date
- August 2019 59
- September 2019 118
- October 2019 165
- November 2019 97
- December 2019 35
- January 2020 58
- February 2020 204
- March 2020 121
- April 2020 172
- May 2020 50
- June 2020 158
- July 2020 85
- August 2020 94
- September 2020 193
- October 2020 277
- November 2020 100
- December 2020 159
- January 2021 38
- February 2021 87
- March 2021 146
- April 2021 73
- May 2021 90
- June 2021 86
- July 2021 123
- August 2021 50
- September 2021 68
- October 2021 66
- November 2021 74
- December 2021 75
- January 2022 98
- February 2022 77
- March 2022 68
- April 2022 31
- May 2022 59
- June 2022 87
- July 2022 141
- August 2022 38
- September 2022 73
- October 2022 152
- November 2022 39
- December 2022 50
- January 2023 93
- February 2023 49
- March 2023 106
- April 2023 47
- May 2023 69
- June 2023 92
- July 2023 64
- August 2023 103
- September 2023 91
- October 2023 101
- November 2023 94
- December 2023 46
- January 2024 75
- February 2024 79
- March 2024 104
- April 2024 63
- May 2024 40
- June 2024 160
- July 2024 80
- August 2024 70
- September 2024 62
- October 2024 121
- November 2024 117
- December 2024 89
- January 2025 59
- February 2025 104
- March 2025 96
- April 2025 107
- May 2025 52
- June 2025 72
- July 2025 60
- August 2025 81
- September 2025 124
- October 2025 63
- November 2025 22
Contributors
Re: stock: Retroactively removing lots from incompatible products in stock move history
On 1/7/22 10:47 AM, Carmen Bianca
Bakker wrote:
I have also verified that the quantities in the inventory have correctly added up (the quantities of bottles that previously had lots are added to the lot-less bottles).
I think at least for the stock_quant table, this is all you had to verify, and you have, so that's fine.
As for the modification that you did in "stock_move_line", I'm less sure - you're changing history there. I'm also not sure if doing that was really necessary to achieve your goal to make the inventory work again.
If you want to be sure, I would revert the stock move line table to a recent backup, and then do some more testing in a test database if that modification is really necessary.
by Tom Blauwendraat - 11:06 - 7 Jan 2022
Reference
-
stock: Retroactively removing lots from incompatible products in stock move history
Hi all, I'm a little bit new to Odoo, so please bear with me if I don't get everything right, but I've been told that I have struck a difficult bug. TL:DR: Having removed the lot_id from certain rows (products that are incompatible with that lot) in stock_move_line and stock_quant, how do I know I haven't broken something? I have a database that was migrated from Odoo 9 to Odoo 12. Before the migration, there was a bug that assigned lots to by-products of a dismantling operation (in this case, empty bottles were assigned the lots of full bottles of wine). As a result, during inventory on Odoo 12, the error message from StockMoveLine._check_lot_product() shows up, correctly identifying that these various lots are incompatible with empty bottles, then aborting the validation. Because these lots were added in error, I want to remove them from all past stock moves. This cannot be done through the UI, so I've made these SQL statements to get it done: ``` update stock_move_line set lot_id = null, lot_name = null where product_id in (67, 38, 29) and lot_id is not null; update stock_quant set lot_id = null where product_id in (67, 38, 29) and lot_id is not null; ``` (the product_ids here are empty bottles) Having run the above on a test/staging database, I can now do the inventory without troubles. I have also verified that the quantities in the inventory have correctly added up (the quantities of bottles that previously had lots are added to the lot-less bottles). The quantities on the `product.product` view have remained the same, which makes sense to me. I have also triggered `_compute_quantities()` for 'product.product', and nothing has changed. Although everything works and my problems seem to have disappeared, the problem is that I do not know whether I have inadvertently corrupted the (test!) database. I've been reading the source code of the stock module to find interactions with lot_id and lot_name, but I've not really found anything troubling. Does my approach make sense? Is there anything I can do to verify the integrity of what I've done? Many thanks and best regards, Carmen Bianca Bakker Coop IT Easy
by Carmen Bianca Bakker - 10:46 - 7 Jan 2022