26 lines
968 B
Python
26 lines
968 B
Python
![]() |
from odoo import api, fields, models
|
||
|
|
||
|
class Users(models.Model):
|
||
|
_inherit = 'res.users'
|
||
|
|
||
|
last_name = fields.Char(string='Фамилия', compute='update_name')
|
||
|
first_name = fields.Char(string='Имя', compute='update_name')
|
||
|
second_name = fields.Char(string='Отчество', compute='update_name')
|
||
|
|
||
|
@api.depends('name')
|
||
|
def update_name(self):
|
||
|
for s in self:
|
||
|
s.last_name = ''
|
||
|
s.first_name = ''
|
||
|
s.second_name = ''
|
||
|
if s.name:
|
||
|
s.last_name = s.name
|
||
|
s.first_name = ''
|
||
|
s.second_name = ''
|
||
|
if len(s.name.split(' ')) == 3:
|
||
|
s.last_name, s.first_name, s.second_name = s.name.split(' ')
|
||
|
if len(s.name.split(' ')) == 4:
|
||
|
s.last_name, s.first_name, second_name1, second_name2 = s.name.split(' ')
|
||
|
s.second_name = second_name1 + ' ' + second_name2
|
||
|
|