From 4cc982414d72bbe324395401680af51f8dc3b2f1 Mon Sep 17 00:00:00 2001 From: houssine Date: Mon, 5 Aug 2019 18:56:08 +0200 Subject: [PATCH] [IMP] Add UPD of legal form and contact person function from sub request --- easy_my_coop/wizard/update_partner_info.py | 26 +++++++++++++++++---- easy_my_coop/wizard/update_partner_info.xml | 2 ++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/easy_my_coop/wizard/update_partner_info.py b/easy_my_coop/wizard/update_partner_info.py index bb7c50b..ae1e653 100644 --- a/easy_my_coop/wizard/update_partner_info.py +++ b/easy_my_coop/wizard/update_partner_info.py @@ -23,7 +23,9 @@ class PartnerUpdateInfo(models.TransientModel): string="Cooperator", default=_get_partner) all = fields.Boolean(string="Update from subscription request") - birthdate = fields.Boolean(string="set missing birth date") + birthdate = fields.Boolean(string="Set missing birth date") + legal_form = fields.Boolean(string="Set legal form") + representative_function = fields.Boolean(string="Set function") @api.multi def update(self): @@ -32,14 +34,30 @@ class PartnerUpdateInfo(models.TransientModel): coop_vals = {} if self.all: - if self.birthdate: + if self.legal_form or self.representative_function: + coops = partner_obj.search([('cooperator', '=', True), + ('is_company', '=', True)]) + for coop in coops: + coop_vals = {} + if coop.subscription_request_ids: + sub_req = coop.subscription_request_ids[0] + if self.legal_form: + coop_vals['legal_form'] = sub_req.company_type + coop.write(coop_vals) + if self.representative_function: + contact = coop.get_representative() + contact.function = sub_req.contact_person_function + else: coops = partner_obj.search([('cooperator', '=', True), ('birthdate_date', '=', False), ('is_company', '=', False)]) for coop in coops: + coop_vals = {} if coop.subscription_request_ids: sub_req = coop.subscription_request_ids[0] - coop.birthdate_date = sub_req.birthdate + if self.birthdate: + coop_vals['birthdate_date'] = sub_req.birthdate + coop.write(coop_vals) else: if cooperator: if cooperator.is_company: @@ -47,4 +65,4 @@ class PartnerUpdateInfo(models.TransientModel): if coop_vals: cooperator.write(coop_vals) - return True \ No newline at end of file + return True diff --git a/easy_my_coop/wizard/update_partner_info.xml b/easy_my_coop/wizard/update_partner_info.xml index f6fabf7..ee78a5d 100644 --- a/easy_my_coop/wizard/update_partner_info.xml +++ b/easy_my_coop/wizard/update_partner_info.xml @@ -12,6 +12,8 @@ + +