Skip to content

Commit

Permalink
[FIX] academic: Fix issue when import partner_type for a bunch of rec…
Browse files Browse the repository at this point in the history
…ords.

The mecanism of the constrain with a onchange is no correct for several resons, one of them
is affected in the import process with this fields set for a candidates records to create in parters.
The way to separate the part for backend in overide the write funcion solve this problem.

X-original-commit: 233a87d
  • Loading branch information
nicomacr committed Apr 1, 2022
1 parent 1282b73 commit 52d7785
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions academic/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,16 @@ def _compute_related_user_id(self):
for rec in self:
rec.related_user_id = rec.user_ids and rec.user_ids[0]

@api.constrains('is_company')
@api.onchange('is_company')
def _check_partner_type(self):
recs = self.filtered(lambda x: x.is_company and x.partner_type)
recs.update({'partner_type': False})
for record in self.filtered(lambda x: x.is_company and x.partner_type):
record.partner_type = False


def write(self, vals):
if 'is_company' in vals and vals.get('is_company'):
vals['partner_type'] = False
return super(ResPartner, self).write(vals)

def quickly_create_portal_user(self):
""" Metodo que crea o activa usuario inactivo en el grupo portal que
Expand Down

0 comments on commit 52d7785

Please sign in to comment.