Browse Source

[FIX] b_shift,b_base: can_shop computation on res_partner

pull/134/head
Rémy Taymans 4 years ago
parent
commit
f1b33e9143
  1. 6
      beesdoo_easy_my_coop/models/res_partner.py
  2. 4
      beesdoo_easy_my_coop/tests/test_res_partner.py
  3. 1
      beesdoo_shift/__manifest__.py
  4. 25
      beesdoo_shift/demo/workers.xml
  5. 1
      beesdoo_worker_status/__manifest__.py

6
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')

4
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):
"""

1
beesdoo_shift/__manifest__.py

@ -40,5 +40,6 @@
],
'demo': [
"demo/templates.xml",
"demo/workers.xml",
]
}

25
beesdoo_worker_status/demo/workers.xml → beesdoo_shift/demo/workers.xml

@ -4,7 +4,8 @@
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="beesdoo_shift_cooperative_status_1_demo" model="cooperative.status">
<record id="cooperative_status_1_demo" model="cooperative.status">
<field name="cooperator_id" ref="beesdoo_base.res_partner_cooperator_1_demo" />
<field name="info_session" eval="True" />
<field name="info_session_date" eval="datetime.now() - timedelta(days=58)" />
@ -15,9 +16,11 @@
<record id="beesdoo_base.res_partner_cooperator_1_demo" model="res.partner">
<field name="working_mode">regular</field>
<field name="is_worker" eval="True"/>
<field name="cooperative_status_ids" eval="[(6, 0, [ref('beesdoo_shift.cooperative_status_1_demo')])]"/>
</record>
<record id="beesdoo_shift_cooperative_status_2_demo" model="cooperative.status">
<record id="cooperative_status_2_demo" model="cooperative.status">
<field name="cooperator_id" ref="beesdoo_base.res_partner_cooperator_2_demo" />
<field name="info_session" eval="False" />
<field name="sr">2</field>
@ -27,9 +30,11 @@
<record id="beesdoo_base.res_partner_cooperator_2_demo" model="res.partner">
<field name="working_mode">irregular</field>
<field name="is_worker" eval="True"/>
<field name="cooperative_status_ids" eval="[(6, 0, [ref('beesdoo_shift.cooperative_status_2_demo')])]"/>
</record>
<record id="beesdoo_shift_cooperative_status_3_demo" model="cooperative.status">
<record id="cooperative_status_3_demo" model="cooperative.status">
<field name="cooperator_id" ref="beesdoo_base.res_partner_cooperator_3_demo" />
<field name="info_session" eval="True" />
<field name="info_session_date" eval="datetime.now() - timedelta(days=98)" />
@ -39,9 +44,11 @@
<record id="beesdoo_base.res_partner_cooperator_3_demo" model="res.partner">
<field name="working_mode">regular</field>
<field name="is_worker" eval="True"/>
<field name="cooperative_status_ids" eval="[(6, 0, [ref('beesdoo_shift.cooperative_status_3_demo')])]"/>
</record>
<record id="beesdoo_shift_cooperative_status_4_demo" model="cooperative.status">
<record id="cooperative_status_4_demo" model="cooperative.status">
<field name="cooperator_id" ref="beesdoo_base.res_partner_cooperator_4_demo" />
<field name="sr">2</field>
<field name="working_mode">irregular</field>
@ -50,9 +57,11 @@
<record id="beesdoo_base.res_partner_cooperator_4_demo" model="res.partner">
<field name="working_mode">irregular</field>
<field name="is_worker" eval="True"/>
<field name="cooperative_status_ids" eval="[(6, 0, [ref('beesdoo_shift.cooperative_status_4_demo')])]"/>
</record>
<record id="beesdoo_shift_cooperative_status_5_demo" model="cooperative.status">
<record id="cooperative_status_5_demo" model="cooperative.status">
<field name="cooperator_id" ref="beesdoo_base.res_partner_cooperator_5_demo" />
<field name="sr">2</field>
<field name="working_mode">regular</field>
@ -60,9 +69,11 @@
<record id="beesdoo_base.res_partner_cooperator_5_demo" model="res.partner">
<field name="working_mode">regular</field>
<field name="is_worker" eval="True"/>
<field name="cooperative_status_ids" eval="[(6, 0, [ref('beesdoo_shift.cooperative_status_5_demo')])]"/>
</record>
<record id="beesdoo_shift_cooperative_status_6_demo" model="cooperative.status">
<record id="cooperative_status_6_demo" model="cooperative.status">
<field name="cooperator_id" ref="beesdoo_base.res_partner_cooperator_6_demo" />
<field name="info_session" eval="True" />
<field name="info_session_date" eval="datetime.now() - timedelta(days=36)" />
@ -72,6 +83,8 @@
<record id="beesdoo_base.res_partner_cooperator_6_demo" model="res.partner">
<field name="working_mode">regular</field>
<field name="is_worker" eval="True"/>
<field name="cooperative_status_ids" eval="[(6, 0, [ref('beesdoo_shift.cooperative_status_6_demo')])]"/>
</record>
</odoo>

1
beesdoo_worker_status/__manifest__.py

@ -23,7 +23,6 @@
],
'demo': [
"demo/cooperators.xml",
"demo/workers.xml",
"demo/tasks.xml",
]
}
Loading…
Cancel
Save