emagdalena
4 years ago
committed by
Luis Torres
8 changed files with 160 additions and 143 deletions
-
12partner_second_lastname/__manifest__.py
-
38partner_second_lastname/models/res_config_settings.py
-
37partner_second_lastname/models/res_partner.py
-
16partner_second_lastname/tests/test_config.py
-
90partner_second_lastname/tests/test_name.py
-
21partner_second_lastname/tests/test_onchange.py
-
68partner_second_lastname/views/res_partner.xml
-
21partner_second_lastname/views/res_user.xml
@ -1,28 +1,36 @@ |
|||
# Copyright 2015 Antiun Ingenieria S.L. - Antonio Espinosa |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from odoo import models, api |
|||
from odoo import api, models |
|||
|
|||
|
|||
class ResConfigSettings(models.TransientModel): |
|||
_inherit = 'res.config.settings' |
|||
_inherit = "res.config.settings" |
|||
|
|||
def _partner_names_order_selection(self): |
|||
options = super( |
|||
ResConfigSettings, self)._partner_names_order_selection() |
|||
options = super(ResConfigSettings, self)._partner_names_order_selection() |
|||
new_labels = { |
|||
'last_first': 'Lastname SecondLastname Firstname', |
|||
'last_first_comma': 'Lastname SecondLastname, Firstname', |
|||
'first_last': 'Firstname Lastname SecondLastname', |
|||
"last_first": "Lastname SecondLastname Firstname", |
|||
"last_first_comma": "Lastname SecondLastname, Firstname", |
|||
"first_last": "Firstname Lastname SecondLastname", |
|||
} |
|||
return [(k, new_labels[k]) if k in new_labels else (k, v) |
|||
for k, v in options] |
|||
return [(k, new_labels[k]) if k in new_labels else (k, v) for k, v in options] |
|||
|
|||
@api.multi |
|||
def _partners_for_recalculating(self): |
|||
return self.env['res.partner'].search([ |
|||
('is_company', '=', False), |
|||
'|', '&', ('firstname', '!=', False), ('lastname', '!=', False), |
|||
'|', '&', ('firstname', '!=', False), ('lastname2', '!=', False), |
|||
'&', ('lastname', '!=', False), ('lastname2', '!=', False), |
|||
]) |
|||
return self.env["res.partner"].search( |
|||
[ |
|||
("is_company", "=", False), |
|||
"|", |
|||
"&", |
|||
("firstname", "!=", False), |
|||
("lastname", "!=", False), |
|||
"|", |
|||
"&", |
|||
("firstname", "!=", False), |
|||
("lastname2", "!=", False), |
|||
"&", |
|||
("lastname", "!=", False), |
|||
("lastname2", "!=", False), |
|||
] |
|||
) |
@ -1,50 +1,80 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<?xml version="1.0" encoding="utf-8" ?> |
|||
<!-- 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="inherit_id" |
|||
ref="partner_firstname.view_partner_simple_form_firstname" |
|||
/> |
|||
<field name="arch" type="xml"> |
|||
<field name="firstname" position="attributes"> |
|||
<attribute name="attrs">{'required': [('lastname', '=', False), ('lastname2', '=', False), ('is_company', '=', False), ('type', '=', 'contact')]}</attribute> |
|||
<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> |
|||
<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 |
|||
name="lastname2" |
|||
attrs="{'required': [('firstname', '=', False), ('lastname', '=', False), ('is_company', '=', False), ('type', '=', 'contact')]}" |
|||
/> |
|||
</field> |
|||
</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="inherit_id" ref="partner_firstname.view_partner_form_firstname" /> |
|||
<field name="arch" type="xml"> |
|||
<!-- Main form --> |
|||
<field name="firstname" position="attributes"> |
|||
<attribute name="attrs">{'required': [('lastname', '=', False), ('lastname2', '=', False), ('is_company', '=', False), ('type', '=', 'contact')]}</attribute> |
|||
<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> |
|||
<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 |
|||
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 |
|||
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 |
|||
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 |
|||
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> |
|||
|
|||
</odoo> |
@ -1,24 +1,29 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<?xml version="1.0" encoding="utf-8" ?> |
|||
<!-- 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> |
|||
|
|||
<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="inherit_id" ref="partner_firstname.view_users_form" /> |
|||
<field name="arch" type="xml"> |
|||
<field name="firstname" position="attributes"> |
|||
<attribute name="attrs">{'required': [('lastname', '=', False), ('lastname2', '=', False)]}</attribute> |
|||
<attribute |
|||
name="attrs" |
|||
>{'required': [('lastname', '=', False), ('lastname2', '=', False)]}</attribute> |
|||
</field> |
|||
<field name="lastname" position="attributes"> |
|||
<attribute name="attrs">{'required': [('firstname', '=', False), ('lastname2', '=', False)]}</attribute> |
|||
<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 |
|||
name="lastname2" |
|||
attrs="{'required': [('firstname', '=', False), ('lastname', '=', False)]}" |
|||
/> |
|||
</field> |
|||
</field> |
|||
</field> |
|||
</record> |
|||
|
|||
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue