Browse Source

Merge pull request #13 from coopiteasy/9.0_add_option_to_wizard

9.0 add option to wizard
pull/17/head
Houssine BAKKALI 5 years ago
committed by GitHub
parent
commit
693dc20246
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      easy_my_coop/wizard/update_partner_info.py
  2. 2
      easy_my_coop/wizard/update_partner_info.xml

22
easy_my_coop/wizard/update_partner_info.py

@ -25,6 +25,8 @@ class PartnerUpdateInfo(models.TransientModel):
default=_get_partner) default=_get_partner)
all = fields.Boolean(string="Update from subscription request") 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 @api.multi
def update(self): def update(self):
@ -33,14 +35,30 @@ class PartnerUpdateInfo(models.TransientModel):
coop_vals = {} coop_vals = {}
if self.all: 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), coops = partner_obj.search([('cooperator', '=', True),
('birthdate_date', '=', False), ('birthdate_date', '=', False),
('is_company', '=', False)]) ('is_company', '=', False)])
for coop in coops: for coop in coops:
coop_vals = {}
if coop.subscription_request_ids: if coop.subscription_request_ids:
sub_req = coop.subscription_request_ids[0] 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: else:
if cooperator: if cooperator:
if cooperator.is_company: if cooperator.is_company:

2
easy_my_coop/wizard/update_partner_info.xml

@ -12,6 +12,8 @@
<group> <group>
<field name="all"/> <field name="all"/>
<field name="birthdate"/> <field name="birthdate"/>
<field name="legal_form"/>
<field name="representative_function"/>
<field name="cooperator" readonly="True"/> <field name="cooperator" readonly="True"/>
<field name="register_number" attrs="{'required':[('all', '=', False)]}"/> <field name="register_number" attrs="{'required':[('all', '=', False)]}"/>
</group> </group>

Loading…
Cancel
Save