Skip to content
Snippets Groups Projects
Commit a379347f authored by Marco Folco's avatar Marco Folco
Browse files

[MOD] health_insurance

Improved create function to not generate KeyError anymore
parent 22a0f221
1 merge request!31[MOD] health_insurance
......@@ -52,13 +52,11 @@ class Partner(models.Model):
@api.model
def create(self, vals):
if 'partner_type' in vals:
if vals['partner_type'] == 'insurance':
vals['ref'] = str(self.env['ir.sequence'].next_by_code('res.partner.insurance'))
if 'default_partner_type' in self.env.context and not vals['ref']:
if self.env.context['default_partner_type'] == 'insurance':
vals['ref'] = str(self.env['ir.sequence'].next_by_code('res.partner.insurance'))
return super(Partner, self).create(vals)
res = super(Partner, self).create(vals)
if not res.ref:
if res.partner_type == 'insurance':
res.ref = str(self.env['ir.sequence'].next_by_code('res.partner.insurance'))
return res
@api.multi
def name_get(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment