Browse Source

[FIX] Bug Fixed

pull/124/head
Ajmalcybrosys 6 years ago
parent
commit
fde752c8f2
  1. 4
      first_last_name/README.rst
  2. 33
      first_last_name/models/name.py

4
first_last_name/README.rst

@ -1,4 +1,4 @@
Contact First And Last Name v11 Contact First And Last Name v12
=========================== ===========================
This module will helps you to give the first name and last name for your contact This module will helps you to give the first name and last name for your contact
@ -14,7 +14,7 @@ Tech
Installation Installation
============ ============
- www.odoo.com/documentation/11.0/setup/install.html - www.odoo.com/documentation/12.0/setup/install.html
- Install our custom addon - Install our custom addon
Bug Tracker Bug Tracker

33
first_last_name/models/name.py

@ -11,27 +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):
if self.first_name and self.last_name: for i in self:
self.name = (self.first_name + ' ' + self.last_name) if i.first_name and i.last_name:
i.name = (i.first_name + ' ' + i.last_name)
@api.onchange('name') @api.onchange('name')
def _onchange_name(self): def _onchange_name(self):
if self.name: for i in self:
name = self.name if i.name and i.company_type == 'person':
list = name.split(' ', 1) name = i.name
self.first_name = list[0] list = name.split(' ', 1)
self.last_name = list[1] i.first_name = list[0]
if len(list) == 2:
i.last_name = list[1]
@api.depends('name') @api.depends('name')
def _compute_first_name(self): def _compute_first_name(self):
if self.name: for i in self:
name = self.name list = i.name.split(' ', 1) if i.name else None
list = name.split(' ', 1) if list and i.company_type == 'person':
self.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):
if self.name: for i in self:
name = self.name list = i.name.split(' ', 1) if i.name else None
list = name.split(' ', 1) if len(list) == 2 and i.company_type == 'person':
self.last_name = list[1] i.last_name = list[1]

Loading…
Cancel
Save