Browse Source

[MIG] partner_second_lastname v11 to v12

pull/696/head
Nikul-Chaudhary 6 years ago
parent
commit
c16d27cb60
  1. 1
      partner_second_lastname/README.rst
  2. 3
      partner_second_lastname/__init__.py
  3. 5
      partner_second_lastname/__manifest__.py
  4. 2
      partner_second_lastname/models/__init__.py
  5. 3
      partner_second_lastname/models/res_config_settings.py
  6. 10
      partner_second_lastname/models/res_partner.py
  7. 15
      partner_second_lastname/readme/CONFIGURE.rst
  8. 4
      partner_second_lastname/readme/CONTRIBUTORS.rst
  9. 7
      partner_second_lastname/readme/DESCRIPTION.rst
  10. 13
      partner_second_lastname/readme/USAGE.rst
  11. 1
      partner_second_lastname/tests/__init__.py
  12. 1
      partner_second_lastname/tests/test_config.py
  13. 5
      partner_second_lastname/tests/test_name.py
  14. 5
      partner_second_lastname/tests/test_onchange.py
  15. 62
      partner_second_lastname/views/res_partner.xml
  16. 24
      partner_second_lastname/views/res_user.xml

1
partner_second_lastname/README.rst

@ -83,6 +83,7 @@ Contributors
* Jairo Llopis <jairo.llopis@tecnativa.com>. * Jairo Llopis <jairo.llopis@tecnativa.com>.
* Antonio Espinosa. * Antonio Espinosa.
* Pedro M. Baeza <pedro.baeza@tecnativa.com>. * Pedro M. Baeza <pedro.baeza@tecnativa.com>.
* Nikul Chaudhary <nikulchaudhary2112@gmail.com>
Maintainer Maintainer
---------- ----------

3
partner_second_lastname/__init__.py

@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
# Copyright 2015 Grupo ESOC Ingeniería de Servicios, S.L.U.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# © 2015 Grupo ESOC Ingeniería de Servicios, S.L.U.
from . import models from . import models

5
partner_second_lastname/__manifest__.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis # Copyright 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
# Copyright 2015 Antiun Ingenieria S.L. - Antonio Espinosa # Copyright 2015 Antiun Ingenieria S.L. - Antonio Espinosa
# Copyright 2017 Tecnativa - Pedro M. Baeza # Copyright 2017 Tecnativa - Pedro M. Baeza
@ -7,9 +6,9 @@
{ {
"name": "Partner second last name", "name": "Partner second last name",
"summary": "Have split first and second lastnames", "summary": "Have split first and second lastnames",
"version": "11.0.1.0.0",
"version": "12.0.1.0.0",
"license": "AGPL-3", "license": "AGPL-3",
"website": "https://www.tecnativa.com",
"website": "https://github.com/OCA/partner-contact",
"author": "Tecnativa, " "author": "Tecnativa, "
"Odoo Community Association (OCA)", "Odoo Community Association (OCA)",
"category": "Partner Management", "category": "Partner Management",

2
partner_second_lastname/models/__init__.py

@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
# © 2015 Antiun Ingenieria S.L. - Antonio Espinosa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import res_config_settings from . import res_config_settings

3
partner_second_lastname/models/res_config_settings.py

@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
# © 2015 Antiun Ingenieria S.L. - Antonio Espinosa
# Copyright 2015 Antiun Ingenieria S.L. - Antonio Espinosa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models, api from odoo import models, api

10
partner_second_lastname/models/res_partner.py

@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# Copyright 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis # Copyright 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
# Copyright 2015 Antiun Ingenieria S.L. - Antonio Espinosa # Copyright 2015 Antiun Ingenieria S.L. - Antonio Espinosa
# Copyright 2017 Tecnativa - Pedro M. Baeza # Copyright 2017 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models from odoo import api, fields, models
from odoo.addons.partner_firstname import exceptions from odoo.addons.partner_firstname import exceptions
@ -12,7 +11,9 @@ class ResPartner(models.Model):
"""Adds a second last name.""" """Adds a second last name."""
_inherit = "res.partner" _inherit = "res.partner"
lastname2 = fields.Char("Second last name", oldname="lastname_second")
lastname2 = fields.Char(
"Second last name",
)
@api.model @api.model
def _get_computed_name(self, lastname, firstname, lastname2=None): def _get_computed_name(self, lastname, firstname, lastname2=None):
@ -49,9 +50,10 @@ class ResPartner(models.Model):
partner.lastname, partner.firstname, partner.lastname2, partner.lastname, partner.firstname, partner.lastname2,
) )
@api.one
@api.multi
def _inverse_name(self): def _inverse_name(self):
"""Try to revert the effect of :meth:`._compute_name`.""" """Try to revert the effect of :meth:`._compute_name`."""
self.ensure_one()
parts = self._get_inverse_name(self.name, self.is_company) parts = self._get_inverse_name(self.name, self.is_company)
# Avoid to hit :meth:`~._check_name` with all 3 fields being ``False`` # Avoid to hit :meth:`~._check_name` with all 3 fields being ``False``
before, after = {}, {} before, after = {}, {}

