Skip to content
Snippets Groups Projects
Commit 1a163efd authored by Daniil Digtyar Vasilieva's avatar Daniil Digtyar Vasilieva :call_me: Committed by Enrico Stano
Browse files

[IMP] energy_selfconsumption: owner creation

parent 41fc9c10
No related branches found
No related tags found
2 merge requests!187Release 14.0.1.1.13,!155[IMP] energy_selfconsumption: importation of selfconsumption inscriptions, supply points and distribution tables by CSV
......@@ -114,6 +114,16 @@ class SelfconsumptionImportWizard(models.TransientModel):
owner = self.env['res.partner'].search([
'|', ('vat', '=', line_dict['owner_vat']), ('vat', '=ilike', line_dict['owner_vat'])
], limit=1)
if not owner:
try:
res = self.env['res.partner'].create({
'vat': line_dict['owner_vat'],
'firstname': line_dict['owner_fistname'],
'lastname': line_dict['owner_lastname'],
'company_type': 'person'
})
except Exception as e:
return False, _('Owner could not be created: {error}').format(error=e)
country = self.env['res.country'].search([('code', '=', line_dict['country'])])
if not country:
return False, _('Country code was not found: {code}').format(line_dict['country'])
......
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