-
Notifications
You must be signed in to change notification settings - Fork 289
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
[FIX] default_warehouse_from_sale_team: prevent Sales Team compute on default journal set i#28375 #1686
[FIX] default_warehouse_from_sale_team: prevent Sales Team compute on default journal set i#28375 #1686
Conversation
Hello @hugho-ad, Could you review, please? Regards. cc. @desdelinux |
team = self.env.context.get("salesteam") or self.team_id or self.env.user.sale_team_id | ||
team = ( | ||
self.env.context.get("salesteam") | ||
or (self._cache["team_id"] and self.team_id) |
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.
If already checking the cache, why do you need to read the current value?
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.
Because the cached value contains only the ID and not the record.
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.
Updated to use the convert_to_record
method as suggested.
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.
Thanks a lot! I like the new approach.
Just only one more request:
Since that's not a trivial code, could you add a small comment above the new line (the one with _fields
) explaining why?
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.
Comment added.
b0fbe23
to
9546b5a
Compare
… default journal set Use the cached value of the Sales Team field to access its value as a record. This avoids computing its value when it has not been computed yet, which could result in setting the wrong Sales Team on an invoice form creation. This issue occurs because the company is not yet set, and its value is required to determine the correct Sales Team [1]. [1]: https://github.com/odoo/odoo/blob/3884a60e/addons/sale/models/account_move.py#L41
9546b5a
to
71da6d8
Compare
Use the cached value of the Sales Team field to access its value as a record. This avoids computing its value when it has not been computed yet, which could result in setting the wrong Sales Team on an invoice form creation. This issue occurs because the company is not yet set, and its value is required to determine the correct Sales Team 1.