Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][IMP] crm_partner_company_group: show company_group_id on list and form view #1949

Merged
merged 1 commit into from
Feb 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions crm_partner_company_group/views/opportunity_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,43 @@
</filter>
</field>
</record>
<record id="crm_lead_view_form" model="ir.ui.view">
<field name="name">crm.lead.form</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_lead_view_form" />
<field name="arch" type="xml">
<xpath
expr="//group[@name='opportunity_partner']/field[@name='partner_id']"
position="after"
>
<field name="company_group_id" invisible="not company_group_id" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not letting to assign it if not set?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The field is readonly and copied from the res.partner to crm.lead.

class CrmLead(models.Model):
    _inherit = "crm.lead"

    company_group_id = fields.Many2one(
        related="partner_id.company_group_id", store=True
    )

I agree that there a some interfaces, where you can change res.partner informations in the lead interface, but this is often not understood correctly by the users and they think they change something on this one lead, but they are actually change it on the linked contact for all leads.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, understood. Yes, it's OK this way then.

</xpath>
<xpath
expr="//group[@name='lead_partner']/field[@name='partner_id']"
position="after"
>
<field name="company_group_id" invisible="not company_group_id" />
</xpath>
</field>
</record>
<record id="crm_case_tree_view_oppor" model="ir.ui.view">
<field name="name">crm.lead.tree.opportunity</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_case_tree_view_oppor" />
<field name="arch" type="xml">
<field name="partner_id" position="after">
<field name="company_group_id" optional="hide" />
</field>
</field>
</record>
<record id="crm_case_tree_view_leads" model="ir.ui.view">
<field name="name">crm.lead.tree.lead</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_case_tree_view_leads" />
<field name="arch" type="xml">
<field name="partner_id" position="after">
<field name="company_group_id" optional="hide" />
</field>
</field>
</record>
</odoo>