|
|
@ -17,26 +17,35 @@ class PartnerUpdateInfo(models.TransientModel): |
|
|
|
partner = self._get_partner() |
|
|
|
if partner.is_company: |
|
|
|
return partner.company_register_number |
|
|
|
else: |
|
|
|
return partner.national_register_number |
|
|
|
|
|
|
|
register_number = fields.Char(string="Register Number", |
|
|
|
required=True, |
|
|
|
default=_get_register_number) |
|
|
|
cooperator = fields.Many2one('res.partner', |
|
|
|
string="Cooperator", |
|
|
|
default=_get_partner) |
|
|
|
all = fields.Boolean(string="Update from subscription request") |
|
|
|
birthdate = fields.Boolean(string="set missing birth date") |
|
|
|
|
|
|
|
@api.multi |
|
|
|
def update(self): |
|
|
|
|
|
|
|
partner_obj = self.env['res.partner'] |
|
|
|
cooperator = self.cooperator |
|
|
|
coop_vals = {} |
|
|
|
|
|
|
|
if cooperator.is_company: |
|
|
|
coop_vals['company_register_number'] = self.register_number |
|
|
|
|
|
|
|
if coop_vals: |
|
|
|
cooperator.write(coop_vals) |
|
|
|
if self.all: |
|
|
|
if self.birthdate: |
|
|
|
coops = partner_obj.search([('cooperator', '=', True), |
|
|
|
('birthdate_date', '=', False), |
|
|
|
('is_company', '=', False)]) |
|
|
|
for coop in coops: |
|
|
|
if coop.subscription_request_ids: |
|
|
|
sub_req = coop.subscription_request_ids[0] |
|
|
|
coop.birthdate_date = sub_req.birthdate |
|
|
|
else: |
|
|
|
if cooperator: |
|
|
|
if cooperator.is_company: |
|
|
|
coop_vals['company_register_number'] = self.register_number |
|
|
|
if coop_vals: |
|
|
|
cooperator.write(coop_vals) |
|
|
|
|
|
|
|
return True |