Browse Source

[MIG] partner_firstname to v9.0

pull/206/head
Paulius Sladkevičius 9 years ago
parent
commit
b985c62143
  1. 2
      partner_firstname/__openerp__.py
  2. 5
      partner_firstname/models.py
  3. 39
      partner_firstname/views/res_partner.xml
  4. 18
      partner_firstname/views/res_user.xml

2
partner_firstname/__openerp__.py

@ -35,6 +35,6 @@
'demo': [], 'demo': [],
'test': [], 'test': [],
'auto_install': False, 'auto_install': False,
'installable': False,
'installable': True,
'images': [] 'images': []
} }

5
partner_firstname/models.py

@ -38,6 +38,11 @@ class ResPartner(models.Model):
required=False, required=False,
store=True) store=True)
# Disable sql name checking constraint
_sql_constraints = [
('check_name', 'check(1=1)', 'Contacts require a name.'),
]
@api.model @api.model
def _get_computed_name(self, lastname, firstname): def _get_computed_name(self, lastname, firstname):
"""Compute the 'name' field according to splitted data. """Compute the 'name' field according to splitted data.

39
partner_firstname/views/res_partner.xml

@ -42,45 +42,32 @@
}</attribute> }</attribute>
</xpath> </xpath>
<xpath expr="//field[@name='category_id']" position="before">
<group attrs="{'invisible': [('is_company', '=', True)]}">
<xpath expr="//field[@name='parent_id']/.." position="before">
<div attrs="{'invisible': [('is_company', '=', True)]}">
<label for="lastname" string="Lastname"/>
<field name="lastname" attrs= <field name="lastname" attrs=
"{'required': [('firstname', '=', False), "{'required': [('firstname', '=', False),
('is_company', '=', False)]}"/>
('is_company', '=', False)]}" class="oe_inline"/><br/>
<label for="firstname" string="Firstname"/>
<field name="firstname" attrs= <field name="firstname" attrs=
"{'required': [('lastname', '=', False), "{'required': [('lastname', '=', False),
('is_company', '=', False)]}"/>
</group>
('is_company', '=', False)]}" class="oe_inline"/>
</div>
</xpath> </xpath>
<!-- Modify inner contact form of child_ids --> <!-- Modify inner contact form of child_ids -->
<xpath expr="//field[@name='child_ids']/form <xpath expr="//field[@name='child_ids']/form
//field[@name='category_id']"
//field[@name='name']"
position="before"> position="before">
<group attrs="{'invisible': [('is_company', '=', True)]}">
<field name="is_company"/>
<field name="lastname" attrs= <field name="lastname" attrs=
"{'required': [('firstname', '=', False), "{'required': [('firstname', '=', False),
('is_company', '=', False)]}"/>
('is_company', '=', False)],
'invisible': [('is_company', '=', True)]}"/>
<field name="firstname" attrs= <field name="firstname" attrs=
"{'required': [('lastname', '=', False), "{'required': [('lastname', '=', False),
('is_company', '=', False)]}"/>
</group>
</xpath>
<xpath expr="//field[@name='child_ids']/form
//field[@name='category_id']"
position="attributes">
<attribute name="style"/>
</xpath>
<xpath expr="//field[@name='child_ids']/form//label[@for='name']"
position="before">
<div class="oe_edit_only">
<field name="is_company"
on_change="onchange_type(is_company)"/>
<label for="is_company"
string="Is a Company?"/>
</div>
('is_company', '=', False)],
'invisible': [('is_company', '=', True)]}"/>
</xpath> </xpath>
<xpath expr="//field[@name='child_ids']/form//field[@name='name']" <xpath expr="//field[@name='child_ids']/form//field[@name='name']"

18
partner_firstname/views/res_user.xml

@ -2,10 +2,6 @@
<openerp> <openerp>
<data> <data>
<!-- 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" />
<record id="view_users_form" model="ir.ui.view"> <record id="view_users_form" model="ir.ui.view">
<field name="name">Add firstname and surnames</field> <field name="name">Add firstname and surnames</field>
<field name="model">res.users</field> <field name="model">res.users</field>
@ -17,12 +13,14 @@
</xpath> </xpath>
<xpath expr="//field[@name='email']" position="after"> <xpath expr="//field[@name='email']" position="after">
<group>
<field name="lastname"
attrs="{'required': [('firstname', '=', False)]}"/>
<field name="firstname"
attrs="{'required': [('lastname', '=', False)]}"/>
</group>
<div>
<label for="lastname" string="Lastname"/>
<field name="lastname" attrs=
"{'required': [('firstname', '=', False)]}" class="oe_inline"/><br/>
<label for="firstname" string="Firstname"/>
<field name="firstname" attrs=
"{'required': [('lastname', '=', False)]}" class="oe_inline"/>
</div>
</xpath> </xpath>
</data> </data>
</field> </field>

Loading…
Cancel
Save