Skip to content

Commit 0b411a4

Browse files
committed
[FIX] account_operating_unit: use sudo() to read journal in OU onchange
Users without journal read permission get AccessError when the _onchange_operating_unit triggers. Use sudo() to safely read journal.operating_unit_id and journal.type. Port of BITVAX fix from 16.0-fix-journal-access-denied branch.
1 parent 8a6ec74 commit 0b411a4

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

account_operating_unit/models/account_move.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ def _default_operating_unit_id(self):
130130
def _onchange_operating_unit(self):
131131
if self.operating_unit_id and (
132132
not self.journal_id
133-
or self.journal_id.operating_unit_id != self.operating_unit_id
133+
or self.journal_id.sudo().operating_unit_id != self.operating_unit_id
134134
):
135135
journal = self.env["account.journal"].search(
136-
[("type", "=", self.journal_id.type)]
136+
[("type", "=", self.journal_id.sudo().type)]
137137
)
138138
jf = journal.filtered(
139139
lambda aj: aj.operating_unit_id == self.operating_unit_id

0 commit comments

Comments
 (0)