-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[14.0][ADD] sale_order_line_display_stock_per_warehouse #3451
base: 14.0
Are you sure you want to change the base?
[14.0][ADD] sale_order_line_display_stock_per_warehouse #3451
Conversation
e9f7451
to
468a9ea
Compare
qty_data = ( | ||
self.env["stock.quant"] | ||
.with_context(warehouse=warehouse.id) | ||
.read_group( | ||
domain=[ | ||
("product_id", "=", line.product_id.id), | ||
("location_id", "child_of", warehouse.lot_stock_id.id), | ||
], | ||
fields=["quantity:sum"], | ||
groupby=[], | ||
)[0]["quantity"] | ||
) | ||
qty_available = qty_data if qty_data else 0 |
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.
Make it simplier and correct.
qty_data = ( | |
self.env["stock.quant"] | |
.with_context(warehouse=warehouse.id) | |
.read_group( | |
domain=[ | |
("product_id", "=", line.product_id.id), | |
("location_id", "child_of", warehouse.lot_stock_id.id), | |
], | |
fields=["quantity:sum"], | |
groupby=[], | |
)[0]["quantity"] | |
) | |
qty_available = qty_data if qty_data else 0 | |
qty_available = line.product_id.with_context(warehouse=warehouse.id).qty_available |
With the current implementation you have the quantity that you have physically in stock. What we need is the quantity that you can sell. The field qty_available depends on the context passed in the warehouse so it' simplier to reuse this field.
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.
thank you for your review, I fixed it.
468a9ea
to
f6c1181
Compare
module to show available stock per warehouse on sale order lines