Skip to content

Commit

Permalink
[FIX] default_warehouse_from_sale_team: validate cache access when no…
Browse files Browse the repository at this point in the history
… record exists

Add a validation to avoid errors when accessing the cache without a
record. The change ensures that the `team_id` value is only retrieved
from the cache when a valid `account.move` record exists.
  • Loading branch information
CLaurelB authored and luisg123v committed Jan 9, 2025
1 parent 171f072 commit 1b236e8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions default_warehouse_from_sale_team/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ def _search_default_journal(self):
journal = super()._search_default_journal()
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)
# If the team_id value (ID) is in the cache on a existing account.move record, 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 and 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"])
Expand Down

0 comments on commit 1b236e8

Please sign in to comment.