Files
odoo_source/addons/crm/views/res_partner_views.xml
T
Hiral Bhavsar e28d3aa4d3 [IMP] crm: merge lead and opportunity form views
When redirecting to record, the wrong 'form' view will sometimes be
loaded. A 'hack' has been done in crm_lead.py to redirect the user to
the relevant 'form' view based on the value of the 'type' field.

However, this solution is not clean as it does not solve all cases
(multiple crm.lead records loaded from the activity systray, reloading
the page after redirection, etc.)

Goal of this task is to solve those issues by merging crm.lead.form.lead and
crm.lead.form.opportunity form views. That way multi records actions will
always display the relevant information according to record type.

Note: Here some fields used as a twice in the form view just to stay
close to the current design. Still few things which are not possible
here for 'lead' and 'opportunity', that is
* A dynamic 'placeholder' on 'name' field.
* A 'domain' on 'partner_id' field.
* A 'widget' on 'probability' field.

Task 47118

closes odoo/odoo#32248

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2019-08-20 08:38:52 +00:00

106 lines
5.4 KiB
XML

<?xml version="1.0"?>
<odoo>
<!-- open opportunities related to given partner -->
<record id="relate_partner_opportunities" model="ir.actions.act_window">
<field name="name">Opportunities</field>
<field name="res_model">crm.lead</field>
<field name="view_mode">kanban,tree,form,graph,calendar</field>
<field name="domain">[('type','=','opportunity')]</field>
<field name="context">{
'search_default_partner_id': active_id,
'default_type': 'opportunity'
}</field>
<field name="view_id" eval="False"/>
<field name="search_view_id" ref="crm.view_crm_case_opportunities_filter"/>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Create an new opportunity related to this customer
</p><p>
Use opportunities to keep track of your sales pipeline, follow
up potential sales and better forecast your future revenues.
</p><p>
You will be able to plan meetings and log activities from
opportunities, convert them into quotations, attach related
documents, track all discussions, and much more.
</p>
</field>
</record>
<record id="relate_partner_opportunities_kanban" model="ir.actions.act_window.view">
<field name="sequence" eval="0"/>
<field name="view_mode">kanban</field>
<field name="view_id" ref="crm_case_kanban_view_leads"/>
<field name="act_window_id" ref="relate_partner_opportunities"/>
</record>
<record id="relate_partner_opportunities_tree" model="ir.actions.act_window.view">
<field name="sequence" eval="1"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="crm_case_tree_view_oppor"/>
<field name="act_window_id" ref="relate_partner_opportunities"/>
</record>
<!-- Partner kanban view inherte -->
<record id="crm_lead_partner_kanban_view" model="ir.ui.view">
<field name="name">res.partner.kanban.inherit</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.res_partner_kanban_view"/>
<field name="priority" eval="10"/>
<field name="groups_id" eval="[(4, ref('sales_team.group_sale_salesman'))]"/>
<field name="arch" type="xml">
<field name="mobile" position="after">
<field name="opportunity_count"/>
<field name="meeting_count"/>
</field>
<xpath expr="//div[hasclass('oe_kanban_partner_links')]" position="inside">
<span class="badge badge-pill" t-if="record.opportunity_count.value>0"><i class="fa fa-fw fa-star" aria-label="Favorites" role="img" title="Favorites"/><t t-esc="record.opportunity_count.value"/></span>
<span class="badge badge-pill" t-if="record.meeting_count.value>0"><i class="fa fa-fw fa-calendar" aria-label="Meetings" role="img" title="Meetings"/><t t-esc="record.meeting_count.value"/></span>
</xpath>
</field>
</record>
<!-- tree view of crm.activity.report -->
<record id="crm_activity_report_view_tree" model="ir.ui.view">
<field name="name">crm.activity.report.tree</field>
<field name="model">crm.activity.report</field>
<field name="arch" type="xml">
<tree delete="false" create="false">
<field name="author_id"/>
<field name="subtype_id"/>
<field name="lead_id"/>
<field name="date"/>
</tree>
</field>
</record>
<!-- Add contextual button on partner form view -->
<record id="view_partners_form_crm1" model="ir.ui.view">
<field name="name">view.res.partner.form.crm.inherited1</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field eval="1" name="priority"/>
<field name="groups_id" eval="[(4, ref('sales_team.group_sale_salesman'))]"/>
<field name="arch" type="xml">
<data>
<div name="button_box" position="inside">
<button class="oe_stat_button o_res_partner_tip_opp" type="action"
name="%(crm.crm_lead_opportunities)d"
icon="fa-star"
groups="sales_team.group_sale_salesman"
context="{'search_default_partner_id': active_id}">
<field string="Opportunities" name="opportunity_count" widget="statinfo"/>
</button>
<button class="oe_stat_button" type="object"
name="schedule_meeting"
icon="fa-calendar"
groups="sales_team.group_sale_salesman"
context="{'partner_id': active_id, 'partner_name': name}">
<field string="Meetings" name="meeting_count" widget="statinfo"/>
</button>
</div>
</data>
</field>
</record>
</odoo>