15
partner_second_lastname/readme/CONFIGURE.rst

@ -0,0 +1,15 @@
You can configure some common name patterns for the inverse function
in Settings > Configuration > General settings:
* Lastname SecondLastname Firstname: For example 'Anderson Lavarge Robert'
* Lastname SecondLastname, Firstname: For example 'Anderson Lavarge, Robert'
* Firstname Lastname SecondLastname: For example 'Robert Anderson Lavarge'
After applying the changes, you can recalculate all partners name clicking
"Recalculate names" button. Note: This process could take so much time depending
how many partners there are in database.
You can use *_get_inverse_name* method to get firstname, lastname and
second lastname from a simple string and also *_get_computed_name* to get a
name form the firstname, lastname and second lastname.
These methods can be overridden to change the format specified above.

4
partner_second_lastname/readme/CONTRIBUTORS.rst

@ -0,0 +1,4 @@
* Jairo Llopis <jairo.llopis@tecnativa.com>.
* Antonio Espinosa.
* Pedro M. Baeza <pedro.baeza@tecnativa.com>.
* Nikul Chaudhary <nikulchaudhary2112@gmail.com>

7
partner_second_lastname/readme/DESCRIPTION.rst

@ -0,0 +1,7 @@
This module was written to extend the functionality of ``partner_firstname`` to
support having a second lastname for contact partners.
In some countries, it's important to have a second last name for contacts.
Contact partners will need to fill at least one of the name fields
(*First name*, *First last name* or *Second last name*).

13
partner_second_lastname/readme/USAGE.rst

@ -0,0 +1,13 @@
To use this module, you need to:
* Edit any partner's form.
* Make sure the partner is not a company.
* Enter firstname and lastnames.
If you directly enter the full name instead of entering the other fields
separately (maybe from other form), this module will try to guess the best
match for your input and split it between firstname, lastname and second
lastname using an inverse function.
If you can, always enter it manually please. Automatic guessing could fail for
you easily in some corner cases.

1
partner_second_lastname/tests/__init__.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import test_name from . import test_name

1
partner_second_lastname/tests/test_config.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Tecnativa - Pedro M. Baeza # Copyright 2017 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

5
partner_second_lastname/tests/test_name.py

@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# © 2015 Grupo ESOC Ingeniería de Servicios, S.L.U.
# © 2015 Antiun Ingenieria S.L. - Antonio Espinosa
# Copyright 2015 Grupo ESOC Ingeniería de Servicios, S.L.U.
# Copyright 2015 Antiun Ingenieria S.L. - Antonio Espinosa
from odoo.tests.common import TransactionCase from odoo.tests.common import TransactionCase
from odoo.addons.partner_firstname.tests.base import MailInstalled from odoo.addons.partner_firstname.tests.base import MailInstalled

5
partner_second_lastname/tests/test_onchange.py

@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# © 2015 Grupo ESOC Ingeniería de Servicios, S.L.U.
# © 2015 Antiun Ingenieria S.L. - Antonio Espinosa
# Copyright 2015 Grupo ESOC Ingeniería de Servicios, S.L.U.
# Copyright 2015 Antiun Ingenieria S.L. - Antonio Espinosa
"""These tests try to mimic the behavior of the UI form. """These tests try to mimic the behavior of the UI form.

62
partner_second_lastname/views/res_partner.xml

