-
-
Notifications
You must be signed in to change notification settings - Fork 787
[14.0][ADD] stock_resupply_order #2412
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
base: 14.0
Are you sure you want to change the base?
Conversation
f703e5c
to
e06d1c2
Compare
e06d1c2
to
27e2ff7
Compare
27e2ff7
to
d1ffd9c
Compare
03329ca
to
a9c6661
Compare
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.
LGTM
a9c6661
to
54a9ecc
Compare
def _get_existing_quants(self): | ||
""" | ||
Get stock quants at the targeted location. Override if you need to | ||
apply specific constraints. | ||
""" | ||
|
||
self.ensure_one() | ||
|
||
return ( | ||
self.env["stock.quant"] | ||
.sudo() | ||
.read_group( | ||
domain=[ | ||
("location_id", "=", self.location_id.id), | ||
( | ||
"product_id", | ||
"in", | ||
self.stock_resupply_order_lines.product_id.ids, | ||
), | ||
], | ||
# Cant aggregate available_quantity here. | ||
fields=["product_id", "quantity:sum", "reserved_quantity:sum"], | ||
groupby=["product_id"], | ||
orderby="product_id", | ||
lazy=False, | ||
) | ||
) |
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.
I suppose other part of the source code would be easier to read if this return a dict (using a default dict) some thing likes:
available_quantities: dict[int, int] = defaultdict(int)
for group in ...read_group():
product_id = group...
available_quantity = physic - reserved
available_quantities[product_id] = available_quantity
``
8da3ceb
to
9e12e98
Compare
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.
LGTM. just some nitpick regarding naming and code structure
"stock.picking", | ||
compute="_compute_picking_ids", | ||
string="Generated stock pickings", | ||
readonly=True, |
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.
readonly=True, |
By default for a simple compute
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.
# by default, computed fields are not stored, computed in superuser
# mode if stored, not copied (unless stored and explicitly not
# readonly), and readonly (unless inversible)
) | ||
|
||
picking_count = fields.Integer( | ||
string="Picking count", compute="_compute_picking_ids", readonly=True |
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.
string="Picking count", compute="_compute_picking_ids", readonly=True | |
string="Picking count", compute="_compute_picking_ids" |
Same
This PR has the |
1 similar comment
This PR has the |
2221a40
to
7be62d4
Compare
7be62d4
to
71ece6a
Compare
Adds a new model to create a procurement that takes available stock at the targeted location into account when creating pickings.