Skip to content

Commit

Permalink
Merge PR #140 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Sep 25, 2023
2 parents 8c336d9 + 43e3606 commit 962f32b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 25 deletions.
13 changes: 0 additions & 13 deletions membership_extension/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,6 @@ class ResPartner(models.Model):
compute="_compute_membership_state",
recursive=True,
)
membership_categories = fields.Char(
string="Membership Categories Labels",
readonly=True,
store=True,
index=True,
compute="_compute_membership_state",
)
membership_state = fields.Selection(
selection=STATE,
store=True,
Expand Down Expand Up @@ -198,13 +191,9 @@ def _compute_membership_state(self):
partner.membership_category_ids = [
(6, False, partner.associate_member.membership_category_ids.ids)
]
partner.membership_categories = (
partner.associate_member.membership_categories
)
elif partner.free_member:
partner.membership_state = "free"
partner.membership_category_ids = [(5, False, False)]
partner.membership_categories = False
else:
state = "none"
category_ids = []
Expand Down Expand Up @@ -234,10 +223,8 @@ def _compute_membership_state(self):
category_ids = list(set(category_ids))
category_names = list(set(category_names))
partner.membership_category_ids = [(6, False, category_ids)]
partner.membership_categories = ", ".join(category_names)
else:
partner.membership_category_ids = [(5, False, False)]
partner.membership_categories = False

@api.model
def check_membership_expiry(self):
Expand Down
10 changes: 0 additions & 10 deletions membership_extension/tests/test_membership.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,7 @@ def test_category(self):
}
)
self.assertEqual(self.category_gold, self.partner.membership_category_ids)
self.assertEqual("Gold", self.partner.membership_categories)
self.assertEqual(self.category_gold, self.child.membership_category_ids)
self.assertEqual("Gold", self.child.membership_categories)
line_two = self.env["membership.membership_line"].create(
{
"membership_id": self.silver_product.id,
Expand All @@ -217,24 +215,16 @@ def test_category(self):
self.category_gold + self.category_silver,
self.partner.membership_category_ids,
)
self.assertTrue("Silver" in self.partner.membership_categories)
self.assertTrue("Gold" in self.partner.membership_categories)
self.assertEqual(
self.category_gold + self.category_silver,
self.child.membership_category_ids,
)
self.assertTrue("Silver" in self.child.membership_categories)
self.assertTrue("Gold" in self.child.membership_categories)
line_one.write({"state": "canceled"})
self.assertEqual(self.category_silver, self.partner.membership_category_ids)
self.assertEqual("Silver", self.partner.membership_categories)
self.assertEqual(self.category_silver, self.child.membership_category_ids)
self.assertEqual("Silver", self.child.membership_categories)
line_two.write({"state": "waiting"})
self.assertFalse(self.partner.membership_category_ids.ids)
self.assertFalse(self.partner.membership_categories)
self.assertFalse(self.child.membership_category_ids.ids)
self.assertFalse(self.child.membership_categories)

def test_remove_membership_line_with_invoice(self):
invoice_form = common.Form(
Expand Down
4 changes: 2 additions & 2 deletions membership_extension/views/res_partner_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@
/>
<filter
string="Membership Category"
name="membership_categories"
name="membership_category_ids"
domain="[('membership_state', 'in', ['invoiced', 'paid'])]"
context="{'group_by':'membership_categories'}"
context="{'group_by':'membership_category_ids'}"
/>
</xpath>
</field>
Expand Down

0 comments on commit 962f32b

Please sign in to comment.