@ -7,17 +7,15 @@
<field name="model">res.partner</field> <field name="model">res.partner</field>
<field name="inherit_id" ref="partner_firstname.view_partner_simple_form_firstname"/> <field name="inherit_id" ref="partner_firstname.view_partner_simple_form_firstname"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<data>
<xpath expr="//field[@name='firstname']" position="attributes">
<attribute name="attrs">{'required': [('lastname', '=', False), ('lastname2', '=', False), ('is_company', '=', False), ('type', '=', 'contact')]}</attribute>
</xpath>
<xpath expr="//field[@name='lastname']" position="attributes">
<attribute name="attrs">{'required': [('firstname', '=', False), ('lastname2', '=', False), ('is_company', '=', False), ('type', '=', 'contact')]}</attribute>
</xpath>
<xpath expr="//field[@name='lastname']" position="after">
<field name="lastname2" attrs="{'required': [('firstname', '=', False), ('lastname', '=', False), ('is_company', '=', False), ('type', '=', 'contact')]}"/>
</xpath>
</data>
<field name="firstname" position="attributes">
<attribute name="attrs">{'required': [('lastname', '=', False), ('lastname2', '=', False), ('is_company', '=', False), ('type', '=', 'contact')]}</attribute>
</field>
<field name="lastname" position="attributes">
<attribute name="attrs">{'required': [('firstname', '=', False), ('lastname2', '=', False), ('is_company', '=', False), ('type', '=', 'contact')]}</attribute>
</field>
<field name="lastname" position="after">
<field name="lastname2" attrs="{'required': [('firstname', '=', False), ('lastname', '=', False), ('is_company', '=', False), ('type', '=', 'contact')]}"/>
</field>
</field> </field>
</record> </record>
@ -25,29 +23,27 @@
<field name="model">res.partner</field> <field name="model">res.partner</field>
<field name="inherit_id" ref="partner_firstname.view_partner_form_firstname"/> <field name="inherit_id" ref="partner_firstname.view_partner_form_firstname"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<data>
<!-- Main form -->
<xpath expr="//field[@name='firstname']" position="attributes">
<attribute name="attrs">{'required': [('lastname', '=', False), ('lastname2', '=', False), ('is_company', '=', False), ('type', '=', 'contact')]}</attribute>
</xpath>
<!-- Main form -->
<field name="firstname" position="attributes">
<attribute name="attrs">{'required': [('lastname', '=', False), ('lastname2', '=', False), ('is_company', '=', False), ('type', '=', 'contact')]}</attribute>
</field>
<xpath expr="//field[@name='lastname']" position="attributes">
<attribute name="attrs">{'required': [('firstname', '=', False), ('lastname2', '=', False), ('is_company', '=', False), ('type', '=', 'contact')]}</attribute>
</xpath>
<xpath expr="//field[@name='lastname']" position="after">
<field name="lastname2" attrs="{'required': [('firstname', '=', False), ('lastname', '=', False), ('is_company', '=', False), ('type', '=', 'contact')]}"/>
</xpath>
<!-- Inner contact form of child_ids -->
<xpath expr="//field[@name='child_ids']/form//field[@name='firstname']" position="attributes">
<attribute name="attrs">{'required': [('lastname', '=', False), ('lastname2', '=', False), ('is_company', '=', False), ('type', '=', 'contact')]}</attribute>
</xpath>
<xpath expr="//field[@name='child_ids']/form//field[@name='lastname']" position="attributes">
<attribute name="attrs">{'required': [('firstname', '=', False), ('lastname2', '=', False), ('is_company', '=', False), ('type', '=', 'contact')]}</attribute>
</xpath>
<xpath expr="//field[@name='child_ids']/form//field[@name='lastname']" position="after">
<field name="lastname2" attrs="{'required': [('firstname', '=', False), ('lastname', '=', False), ('is_company', '=', False), ('type', '=', 'contact')]}"/>
</xpath>
</data>
<field name="lastname" position="attributes">
<attribute name="attrs">{'required': [('firstname', '=', False), ('lastname2', '=', False), ('is_company', '=', False), ('type', '=', 'contact')]}</attribute>
</field>
<field name="lastname" position="after">
<field name="lastname2" attrs="{'required': [('firstname', '=', False), ('lastname', '=', False), ('is_company', '=', False), ('type', '=', 'contact')]}"/>
</field>
<!-- Inner contact form of child_ids -->
<xpath expr="//field[@name='child_ids']/form//field[@name='firstname']" position="attributes">
<attribute name="attrs">{'required': [('lastname', '=', False), ('lastname2', '=', False), ('is_company', '=', False), ('type', '=', 'contact')]}</attribute>
</xpath>
<xpath expr="//field[@name='child_ids']/form//field[@name='lastname']" position="attributes">
<attribute name="attrs">{'required': [('firstname', '=', False), ('lastname2', '=', False), ('is_company', '=', False), ('type', '=', 'contact')]}</attribute>
</xpath>
<xpath expr="//field[@name='child_ids']/form//field[@name='lastname']" position="after">
<field name="lastname2" attrs="{'required': [('firstname', '=', False), ('lastname', '=', False), ('is_company', '=', False), ('type', '=', 'contact')]}"/>
</xpath>
</field> </field>
</record> </record>

24
partner_second_lastname/views/res_user.xml

@ -9,21 +9,15 @@
<field name="model">res.users</field> <field name="model">res.users</field>
<field name="inherit_id" ref="partner_firstname.view_users_form"/> <field name="inherit_id" ref="partner_firstname.view_users_form"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<data>
<xpath expr="//field[@name='firstname']" position="attributes">
<attribute name="attrs">{'required': [('lastname', '=', False), ('lastname2', '=', False)]}</attribute>
</xpath>
<xpath expr="//field[@name='lastname']" position="attributes">
<attribute name="attrs">{'required': [('firstname', '=', False), ('lastname2', '=', False)]}</attribute>
</xpath>
<xpath expr="//field[@name='lastname']" position="after">
<field name="lastname2"
attrs="{'required': [('firstname', '=', False), ('lastname', '=', False)]}"
/>
</xpath>
</data>
<field name="firstname" position="attributes">
<attribute name="attrs">{'required': [('lastname', '=', False), ('lastname2', '=', False)]}</attribute>
</field>
<field name="lastname" position="attributes">
<attribute name="attrs">{'required': [('firstname', '=', False), ('lastname2', '=', False)]}</attribute>
</field>
<field name="lastname" position="after">
<field name="lastname2" attrs="{'required': [('firstname', '=', False), ('lastname', '=', False)]}" />
</field>
</field> </field>
</record> </record>

Loading…
Cancel
Save