From e7cbc319329e384d532725e5a4b50e8cf3f56acb Mon Sep 17 00:00:00 2001 From: houssine Date: Fri, 3 May 2019 11:03:35 +0200 Subject: [PATCH] [FIX] check no_registre only if it's required for the localisation --- easy_my_coop/controllers/main.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/easy_my_coop/controllers/main.py b/easy_my_coop/controllers/main.py index c58c71a..df70ec3 100644 --- a/easy_my_coop/controllers/main.py +++ b/easy_my_coop/controllers/main.py @@ -248,7 +248,7 @@ class WebsiteSubscription(http.Controller): "is not valid") return request.website.render(redirect, values) - if not is_company: + if not is_company and 'no_registre' in required_fields: no_registre = re.sub('[^0-9a-zA-Z]+', '', kwargs.get("no_registre")) valid = sub_req_obj.check_belgian_identification_id(no_registre) @@ -304,6 +304,8 @@ class WebsiteSubscription(http.Controller): def share_subscription(self, **kwargs): sub_req_obj = request.env['subscription.request'] attach_obj = request.env['ir.attachment'] + required_fields = sub_req_obj.sudo().get_required_field() + # List of file to add to ir_attachment once we have the ID post_file = [] # Info to add after the message @@ -357,9 +359,10 @@ class WebsiteSubscription(http.Controller): kwargs.get("company_register_number")) subscription_id = sub_req_obj.sudo().create_comp_sub_req(values) else: - no_registre = re.sub('[^0-9a-zA-Z]+', '', - kwargs.get("no_registre")) - values["no_registre"] = no_registre + if 'no_registre' in required_fields: + no_registre = re.sub('[^0-9a-zA-Z]+', '', + kwargs.get("no_registre")) + values["no_registre"] = no_registre subscription_id = sub_req_obj.sudo().create(values)