Skip to content

Commit

Permalink
[FIX] partner_tier_validation: Allow to open view_partner_simple_form
Browse files Browse the repository at this point in the history
Caused by: EvalError: Can not evaluate python expression: (bool(bool(review_ids)))
    Error: Name 'review_ids' is not defined
    EvalError: Can not evaluate python expression: (bool(bool(review_ids)))
    Error: Name 'review_ids' is not defined
  • Loading branch information
rven committed Sep 5, 2024
1 parent 271a8bc commit 14b66ba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions partner_tier_validation/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,8 @@ def write(self, vals):
if "stage_id" in vals and vals.get("stage_id") in self._state_from:
self.restart_validation()

Check warning on line 49 in partner_tier_validation/models/res_partner.py

View check run for this annotation

Codecov / codecov/patch

partner_tier_validation/models/res_partner.py#L49

Added line #L49 was not covered by tests
return res

def _get_tier_validation_readonly_domain(self):
if self.env.context.get("form_view_ref") == "base.view_partner_simple_form":
return ""
return super()._get_tier_validation_readonly_domain()

Check warning on line 55 in partner_tier_validation/models/res_partner.py

View check run for this annotation

Codecov / codecov/patch

partner_tier_validation/models/res_partner.py#L55

Added line #L55 was not covered by tests
9 changes: 7 additions & 2 deletions partner_tier_validation/tests/test_tier_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

from odoo.exceptions import ValidationError
from odoo.tests import common, tagged
from odoo.tests import Form, common, tagged


@tagged("-at_install", "post_install")
Expand Down Expand Up @@ -77,11 +77,16 @@ def test_validation_res_partner(self):
)
self.assertEqual(contact.state, "confirmed")

# Change company type to retrigger validation
# Change company type to trigger validation
contact.write({"company_type": "person"})
self.assertEqual(
contact.state, "draft", "Change company type sets back to draft"
)
with Form(
contact.with_context(form_view_ref="base.view_partner_simple_form"),
view="base.view_partner_simple_form",
) as c:
c.email = "test@company.test"

def test_no_validation_res_partner(self):
"""
Expand Down

0 comments on commit 14b66ba

Please sign in to comment.