Skip to content

Commit

Permalink
[IMP] account_move_tier_validation_approver: replace problematic onch…
Browse files Browse the repository at this point in the history
…ange with depends readonly=False
  • Loading branch information
kevinkhao committed Jan 22, 2025
1 parent eb67009 commit 5a74d8d
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions account_move_tier_validation_approver/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,23 @@
class AccountMove(models.Model):
_inherit = "account.move"

approver_id = fields.Many2one("res.users", string="Responsible for Approval")
approver_id = fields.Many2one(
"res.users",
string="Responsible for Approval",
compute="_compute_approver_id",
readonly=False,
)

@api.onchange("partner_id")
def _onchange_partner_approver_id(self):
if self.partner_id:
self.approver_id = self.partner_id.approver_id.id
@api.depends("partner_id")
def _compute_approver_id(self):
for rec in self:
if rec.approver_id:
# assign a value in any case
rec.approver_id = rec.approver_id

Check warning on line 23 in account_move_tier_validation_approver/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

account_move_tier_validation_approver/models/account_move.py#L23

Added line #L23 was not covered by tests
elif rec.partner_id.approver_id:
rec.approver_id = rec.partner_id.approver_id

Check warning on line 25 in account_move_tier_validation_approver/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

account_move_tier_validation_approver/models/account_move.py#L25

Added line #L25 was not covered by tests
else:
rec.approver_id = False

Check warning on line 27 in account_move_tier_validation_approver/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

account_move_tier_validation_approver/models/account_move.py#L27

Added line #L27 was not covered by tests

def _post(self, soft=True):
for move in self:
Expand Down

0 comments on commit 5a74d8d

Please sign in to comment.