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

[FIX] default_warehouse_from_sale_team: prevent Sales Team compute on default journal set i#28375 #1686

Merged
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
8 changes: 7 additions & 1 deletion default_warehouse_from_sale_team/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ class AccountMove(models.Model):
def _search_default_journal(self):
"""If a team is provided and it has a sales journal set, take it as 1st alternative"""
journal = super()._search_default_journal()
team = self.env.context.get("salesteam") or self.team_id or self.env.user.sale_team_id
team = (
self.env.context.get("salesteam")
# If the team_id value (ID) is in the cache, it must be converted to a record from the
# cached value to avoid triggering the field's compute method when it has not yet been computed.
or self._fields["team_id"].convert_to_record(self._cache.get("team_id"), self)
or self.env.user.sale_team_id
)
journal_on_team = team._get_default_journal([journal.type or "general"])
return journal_on_team or journal

Expand Down
Loading