Browse Source

Prepare partner_firstname for partner_second_lastname

pull/663/head
Jairo Llopis 10 years ago
committed by Jairo Llopis
parent
commit
eccad287c5
  1. 3
      partner_firstname/__openerp__.py
  2. 3
      partner_firstname/exceptions.py
  3. 7
      partner_firstname/models.py
  4. 3
      partner_firstname/tests/test_empty.py

3
partner_firstname/__openerp__.py

@ -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',

3
partner_firstname/exceptions.py

@ -1,5 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
# Odoo, Open Source Management Solution
# Copyright (C) 2014-2015 Grupo ESOC <www.grupoesoc.es>
#

7
partner_firstname/models.py

@ -73,7 +73,7 @@ class ResPartner(models.Model):
@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.
@ -93,12 +93,13 @@ class ResPartner(models.Model):
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")

3
partner_firstname/tests/test_empty.py

@ -1,5 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
# Odoo, Open Source Management Solution
# Copyright (C) 2014-2015 Grupo ESOC <www.grupoesoc.es>
#

Loading…
Cancel
Save