Browse Source

[FIX] subscription request validate button visibility + test

pull/49/head
robin.keunen 5 years ago
committed by Rémy Taymans
parent
commit
5bbda6d7d1
  1. 22
      easy_my_coop/models/coop.py
  2. 25
      easy_my_coop/tests/test_emc.py
  3. 4
      easy_my_coop/views/subscription_request_view.xml

22
easy_my_coop/models/coop.py

@ -107,21 +107,23 @@ class SubscriptionRequest(models.Model):
return True
def check_iban(self, iban):
validated = True
if iban:
try:
try:
if iban:
validate_iban(iban)
except ValidationError:
validated = False
return validated
return True
else:
return False
except ValidationError:
return False
@api.multi
@api.depends('iban', 'skip_control_ng', 'is_company')
@api.depends('iban', 'skip_control_ng')
def _validated_lines(self):
for sub_request in self:
validated = (self.check_iban(sub_request.iban)
or sub_request.skip_control_ng
)
validated = (
sub_request.skip_control_ng
or self.check_iban(sub_request.iban)
)
sub_request.validated = validated
@api.multi

25
easy_my_coop/tests/test_emc.py

@ -173,3 +173,28 @@ class EMCCase(EMCBaseCase):
)
share_type.list_price = 30
share_type.unlink()
def test_validated_lines_on_subscription_request(self):
request = self.request
self.assertFalse(request.skip_control_ng)
self.assertFalse(request.iban)
# empty iban - don't skip
self.assertFalse(request.validated)
# good iban - don't skip
request.skip_control_ng = False
self.request.iban = "BE71096123456769"
self.assertTrue(request.validated)
# wrong iban - don't skip
self.request.iban = "xxxx"
self.assertFalse(request.validated)
# wrong iban - skip
request.skip_control_ng = True
self.assertTrue(request.validated)
# empty iban - skip
self.request.iban = False
self.assertTrue(request.validated)

4
easy_my_coop/views/subscription_request_view.xml

@ -19,7 +19,7 @@
<field name="source"/>
<field name="state"/>
<field name="validated" invisible="True"/>
<button type="object" string="Validate" aria-label="Validate" name="validate_subscription_request" attrs="{'invisible':['|',('state','!=','draft'),('validated','=',False)]}"/>
<button type="object" string="Validate" aria-label="Validate" name="validate_subscription_request" attrs="{'invisible':['|',('state','not in',['draft','waiting']),('validated','=',False)]}"/>
<button type="object" string="Block" aria-label="Block" name="block_subscription_request" states="draft" groups="easy_my_coop.group_easy_my_coop_user"/>
<button type="object" string="Unblock" aria-label="Unblock" name="unblock_subscription_request" states="block" groups="easy_my_coop.group_easy_my_coop_user"/>
</tree>
@ -40,6 +40,7 @@
<sheet>
<group>
<group>
<field name="validated" invisible="True"/>
<field name="already_cooperator"/>
<field name="is_company" groups="easy_my_coop.group_easy_my_coop_manager"/>
<field name="is_operation" invisible="True"/>
@ -73,7 +74,6 @@
<field name="partner_id" options="{'no_create':True}"/>
<field name="type"/>
<field name="lang"/>
<field name="validated" invisible="True"/>
<field name="skip_control_ng"/>
</group>
</group>

Loading…
Cancel
Save