You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.2 KiB
37 lines
1.2 KiB
# -*- coding: utf-8 -*-
|
|
# © 2013 Nicolas Bessi (Camptocamp SA)
|
|
# © 2014 Agile Business Group (<http://www.agilebg.com>)
|
|
# © 2015 Grupo ESOC (<http://www.grupoesoc.es>)
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
|
import logging
|
|
from openerp import api, models
|
|
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
class ResUser(models.Model):
|
|
_inherit = 'res.users'
|
|
|
|
@api.model
|
|
def default_get(self, fields_list):
|
|
"""Invert name when getting default values."""
|
|
result = super(ResUser, self).default_get(fields_list)
|
|
|
|
partner_model = self.env['res.partner']
|
|
inverted = partner_model._get_inverse_name(
|
|
partner_model._get_whitespace_cleaned_name(result.get("name", "")),
|
|
result.get("is_company", False))
|
|
|
|
for field in inverted.keys():
|
|
if field in fields_list:
|
|
result[field] = inverted.get(field)
|
|
|
|
return result
|
|
|
|
@api.onchange("firstname", "lastname")
|
|
def _compute_name(self):
|
|
"""Write the 'name' field according to splitted data."""
|
|
for rec in self:
|
|
rec.name = rec.partner_id._get_computed_name(
|
|
rec.lastname, rec.firstname)
|