Skip to content

Commit

Permalink
Prepare partner_firstname for partner_second_lastname
Browse files Browse the repository at this point in the history
  • Loading branch information
Jairo Llopis authored and edlopen committed Mar 1, 2024
1 parent ed01ee6 commit c6f8dd8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
3 changes: 2 additions & 1 deletion partner_firstname/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
'name': 'Partner first name and last name',
'summary': "Split first name and last name for non company partners",
'version': '8.0.2.0.0',
'author': "Camptocamp,Odoo Community Association (OCA)",
'author': "Camptocamp, Odoo Community Association (OCA)",
"license": "AGPL-3",
'maintainer': 'Camptocamp, Acsone',
'category': 'Extra Tools',
'website': 'http://www.camptocamp.com, http://www.acsone.eu',
Expand Down
3 changes: 1 addition & 2 deletions partner_firstname/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- encoding: utf-8 -*-

# -*- coding: utf-8 -*-
# Odoo, Open Source Management Solution
# Copyright (C) 2014-2015 Grupo ESOC <www.grupoesoc.es>
#
Expand Down
7 changes: 4 additions & 3 deletions partner_firstname/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def _inverse_name_after_cleaning_whitespace(self):

@api.model
def _get_inverse_name(self, name, is_company=False):
"""Try to revert the effect of :meth:`._compute_name`.
"""Compute the inverted name.
- If the partner is a company, save it in the lastname.
- Otherwise, make a guess.
Expand All @@ -93,12 +93,13 @@ def _get_inverse_name(self, name, is_company=False):
parts = name.split(" ", 1)
while len(parts) < 2:
parts.append(False)
return parts
return {"lastname": parts[0], "firstname": parts[1]}

@api.one
def _inverse_name(self):
"""Try to revert the effect of :meth:`._compute_name`."""
parts = self._get_inverse_name(self.name, self.is_company)
self.lastname, self.firstname = parts
self.lastname, self.firstname = parts["lastname"], parts["firstname"]

@api.one
@api.constrains("firstname", "lastname")
Expand Down
3 changes: 1 addition & 2 deletions partner_firstname/tests/test_empty.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- encoding: utf-8 -*-

# -*- coding: utf-8 -*-
# Odoo, Open Source Management Solution
# Copyright (C) 2014-2015 Grupo ESOC <www.grupoesoc.es>
#
Expand Down

0 comments on commit c6f8dd8

Please sign in to comment.