From f1b33e914353e835022adf77a79961847c50b59f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Taymans?= Date: Sun, 31 May 2020 11:34:42 +0200 Subject: [PATCH] [FIX] b_shift,b_base: can_shop computation on res_partner --- beesdoo_easy_my_coop/models/res_partner.py | 6 +++-- .../tests/test_res_partner.py | 4 +++ beesdoo_shift/__manifest__.py | 1 + .../demo/workers.xml | 25 ++++++++++++++----- beesdoo_worker_status/__manifest__.py | 1 - 5 files changed, 28 insertions(+), 9 deletions(-) rename {beesdoo_worker_status => beesdoo_shift}/demo/workers.xml (67%) diff --git a/beesdoo_easy_my_coop/models/res_partner.py b/beesdoo_easy_my_coop/models/res_partner.py index b5eaf72..de69114 100644 --- a/beesdoo_easy_my_coop/models/res_partner.py +++ b/beesdoo_easy_my_coop/models/res_partner.py @@ -57,6 +57,8 @@ class Partner(models.Model): @api.depends( "cooperative_status_ids", + "cooperative_status_ids.status", + "cooperative_status_ids.can_shop", "share_ids", "share_ids.share_product_id", "share_ids.share_product_id.default_code", @@ -71,13 +73,13 @@ class Partner(models.Model): if share_type: rec.can_shop = ( rec.cooperative_status_ids.can_shop - if rec.cooperative_status_ids + if rec.is_worker and rec.cooperative_status_ids else share_type.allow_shopping ) else: rec.can_shop = ( rec.cooperative_status_ids.can_shop - if rec.cooperative_status_ids else False + if rec.is_worker and rec.cooperative_status_ids else False ) @api.constrains('parent_eater_id') diff --git a/beesdoo_easy_my_coop/tests/test_res_partner.py b/beesdoo_easy_my_coop/tests/test_res_partner.py index fd42b64..742c487 100644 --- a/beesdoo_easy_my_coop/tests/test_res_partner.py +++ b/beesdoo_easy_my_coop/tests/test_res_partner.py @@ -188,6 +188,10 @@ class TestResPartner(TransactionCase): # Run computed field coop1._compute_can_shop() self.assertEqual(coop1.can_shop, True) + # Now unsubscribe the coop + coop1.cooperative_status_ids.status = 'resigning' + self.assertEqual(coop1.cooperative_status_ids.can_shop, False) + self.assertEqual(coop1.can_shop, False) def test_compute_can_shop_share_c(self): """ diff --git a/beesdoo_shift/__manifest__.py b/beesdoo_shift/__manifest__.py index 368e210..08db04f 100644 --- a/beesdoo_shift/__manifest__.py +++ b/beesdoo_shift/__manifest__.py @@ -40,5 +40,6 @@ ], 'demo': [ "demo/templates.xml", + "demo/workers.xml", ] } diff --git a/beesdoo_worker_status/demo/workers.xml b/beesdoo_shift/demo/workers.xml similarity index 67% rename from beesdoo_worker_status/demo/workers.xml rename to beesdoo_shift/demo/workers.xml index 13edb20..b9880c2 100644 --- a/beesdoo_worker_status/demo/workers.xml +++ b/beesdoo_shift/demo/workers.xml @@ -4,7 +4,8 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> - + + @@ -15,9 +16,11 @@ regular + + - + 2 @@ -27,9 +30,11 @@ irregular + + - + @@ -39,9 +44,11 @@ regular + + - + 2 irregular @@ -50,9 +57,11 @@ irregular + + - + 2 regular @@ -60,9 +69,11 @@ regular + + - + @@ -72,6 +83,8 @@ regular + + diff --git a/beesdoo_worker_status/__manifest__.py b/beesdoo_worker_status/__manifest__.py index d241d9c..abcefa2 100644 --- a/beesdoo_worker_status/__manifest__.py +++ b/beesdoo_worker_status/__manifest__.py @@ -23,7 +23,6 @@ ], 'demo': [ "demo/cooperators.xml", - "demo/workers.xml", "demo/tasks.xml", ] }