Skip to content

Commit

Permalink
[IMP] partner_firstname: adapt to partner_type_base changes
Browse files Browse the repository at this point in the history
  • Loading branch information
CRogos committed Nov 28, 2024
1 parent 07d9871 commit b159dba
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 41 deletions.
2 changes: 1 addition & 1 deletion partner_firstname/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"maintainer": "Camptocamp, Acsone",
"category": "Extra Tools",
"website": "https://github.com/OCA/partner-contact",
"depends": ["base_setup"],
"depends": ["base_setup", "partner_type_base"],
"post_init_hook": "post_init_hook",
"data": [
"views/base_config_view.xml",
Expand Down
5 changes: 5 additions & 0 deletions partner_firstname/migrations/18.0.1.2.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from odoo.upgrade import util


def migrate(cr, version):
util.force_install_module(cr, "partner_type_base")
52 changes: 12 additions & 40 deletions partner_firstname/views/res_partner.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,12 @@
<field name="inherit_id" ref="base.view_partner_simple_form" />
<field name="arch" type="xml">
<xpath expr="//field[@id='individual']" position="attributes">
<attribute name="invisible">is_company</attribute>
<attribute name="readonly">not is_company</attribute>
<attribute name="required">type == 'contact' and is_company</attribute>
</xpath>
<xpath expr="//field[@id='company']" position="attributes">
<attribute name="invisible">is_company == False</attribute>
<attribute name="readonly">not is_company</attribute>
<attribute name="required">type == 'contact' and is_company</attribute>
<attribute name="readonly">is_individual</attribute>
</xpath>
<xpath expr="//h1//field[@id='company']/.." position="before">
<group invisible="is_company">
<field
name="lastname"
required="not firstname and not is_company and type == 'contact'"
/>
<field
name="firstname"
required="not lastname and not is_company and type == 'contact'"
/>
<group invisible="not is_individual">
<field name="lastname" required="not firstname and is_individual" />
<field name="firstname" required="not lastname and is_individual" />
</group>
</xpath>
</field>
Expand All @@ -32,54 +19,39 @@
<field name="inherit_id" ref="base.view_partner_form" />
<field name="arch" type="xml">
<xpath expr="//field[@id='individual']" position="attributes">
<attribute name="invisible">is_company</attribute>
<attribute name="readonly">not is_company</attribute>
<attribute name="required">type == 'contact' and is_company</attribute>
</xpath>
<xpath expr="//field[@id='company']" position="attributes">
<attribute name="invisible">not is_company</attribute>
<attribute name="readonly">not is_company</attribute>
<attribute name="required">type == 'contact' and is_company</attribute>
<attribute name="readonly">is_individual</attribute>
</xpath>
<xpath
expr="//div[hasclass('oe_title')]//field[@id='company']/.."
position="after"
>
<div class="oe_edit_only">
<group invisible="is_company">
<group invisible="not is_individual">
<field
name="lastname"
required="not firstname and not is_company and type == 'contact'"
required="not firstname and is_individual"
/>
<field
name="firstname"
required="not lastname and not is_company and type == 'contact'"
required="not lastname and is_individual"
/>
</group>
</div>
</xpath>
<!-- Modify inner contact form of child_ids -->
<xpath
expr="//field[@name='child_ids']/form//field[@name='name']"
position="attributes"
>
<attribute name="readonly">not is_company</attribute>
<attribute name="required">is_company</attribute>
</xpath>

<xpath
expr="//field[@name='child_ids']/form//field[@name='name']"
position="after"
>
<div class="oe_edit_only" colspan="2">
<field name="is_company" invisible="True" />
<group invisible="is_company">
<group invisible="not is_individual">
<field
name="lastname"
required="not firstname and not is_company and type == 'contact'"
required="not firstname and is_individual"
/>
<field
name="firstname"
required="not lastname and not is_company and type == 'contact'"
required="not lastname and is_individual"
/>
</group>
</div>
Expand Down

0 comments on commit b159dba

Please sign in to comment.