Skip to content

Commit

Permalink
[FIX] default_warehouse_from_sale_team: prevent Sales Team compute on…
Browse files Browse the repository at this point in the history
… default journal set

Use the cached value of the Sales Team field as a condition to access
the value of the field. This avoids computing the value of the field
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
  • Loading branch information
CLaurelB committed Dec 30, 2024
1 parent 23c94e6 commit b0fbe23
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 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,11 @@ 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")
or (self._cache["team_id"] and self.team_id)
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

0 comments on commit b0fbe23

Please sign in to comment.