From 43e36068be376943d30bb74e544bb40debf658a5 Mon Sep 17 00:00:00 2001 From: Pierrick Brun Date: Mon, 6 Mar 2023 13:08:06 +0100 Subject: [PATCH] [FIX] replace categories field by category_ids --- membership_extension/models/res_partner.py | 13 ------------- membership_extension/tests/test_membership.py | 10 ---------- membership_extension/views/res_partner_view.xml | 4 ++-- 3 files changed, 2 insertions(+), 25 deletions(-) diff --git a/membership_extension/models/res_partner.py b/membership_extension/models/res_partner.py index 4c7bef49..ffaace92 100644 --- a/membership_extension/models/res_partner.py +++ b/membership_extension/models/res_partner.py @@ -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, @@ -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 = [] @@ -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): diff --git a/membership_extension/tests/test_membership.py b/membership_extension/tests/test_membership.py index 02578ca6..00be201c 100644 --- a/membership_extension/tests/test_membership.py +++ b/membership_extension/tests/test_membership.py @@ -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, @@ -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( diff --git a/membership_extension/views/res_partner_view.xml b/membership_extension/views/res_partner_view.xml index fb287938..d68d83ba 100644 --- a/membership_extension/views/res_partner_view.xml +++ b/membership_extension/views/res_partner_view.xml @@ -111,9 +111,9 @@ />