Browse Source

[MIG] partner_second_lastname: Migration to 10.0

pull/495/head
Pedro M. Baeza 8 years ago
committed by Jordi Ballester
parent
commit
00cbc810cc
  1. 15
      partner_second_lastname/README.rst
  2. 16
      partner_second_lastname/__manifest__.py
  3. 58
      partner_second_lastname/i18n/es.po
  4. 63
      partner_second_lastname/i18n/partner_second_lastname.pot
  5. 2
      partner_second_lastname/models/base_config_settings.py
  6. 29
      partner_second_lastname/models/res_partner.py
  7. 7
      partner_second_lastname/tests/__init__.py
  8. 35
      partner_second_lastname/tests/test_config.py
  9. 4
      partner_second_lastname/tests/test_name.py
  10. 3
      partner_second_lastname/tests/test_onchange.py
  11. 157
      partner_second_lastname/views/res_partner.xml
  12. 62
      partner_second_lastname/views/res_user.xml

15
partner_second_lastname/README.rst

@ -11,7 +11,7 @@ support having a second lastname for contact partners.
In some countries, it's important to have a second last name for contacts. In some countries, it's important to have a second last name for contacts.
Contact partners will need to fulfill at least one of the name fields
Contact partners will need to fill at least one of the name fields
(*First name*, *First last name* or *Second last name*). (*First name*, *First last name* or *Second last name*).
Configuration Configuration
@ -53,7 +53,7 @@ you easily in some corner cases.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot :alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/134/8.0
:target: https://runbot.odoo-community.org/runbot/134/10.0
Known issues / Roadmap Known issues / Roadmap
@ -71,7 +71,7 @@ Bugs are tracked on `GitHub Issues
<https://github.com/OCA/partner-contact/issues>`_. In case of trouble, please <https://github.com/OCA/partner-contact/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first, check there if your issue has already been reported. If you spotted it first,
help us smashing it by providing a detailed and welcomed feedback `here help us smashing it by providing a detailed and welcomed feedback `here
<https://github.com/OCA/partner-contact/issues/new?body=module:%20partner_second_lastname%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
<https://github.com/OCA/partner-contact/issues/new>`_.
Credits Credits
@ -80,10 +80,9 @@ Credits
Contributors Contributors
------------ ------------
* `Grupo ESOC <http://grupoesoc.es>`_:
* `Jairo Llopis <mailto:j.llopis@grupoesoc.es>`_.
* `Antiun Ingeniería S.L. <http://www.antiun.com>`_:
* `Antonio Espinosa <mailto:antonioea@antiun.com>`_.
* Jairo Llopis <jairo.llopis@tecnativa.com>.
* Antonio Espinosa.
* Pedro M. Baeza <pedro.baeza@tecnativa.com>.
Maintainer Maintainer
---------- ----------
@ -98,4 +97,4 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
To contribute to this module, please visit http://odoo-community.org.
To contribute to this module, please visit https://odoo-community.org.

16
partner_second_lastname/__openerp__.py → partner_second_lastname/__manifest__.py

@ -1,24 +1,24 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
# Copyright 2015 Antiun Ingenieria S.L. - Antonio Espinosa
# 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).
# © 2015 Grupo ESOC Ingeniería de Servicios, S.L.U.
{ {
"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": "8.0.4.1.0",
"version": "10.0.1.0.0",
"license": "AGPL-3", "license": "AGPL-3",
"website": "https://grupoesoc.es",
"author": "Grupo ESOC Ingeniería de Servicios, "
"website": "https://www.tecnativa.com",
"author": "Tecnativa, "
"Odoo Community Association (OCA)", "Odoo Community Association (OCA)",
"maintainer": "Odoo Community Association (OCA)",
"category": "Extra Tools",
"category": "Partner Management",
"depends": [ "depends": [
"partner_firstname"
"partner_firstname",
], ],
"data": [ "data": [
"views/res_partner.xml", "views/res_partner.xml",
"views/res_user.xml", "views/res_user.xml",
], ],
"installable": True, "installable": True,
'images': [],
} }

58
partner_second_lastname/i18n/es.po

