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

[15.0][FIX] stock_return_request: Cache miss error when access to qty_returnable computed field on stock move #1843

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

Conversation

sergio-teruel
Copy link
Contributor

@pedrobaeza pedrobaeza added this to the 15.0 milestone Jan 21, 2025
@@ -16,7 +16,10 @@ class StockMove(models.Model):
def _compute_qty_returnable(self):
"""Looks for chained returned moves to compute how much quantity
from the original can be returned"""
for move in self.filtered(lambda x: x.state not in ["draft", "cancel"]):
Copy link
Contributor

Choose a reason for hiding this comment

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

@sergio-teruel
To avoid multiple __set__ calls and n condition evaluations, do this:

self.update({"qty_returnable": 0.0})

@@ -16,7 +16,10 @@ class StockMove(models.Model):
def _compute_qty_returnable(self):
"""Looks for chained returned moves to compute how much quantity
from the original can be returned"""
for move in self.filtered(lambda x: x.state not in ["draft", "cancel"]):
Copy link
Member

Choose a reason for hiding this comment

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

Why not simply setting it to False at the beggining?

@sergio-teruel sergio-teruel force-pushed the 15.0-FIX-stock_return_request-cache-miss-stock_move branch from 1a7ecbc to fb5c128 Compare January 22, 2025 15:04
@sergio-teruel
Copy link
Contributor Author

changes done!

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.

5 participants