Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions stock_storage_type/models/stock_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ def _compute_has_potential_lot_mix_exception(self):
for location in self:
if (
location.fill_state not in ("empty", "being_emptied")
and location._should_compute_will_contain_lot_ids()
and len(location.location_will_contain_lot_ids) > 1
):
locations_with_exception |= location
Expand All @@ -187,7 +186,6 @@ def _compute_has_potential_product_mix_exception(self):
for location in self:
if (
location.fill_state not in ("empty", "being_emptied")
and location._should_compute_will_contain_product_ids()
and len(location.location_will_contain_product_ids) > 1
):
locations_with_exception |= location
Expand Down Expand Up @@ -312,7 +310,14 @@ def _should_compute_will_contain_lot_ids(self):
"do_not_mix_products",
)
def _compute_location_will_contain_product_ids(self):
for rec in self:
# We should not retrieve fields values for records that should not be computed
# as when the field is accessed the first time for a record that should be
# computed (in 'else'), field value for records of 'self' will be retrieved.
# Like 'quant_ids' for locations like 'Customers'
prefetch_ids = [
rec.id for rec in self if rec._should_compute_will_contain_product_ids()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not call it twice

]
for rec in self.with_prefetch(prefetch_ids):
if not rec._should_compute_will_contain_product_ids():
no_product = self.env["product.product"].browse()
rec.location_will_contain_product_ids = no_product
Expand Down
Loading