@ -1,21 +1,19 @@
# Translation of Odoo Server. # Translation of Odoo Server.
# This file contains the translation of the following modules: # This file contains the translation of the following modules:
# * partner_lastname2
# * partner_second_lastname
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 8.0-20150327\n"
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-08-13 11:16+0100\n"
"PO-Revision-Date: 2015-08-13 11:16+0100\n"
"Last-Translator: Jairo Llopis <j.llopis@grupoesoc.es>\n"
"POT-Creation-Date: 2017-06-22 00:28+0000\n"
"PO-Revision-Date: 2017-06-22 00:28+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n" "Language-Team: \n"
"Language: es_ES\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 1.8.1\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: partner_second_lastname #. module: partner_second_lastname
#: model:ir.model,name:partner_second_lastname.model_res_partner #: model:ir.model,name:partner_second_lastname.model_res_partner
@ -23,46 +21,12 @@ msgid "Partner"
msgstr "Empresa" msgstr "Empresa"
#. module: partner_second_lastname #. module: partner_second_lastname
#: field:res.partner,lastname2:0
#: model:ir.model.fields,field_description:partner_second_lastname.field_res_partner_lastname2
msgid "Second last name" msgid "Second last name"
msgstr "Segundo apellido" msgstr "Segundo apellido"
#. module: partner_second_lastname #. module: partner_second_lastname
#: view:res.partner:partner_second_lastname.partner_form
#: view:res.partner:partner_second_lastname.partner_simple_form
msgid ""
"{\n"
" 'required': [('firstname', '=', False),\n"
" ('lastname2', '=', False),\n"
" ('is_company', '=', False)]\n"
" }"
msgstr ""
#: model:ir.model,name:partner_second_lastname.model_base_config_settings
msgid "base.config.settings"
msgstr "base.config.settings"
#. module: partner_second_lastname
#: view:res.users:partner_second_lastname.users_form
msgid ""
"{\n"
" 'required': [('firstname', '=', False),\n"
" ('lastname2', '=', False)]\n"
" }"
msgstr ""
#. module: partner_second_lastname
#: view:res.partner:partner_second_lastname.partner_form
#: view:res.partner:partner_second_lastname.partner_simple_form
msgid ""
"{\n"
" 'required': [('lastname', '=', False),\n"
" ('lastname2', '=', False),\n"
" ('is_company', '=', False)]\n"
" }"
msgstr ""
#. module: partner_second_lastname
#: view:res.users:partner_second_lastname.users_form
msgid ""
"{\n"
" 'required': [('lastname', '=', False),\n"
" ('lastname2', '=', False)]\n"
" }"
msgstr ""

63
partner_second_lastname/i18n/partner_second_lastname.pot

@ -1,63 +0,0 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_second_lastname
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0-20150811\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-08-13 09:15+0000\n"
"PO-Revision-Date: 2015-08-13 09:15+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: partner_second_lastname
#: model:ir.model,name:partner_second_lastname.model_res_partner
msgid "Partner"
msgstr ""
#. module: partner_second_lastname
#: field:res.partner,lastname2:0
msgid "Second last name"
msgstr ""
#. module: partner_second_lastname
#: view:res.partner:partner_second_lastname.partner_form
#: view:res.partner:partner_second_lastname.partner_simple_form
msgid "{\n"
" 'required': [('firstname', '=', False),\n"
" ('lastname2', '=', False),\n"
" ('is_company', '=', False)]\n"
" }"
msgstr ""
#. module: partner_second_lastname
#: view:res.users:partner_second_lastname.users_form
msgid "{\n"
" 'required': [('firstname', '=', False),\n"
" ('lastname2', '=', False)]\n"
" }"
msgstr ""
#. module: partner_second_lastname
#: view:res.partner:partner_second_lastname.partner_form
#: view:res.partner:partner_second_lastname.partner_simple_form
msgid "{\n"
" 'required': [('lastname', '=', False),\n"
" ('lastname2', '=', False),\n"
" ('is_company', '=', False)]\n"
" }"
msgstr ""
#. module: partner_second_lastname
#: view:res.users:partner_second_lastname.users_form
msgid "{\n"
" 'required': [('lastname', '=', False),\n"
" ('lastname2', '=', False)]\n"
" }"
msgstr ""

2
partner_second_lastname/models/base_config_settings.py

@ -2,7 +2,7 @@
# © 2015 Antiun Ingenieria S.L. - Antonio Espinosa # © 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 openerp import models, api
from odoo import models, api
class BaseConfigSettings(models.TransientModel): class BaseConfigSettings(models.TransientModel):

29
partner_second_lastname/models/res_partner.py

