Skip to content

Commit b086e5e

Browse files
CLaurelBluisg123v
authored andcommitted
[FIX] default_warehouse_from_sale_team: validate cache access when no 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.
1 parent 60d559e commit b086e5e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

default_warehouse_from_sale_team/models/account_move.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ def _search_default_journal(self):
99
journal = super()._search_default_journal()
1010
team = (
1111
self.env.context.get("salesteam")
12-
# If the team_id value (ID) is in the cache, it must be converted to a record from the
13-
# cached value to avoid triggering the field's compute method when it has not yet been computed.
14-
or self._fields["team_id"].convert_to_record(self._cache.get("team_id"), self)
12+
# If the team_id value (ID) is in the cache on a existing account.move record, it must be
13+
# converted to a record from the cached value to avoid triggering the field's compute
14+
# method when it has not yet been computed.
15+
or (self and self._fields["team_id"].convert_to_record(self._cache.get("team_id"), self))
1516
or self.env.user.sale_team_id
1617
)
1718
journal_on_team = team._get_default_journal([journal.type or "general"])

0 commit comments

Comments
 (0)