From 5934284cff94abb0f92b81dcb1d4cc84aa364959 Mon Sep 17 00:00:00 2001 From: Houssine BAKKALI Date: Mon, 5 Aug 2019 18:59:00 +0200 Subject: [PATCH] Update update_partner_info.py --- easy_my_coop/wizard/update_partner_info.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/easy_my_coop/wizard/update_partner_info.py b/easy_my_coop/wizard/update_partner_info.py index 3c0fcee..ea23fe8 100644 --- a/easy_my_coop/wizard/update_partner_info.py +++ b/easy_my_coop/wizard/update_partner_info.py @@ -25,6 +25,8 @@ class PartnerUpdateInfo(models.TransientModel): default=_get_partner) all = fields.Boolean(string="Update from subscription request") 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): @@ -33,14 +35,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: