Skip to content
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

Open
wants to merge 1 commit into
base: 14.0
Choose a base branch
from

Conversation

Kev-Roche
Copy link
Contributor

module to show available stock per warehouse on sale order lines

@Kev-Roche Kev-Roche force-pushed the 14.0-add-sale_order_line_display_stock_per_warehouse branch 2 times, most recently from e9f7451 to 468a9ea Compare December 3, 2024 20:07
Comment on lines 27 to 39
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
Copy link
Member

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.

Suggested change
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.

Copy link
Contributor Author

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.

@Kev-Roche Kev-Roche force-pushed the 14.0-add-sale_order_line_display_stock_per_warehouse branch from 468a9ea to f6c1181 Compare December 4, 2024 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants