Browse Source

[FIX] Bug Fixed

pull/116/head
Ajmalcybrosys 6 years ago
parent
commit
057f346a1b
  1. 35
      first_last_name/models/name.py

35
first_last_name/models/name.py

@ -11,39 +11,30 @@ class FirstNameLastName(models.Model):
@api.onchange('last_name', 'first_name') @api.onchange('last_name', 'first_name')
def _onchange_first_last_name(self): def _onchange_first_last_name(self):
print(self) for i in self:
print("_onchange_first_last_name") if i.first_name and i.last_name:
print(self.name) i.name = (i.first_name + ' ' + i.last_name)
print(self.first_name)
print(self.last_name)
if self.first_name and self.last_name:
self.name = (self.first_name + ' ' + self.last_name)
@api.onchange('name') @api.onchange('name')
def _onchange_name(self): def _onchange_name(self):
print(self) for i in self:
print("_onchange_name") if i.name and i.company_type == 'person':
if self.name and self.company_type == 'person': name = i.name
name = self.name list = name.split(' ', 1)
list = name.split(' ', 1) i.first_name = list[0]
print(list) if len(list) == 2:
self.first_name = list[0] i.last_name = list[1]
self.last_name = list[1]
@api.depends('name') @api.depends('name')
def _compute_first_name(self): def _compute_first_name(self):
print("_compute_first_name")
for i in self: for i in self:
list = i.name.split(' ',1) if i.name else None list = i.name.split(' ', 1) if i.name else None
if list and i.company_type == 'person': if list and i.company_type == 'person':
i.first_name = list[0] i.first_name = list[0]
@api.depends('name') @api.depends('name')
def _compute_last_name(self): def _compute_last_name(self):
print("_compute_last_name")
for i in self: for i in self:
list = i.name.split(' ', 1) if i.name else None list = i.name.split(' ', 1) if i.name else None
print(list) if len(list) == 2 and i.company_type == 'person':
if list and i.company_type == 'person':
print(i.name)
i.last_name = list[1] i.last_name = list[1]
Loading…
Cancel
Save