From fde752c8f28c022df7bbe0769b4a1428b65cf835 Mon Sep 17 00:00:00 2001 From: Ajmalcybrosys Date: Thu, 18 Apr 2019 17:55:31 +0530 Subject: [PATCH] [FIX] Bug Fixed --- first_last_name/README.rst | 4 ++-- first_last_name/models/name.py | 33 ++++++++++++++++++--------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/first_last_name/README.rst b/first_last_name/README.rst index c8f90b346..b6daf3f96 100755 --- a/first_last_name/README.rst +++ b/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 @@ -14,7 +14,7 @@ Tech Installation ============ -- www.odoo.com/documentation/11.0/setup/install.html +- www.odoo.com/documentation/12.0/setup/install.html - Install our custom addon Bug Tracker diff --git a/first_last_name/models/name.py b/first_last_name/models/name.py index cfd088a36..58e5419d2 100644 --- a/first_last_name/models/name.py +++ b/first_last_name/models/name.py @@ -11,27 +11,30 @@ class FirstNameLastName(models.Model): @api.onchange('last_name', 'first_name') def _onchange_first_last_name(self): - if self.first_name and self.last_name: - self.name = (self.first_name + ' ' + self.last_name) + for i in self: + if i.first_name and i.last_name: + i.name = (i.first_name + ' ' + i.last_name) @api.onchange('name') def _onchange_name(self): - if self.name: - name = self.name - list = name.split(' ', 1) - self.first_name = list[0] - self.last_name = list[1] + for i in self: + if i.name and i.company_type == 'person': + name = i.name + list = name.split(' ', 1) + i.first_name = list[0] + if len(list) == 2: + i.last_name = list[1] @api.depends('name') def _compute_first_name(self): - if self.name: - name = self.name - list = name.split(' ', 1) - self.first_name = list[0] + for i in self: + list = i.name.split(' ', 1) if i.name else None + if list and i.company_type == 'person': + i.first_name = list[0] @api.depends('name') def _compute_last_name(self): - if self.name: - name = self.name - list = name.split(' ', 1) - self.last_name = list[1] + for i in self: + list = i.name.split(' ', 1) if i.name else None + if len(list) == 2 and i.company_type == 'person': + i.last_name = list[1]