|
@ -23,7 +23,9 @@ class PartnerUpdateInfo(models.TransientModel): |
|
|
string="Cooperator", |
|
|
string="Cooperator", |
|
|
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): |
|
@ -32,14 +34,32 @@ 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 = {} |
|
|
|
|
|
sub_reqs = coop.subscription_request_ids.filtered(lambda r: r.state in ['done', 'paid']) |
|
|
|
|
|
if sub_reqs: |
|
|
|
|
|
sub_req = sub_reqs[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: |
|
|
if coop.subscription_request_ids: |
|
|
|
|
|
sub_req = coop.subscription_request_ids[0] |
|
|
|
|
|
coop.birthdate_date = sub_req.birthdate |
|
|
|
|
|
|
|
|
coop_vals = {} |
|
|
|
|
|
sub_reqs = coop.subscription_request_ids.filtered(lambda r: r.state in ['done', 'paid']) |
|
|
|
|
|
if sub_reqs: |
|
|
|
|
|
sub_req = sub_reqs[0] |
|
|
|
|
|
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: |
|
|