-
-
Notifications
You must be signed in to change notification settings - Fork 690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[11.0][FIX] stock: add move lines from inventory moves #1633
[11.0][FIX] stock: add move lines from inventory moves #1633
Conversation
f000724
to
5c73dea
Compare
Why is this needed? Isn't stock.move coming from inventory lines already in done state? |
Yes, they are already in done state, but it's a "just in case". It's not bad to have them. I am just trying to have a complete stock.move.line migration. |
You are duplicating stock.move.line then, so this is not valid. I'm afraid "just in case" is not enough for accepting this. |
I am not duplicating anything. Each method gives different stock move lines. |
I don't get it then: if they are in done state, then they should be inserted in the other query. The group by sm.picking_id or maybe if there is a |
It's a bit difficult to merge the two methods, they are too different. |
OK, I'll check next week as today I'm holidays. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As said, the extra method is not needed at all, as it's already populated by the general method create_stock_move_line
, so please remove it.
I fix in #1639 the main problem |
e0b29bf
to
8ece51c
Compare
That's not true. The |
When you have a product and then you do "update qty on hand", it generates this stock move lines associated with stock moves that are linked to stock.inventory |
OK, that's what the kind of explanation that I was expecting from the beginning, not now. Let me check again then. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, the concept is correct, but several incorrect things in the SQL.
Other thing: have you taken into account possible inventories in another UoM different from product one? |
565df76
to
a912df7
Compare
Yes, I recently tested that. Works super fine. Want screenshots? :) |
8001ec7
to
be7cb6c
Compare
Ready to review and merge |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to process millions of moves, so better get this query the quickest possible!
be7cb6c
to
0c84b8b
Compare
I updated the PR as you requested, but I don't like this way without subquery. It will create duplicated stock move lines in cases where a stock move is linked to more than one quant with lot. |
@mreficent that is not going to happen as business logic avoids that: although technically the field is a many2many that allows several values, on practice, this is not happening, as you are only able to introduce one lot per inventory line, and thus, that many2many table will have only one record (or none) per each line. |
@pedrobaeza Your statement is False. I have a v10 database, and I have inventory stock moves linked to more than one quant with lot_id |
0c84b8b
to
5e98057
Compare
Also, you can have inventory stock moves that are linked to several quants without any lot_id. Without any way to restrict it to just one quant than using a subquery, I don't know how to do the plain FROM query without creating duplicated stock move lines. Please, just put explicit your ideal query and we will see. |
@mreficent I'm not talking moves in general. I'm talking about moves coming from inventory lines, which is the source of this query. Please check this case. |
It's what I checked. |
This query includes all stock move lines that are generated from stock moves that have the inventory_id filled. If you think there are different subcases, then maybe the good way to handle it is to have one different query for any of these subcases. |
Can you guide me to a case where multiple lots are for the same move? Maybe Odoo groups all the inventory lines with different lots in one move? |
In the case with inventory moves linked to more than one quant with lot_id, the lot_id is the same, not different. |
5e98057
to
fafa5ff
Compare
@mreficent I don't get it. Maybe we can perform a hangout and check it. |
Case 1 (without lots):
Now, check that in the move_quant table, for the move mB there is TWO quants! Thus, if I do your "plain FROM query" will create two stock move lines, one for each quant, and that is a wrong duplication! Case 2 (without lots):
This create a move linked to a quant without lot. No problem with this case. Case 3 (fusion of case 2 and 1, but with lots):
Now check that in the move table, there is a move linked to the inventory adjustment when we updated qty to 50. Then, check in the move_quant table that this move has TWO quants, each quant with lot Ld (one quant has qty 1 and the other has qty 49). |
OK, I see the problem and it's due to how the lots are computed for the field
|
@pedrobaeza We will check how long does it take to migrate with the current approach |
Any news on this? |
Merging this one meanwhile. If someone detects a great bottleneck, then we reconsider the SQL. |
This PR adds the stock moves lines from inventory moves.
--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr