Browse Source

[IMP] add control on iban and niss number in the subscription form

pull/1/head
houssine 6 years ago
parent
commit
c8bf966b13
  1. 56
      easy_my_coop/controllers/main.py

56
easy_my_coop/controllers/main.py

@ -262,24 +262,6 @@ class WebsiteSubscription(http.Controller):
values = dict(values, error=error, kwargs=kwargs.items())
return request.website.render(kwargs.get("view_from", redirect), values)
if kwargs.get("already_cooperator") == 'on':
values["already_cooperator"] = True
lastname = kwargs.get("lastname").upper()
firstname = kwargs.get("firstname").title()
values["name"] = firstname + " " + lastname
values["lastname"] = lastname
values["firstname"] = firstname
values["birthdate"] = datetime.strptime(kwargs.get("birthdate"),
"%d/%m/%Y").date()
values["source"] = "website"
if kwargs.get("share_product_id"):
product_id = kwargs.get("share_product_id")
product = request.env['product.template'].sudo().browse(int(product_id)).product_variant_ids[0]
values["share_product_id"] = product.id
# check the subscription's amount
max_amount = company.subscription_maximum_amount
total_amount = float(kwargs.get('total_parts'))
@ -297,9 +279,43 @@ class WebsiteSubscription(http.Controller):
subscription_id = sub_req_obj.sudo().create_comp_sub_req(values)
else:
if kwargs.get("no_registre"):
values["no_registre"] = re.sub('[^0-9a-zA-Z]+',
'',
no_registre = re.sub('[^0-9a-zA-Z]+', '',
kwargs.get("no_registre"))
valid = sub_req_obj.check_belgian_identification_id(no_registre)
if not valid:
values = self.fill_values(values, is_company)
values["error_msg"] = _("You national register number "
"is not valid")
return request.website.render("easy_my_coop.becomecooperator", values)
values["no_registre"] = no_registre
iban = kwargs.get("iban")
valid = sub_req_obj.check_iban(iban)
if not valid:
values = self.fill_values(values, is_company)
values["error_msg"] = _("You iban account number"
"is not valid")
return request.website.render("easy_my_coop.becomecooperator", values)
if kwargs.get("already_cooperator") == 'on':
values["already_cooperator"] = True
lastname = kwargs.get("lastname").upper()
firstname = kwargs.get("firstname").title()
values["name"] = firstname + " " + lastname
values["lastname"] = lastname
values["firstname"] = firstname
values["birthdate"] = datetime.strptime(kwargs.get("birthdate"),
"%d/%m/%Y").date()
values["source"] = "website"
if kwargs.get("share_product_id"):
product_id = kwargs.get("share_product_id")
product = request.env['product.template'].sudo().browse(int(product_id)).product_variant_ids[0]
values["share_product_id"] = product.id
subscription_id = sub_req_obj.sudo().create(values)
values.update(subscription_id=subscription_id)

Loading…
Cancel
Save