@ -1,15 +1,15 @@
# -*- coding: utf-8 -*- # -*- 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. - Jairo Llopis
# Copyright 2015 Antiun Ingenieria S.L. - Antonio Espinosa
# Copyright 2017 Tecnativa - Pedro M. Baeza
from openerp import api, fields, models
from openerp.addons.partner_firstname.models import exceptions
from odoo import api, fields, models
from odoo.addons.partner_firstname import exceptions
class ResPartner(models.Model): 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", oldname="lastname_second")
@ -41,20 +41,20 @@ class ResPartner(models.Model):
names.append(firstname) names.append(firstname)
return u" ".join(names) return u" ".join(names)
@api.one
@api.depends("firstname", "lastname", "lastname2") @api.depends("firstname", "lastname", "lastname2")
def _compute_name(self): def _compute_name(self):
"""Write :attr:`~.name` according to splitted data.""" """Write :attr:`~.name` according to splitted data."""
self.name = self._get_computed_name(
self.lastname, self.firstname, self.lastname2)
for partner in self:
partner.name = self._get_computed_name(
partner.lastname, partner.firstname, partner.lastname2,
)
@api.one @api.one
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`."""
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 = dict(), dict()
before, after = {}, {}
for key, value in parts.iteritems(): for key, value in parts.iteritems():
(before if value else after)[key] = value (before if value else after)[key] = value
if any([before[k] != self[k] for k in before.keys()]): if any([before[k] != self[k] for k in before.keys()]):
@ -96,17 +96,16 @@ class ResPartner(models.Model):
result['lastname2'] = parts[1] result['lastname2'] = parts[1]
return result return result
@api.one
@api.constrains("firstname", "lastname", "lastname2") @api.constrains("firstname", "lastname", "lastname2")
def _check_name(self): def _check_name(self):
"""Ensure at least one name is set.""" """Ensure at least one name is set."""
try: try:
super(ResPartner, self)._check_name() super(ResPartner, self)._check_name()
except exceptions.EmptyNamesError as error:
if not self.lastname2:
raise error
except exceptions.EmptyNamesError:
for partner in self:
if not partner.lastname2:
raise
@api.one
@api.onchange("firstname", "lastname", "lastname2") @api.onchange("firstname", "lastname", "lastname2")
def _onchange_subnames(self): def _onchange_subnames(self):
"""Trigger onchange with :attr:`~.lastname2` too.""" """Trigger onchange with :attr:`~.lastname2` too."""

7
partner_second_lastname/tests/__init__.py

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*- # -*- 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.
from . import test_name, test_onchange
from openerp.addons.partner_firstname.tests import test_empty
from . import test_name
from . import test_onchange
from . import test_config
from odoo.addons.partner_firstname.tests import test_empty

35
partner_second_lastname/tests/test_config.py

@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo.tests import common
class TestConfig(common.SavepointCase):
@classmethod
def setUpClass(cls):
super(TestConfig, cls).setUpClass()
cls.wizard = cls.env['base.config.settings'].create({})
cls.partner = cls.env['res.partner'].create({
'firstname': "First",
'lastname': "Last",
'lastname2': "Second",
})
def test_last_first(self):
self.wizard.partner_names_order = 'last_first'
self.wizard.set_partner_names_order()
self.wizard.action_recalculate_partners_name()
self.assertEqual(self.partner.name, "Last Second First")
def test_last_first_comma(self):
self.wizard.partner_names_order = 'last_first_comma'
self.wizard.set_partner_names_order()
self.wizard.action_recalculate_partners_name()
self.assertEqual(self.partner.name, "Last Second, First")
def test_first_last(self):
self.wizard.partner_names_order = 'first_last'
self.wizard.set_partner_names_order()
self.wizard.action_recalculate_partners_name()
self.assertEqual(self.partner.name, "First Last Second")

4
partner_second_lastname/tests/test_name.py

@ -3,8 +3,8 @@
# © 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. # © 2015 Grupo ESOC Ingeniería de Servicios, S.L.U.
# © 2015 Antiun Ingenieria S.L. - Antonio Espinosa # © 2015 Antiun Ingenieria S.L. - Antonio Espinosa
from openerp.tests.common import TransactionCase
from openerp.addons.partner_firstname.tests.base import MailInstalled
from odoo.tests.common import TransactionCase
from odoo.addons.partner_firstname.tests.base import MailInstalled
class CompanyCase(TransactionCase): class CompanyCase(TransactionCase):

3
partner_second_lastname/tests/test_onchange.py

@ -8,7 +8,7 @@
The form operates in onchange mode, with its limitations. The form operates in onchange mode, with its limitations.
""" """
from openerp.tests.common import TransactionCase
from odoo.tests.common import TransactionCase
class OnChangeCase(TransactionCase): class OnChangeCase(TransactionCase):
@ -31,6 +31,7 @@ class PartnerCompanyCase(OnChangeCase):
def tearDown(self): def tearDown(self):
"""Companies never have ``firstname`` nor ``lastname2``.""" """Companies never have ``firstname`` nor ``lastname2``."""
super(PartnerCompanyCase, self).tearDown()
self.assertEqual(self.partner.firstname, False) self.assertEqual(self.partner.firstname, False)
self.assertEqual(self.partner.lastname2, False) self.assertEqual(self.partner.lastname2, False)

157
partner_second_lastname/views/res_partner.xml

@ -1,105 +1,54 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
© 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. -->
<openerp>
<data>
<record id="partner_simple_form" model="ir.ui.view">
<field name="name">Add second last name</field>
<field name="model">res.partner</field>
<field name="inherit_id"
ref="partner_firstname.view_partner_simple_form_firstname"/>
<field name="arch" type="xml">
<data>
<xpath expr="//field[@name='firstname']" position="attributes">
<attribute name="attrs">{
'required': [('lastname', '=', False),
('lastname2', '=', False),
('is_company', '=', False)]
}</attribute>
</xpath>
<xpath expr="//field[@name='lastname']" position="attributes">
<attribute name="attrs">{
'required': [('firstname', '=', False),
('lastname2', '=', False),
('is_company', '=', False)]
}</attribute>
</xpath>
<xpath expr="//field[@name='lastname']" position="after">
<field name="lastname2"
attrs="{'required': [('firstname', '=', False),
('lastname', '=', False),
('is_company', '=', False)]}"/>
</xpath>
</data>
</field>
</record>
<record id="partner_form" model="ir.ui.view">
<field name="name">Add second last name</field>
<field name="model">res.partner</field>
<field name="inherit_id"
ref="partner_firstname.view_partner_form_firstname"/>
<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)]
}</attribute>
</xpath>
<xpath expr="//field[@name='lastname']" position="attributes">
<attribute name="attrs">{
'required': [('firstname', '=', False),
('lastname2', '=', False),
('is_company', '=', False)]
}</attribute>
</xpath>
<xpath expr="//field[@name='lastname']" position="after">
<field name="lastname2"
attrs="{'required': [('firstname', '=', False),
('lastname', '=', False),
('is_company', '=', False)]}"/>
</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)]
}</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)]
}</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)]}"/>
</xpath>
</data>
</field>
</record>
</data>
</openerp>
<!-- Copyright 2015 Tecnativa - Jairo Llopis
Copyright 2017 Tecnativa - Pedro M. Baeza
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="partner_simple_form" model="ir.ui.view">
<field name="model">res.partner</field>
<field name="inherit_id" ref="partner_firstname.view_partner_simple_form_firstname"/>
<field name="arch" type="xml">
<data>
<xpath expr="//field[@name='firstname']" position="attributes">
<attribute name="attrs">{'required': [('lastname', '=', False), ('lastname2', '=', False), ('is_company', '=', False)]}</attribute>
</xpath>
<xpath expr="//field[@name='lastname']" position="attributes">
<attribute name="attrs">{'required': [('firstname', '=', False), ('lastname2', '=', False), ('is_company', '=', False)]}</attribute>
</xpath>
<xpath expr="//field[@name='lastname']" position="after">
<field name="lastname2" attrs="{'required': [('firstname', '=', False), ('lastname', '=', False), ('is_company', '=', False)]}"/>
</xpath>
</data>
</field>
</record>
<record id="partner_form" model="ir.ui.view">
<field name="model">res.partner</field>
<field name="inherit_id" ref="partner_firstname.view_partner_form_firstname"/>
<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)]}</attribute>
</xpath>
<xpath expr="//field[@name='lastname']" position="attributes">
<attribute name="attrs">{'required': [('firstname', '=', False), ('lastname2', '=', False), ('is_company', '=', False)]}</attribute>
</xpath>
<xpath expr="//field[@name='lastname']" position="after">
<field name="lastname2" attrs="{'required': [('firstname', '=', False), ('lastname', '=', False), ('is_company', '=', False)]}"/>
</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)]}</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)]}</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)]}"/>
</xpath>
</data>
</field>
</record>
</odoo>

62
partner_second_lastname/views/res_user.xml

@ -1,42 +1,30 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
© 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. -->
<!-- Copyright 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
Copyright 2017 Tecnativa - Pedro M. Baeza
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<openerp>
<data>
<record id="users_form" model="ir.ui.view">
<field name="name">Add second last name</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="partner_firstname.view_users_form"/>
<field name="arch" type="xml">
<data>
<xpath expr="//field[@name='firstname']" position="attributes">
<attribute name="attrs">{'required': [('lastname', '=', False), ('lastname2', '=', False)]}</attribute>
</xpath>
<!-- Required before modifying `base.vew_users_form`.
https://github.com/odoo/odoo/issues/6324#issuecomment-93534579 -->
<function model="res.groups" name="update_user_groups_view" />
<xpath expr="//field[@name='lastname']" position="attributes">
<attribute name="attrs">{'required': [('firstname', '=', False), ('lastname2', '=', False)]}</attribute>
</xpath>
<record id="users_form" model="ir.ui.view">
<field name="name">Add second last name</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="partner_firstname.view_users_form"/>
<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="after">
<field name="lastname2"
attrs="{'required': [('firstname', '=', False), ('lastname', '=', False)]}"
/>
</xpath>
</data>
</field>
</record>
<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>
</record>
</data>
</openerp>
</odoo>
Loading…
Cancel
Save