[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>
This commit is contained in:
Hiral Bhavsar
2019-08-20 08:38:52 +00:00
committed by Thibault Delavallée
parent b63b8e0a11
commit e28d3aa4d3
11 changed files with 288 additions and 465 deletions
+5 -43
View File
@@ -965,48 +965,17 @@ class Lead(models.Model):
lead.write(value)
return True
def redirect_opportunity_view(self):
def redirect_lead_opportunity_view(self):
self.ensure_one()
# Get opportunity views
form_view = self.env.ref('crm.crm_case_form_view_oppor')
tree_view = self.env.ref('crm.crm_case_tree_view_oppor')
return {
'name': _('Opportunity'),
'view_mode': 'tree, form',
'name': _('Lead or Opportunity'),
'view_mode': 'form',
'res_model': 'crm.lead',
'domain': [('type', '=', 'opportunity')],
'domain': [('type', '=', self.type)],
'res_id': self.id,
'view_id': False,
'views': [
(form_view.id, 'form'),
(tree_view.id, 'tree'),
(False, 'kanban'),
(False, 'calendar'),
(False, 'graph')
],
'type': 'ir.actions.act_window',
'context': {'default_type': 'opportunity'}
}
def redirect_lead_view(self):
self.ensure_one()
# Get lead views
form_view = self.env.ref('crm.crm_case_form_view_leads')
tree_view = self.env.ref('crm.crm_case_tree_view_leads')
return {
'name': _('Lead'),
'view_mode': 'tree, form',
'res_model': 'crm.lead',
'domain': [('type', '=', 'lead')],
'res_id': self.id,
'view_id': False,
'views': [
(form_view.id, 'form'),
(tree_view.id, 'tree'),
(False, 'calendar'),
(False, 'graph')
],
'type': 'ir.actions.act_window',
'context': {'default_type': self.type}
}
@api.model
@@ -1221,13 +1190,6 @@ class Lead(models.Model):
res.update(super(Lead, leftover)._notify_get_reply_to(default=default, records=None, company=company, doc_names=doc_names))
return res
def get_formview_id(self, access_uid=None):
if self.type == 'opportunity':
view_id = self.env.ref('crm.crm_case_form_view_oppor').id
else:
view_id = super(Lead, self).get_formview_id()
return view_id
def _message_get_default_recipients(self):
return {r.id: {
'partner_ids': [],
@@ -115,8 +115,7 @@
eval="[(5, 0, 0),
(0, 0, {'view_mode': 'graph', 'view_id': ref('crm_opportunity_report_view_graph')}),
(0, 0, {'view_mode': 'pivot', 'view_id': ref('crm_opportunity_report_view_pivot')}),
(0, 0, {'view_mode': 'tree', 'view_id': ref('crm_case_tree_view_oppor')}),
(0, 0, {'view_mode': 'form', 'view_id': ref('crm_case_form_view_oppor')})]"/>
(0, 0, {'view_mode': 'tree', 'view_id': ref('crm_case_tree_view_oppor')})]"/>
<field name="help">Pipeline Analysis gives you an instant access to
your opportunities with information such as the expected revenue, planned cost,
missed deadlines or the number of interactions per opportunity. This report is
+2 -2
View File
@@ -63,12 +63,12 @@ tour.register('crm_tour', {
actions.auto(".o_kanban_record .oe_kanban_action[data-type=edit]");
},
}, {
trigger: ".o_opportunity_form .o_chatter_button_new_message",
trigger: ".o_lead_opportunity_form .o_chatter_button_new_message",
content: _t('<p><b>Send messages</b> to your prospect and get replies automatically attached to this opportunity.</p><p class="mb0">Type <i>\'@\'</i> to mention people - it\'s like cc-ing on emails.</p>'),
position: "bottom"
}, {
trigger: ".breadcrumb-item:not(.active):last",
extra_trigger: '.o_opportunity_form',
extra_trigger: '.o_lead_opportunity_form',
content: _t("Use the breadcrumbs to <b>go back to your sales pipeline</b>."),
position: "bottom"
}, tour.STEPS.TOGGLE_HOME_MENU, tour.STEPS.SHOW_APPS_MENU_ITEM, {
+259 -338
View File
@@ -38,6 +38,265 @@
</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="arch" type="xml">
<form class="o_lead_opportunity_form">
<header>
<button name="action_set_won_rainbowman" string="Mark Won"
type="object" class="oe_highlight"
attrs="{'invisible': ['|','|', ('active','=',False), ('probability', '=', 100), ('type', '=', 'lead')]}"/>
<button name="%(crm.crm_lead_lost_action)d" string="Mark Lost"
type="action" class="oe_highlight" context="{'default_lead_id': active_id}" attrs="{'invisible': ['|', ('type', '=', 'lead'),('active', '=', False),('probability', '&lt;', 100)]}"/>
<button name="%(crm.action_crm_lead2opportunity_partner)d" string="Convert to Opportunity" type="action" help="Convert to Opportunity"
class="oe_highlight" attrs="{'invisible': ['|', ('type', '=', 'opportunity'), ('active', '=', False)]}"/>
<button name="toggle_active" string="Restore" type="object"
attrs="{'invisible': ['|', ('probability', '&gt;', 0), ('active', '=', True)]}"/>
<button name="action_set_lost" string="Mark as Lost" type="object"
attrs="{'invisible': ['|', ('type', '=', 'opportunity'), '&amp;', ('probability', '=', 0), ('active', '=', False)]}"/>
<field name="stage_id" widget="statusbar"
options="{'clickable': '1', 'fold_field': 'fold'}"
domain="['|', ('team_id', '=', team_id), ('team_id', '=', False)]"
attrs="{'invisible': ['|', ('active', '=', False), ('type', '=', 'lead')]}"/>
</header>
<sheet>
<field name="active" invisible="1"/>
<div class="oe_button_box" name="button_box">
<button class="oe_stat_button" type="object" context="{'partner_id': partner_id}" name="action_schedule_meeting" icon="fa-calendar" attrs="{'invisible': [('type', '=', 'lead')]}">
<div class="o_stat_info">
<field name="meeting_count" class="o_stat_value"/>
<span class="o_stat_text" attrs="{'invisible': [('meeting_count', '&lt;', 2)]}"> Meetings</span>
<span class="o_stat_text" attrs="{'invisible': [('meeting_count', '&gt;', 1)]}"> Meeting</span>
</div>
</button>
</div>
<widget name="web_ribbon" text="Lost" bg_color="bg-danger" attrs="{'invisible': ['|', ('probability', '&gt;', 0), ('active', '=', True)]}"/>
<widget name="web_ribbon" text="Won" attrs="{'invisible': [('probability', '&lt;', 100)]}" />
<div class="oe_title">
<label for="name" class="oe_edit_only" string="Lead" attrs="{'invisible': [('type', '=', 'opportunity')]}"/>
<label for="name" class="oe_edit_only" attrs="{'invisible': [('type', '=', 'lead')]}"/>
<h1><field name="name" placeholder="e.g. Product Pricing"/></h1>
<h2 class="o_row row no-gutters d-flex">
<div class="col" attrs="{'invisible': [('type', '=', 'lead')]}">
<label for="planned_revenue" class="oe_edit_only" />
<div class="o_row">
<field name="company_currency" invisible="1"/>
<field name="planned_revenue" class="oe_inline" widget='monetary' options="{'currency_field': 'company_currency'}"/>
<span class="oe_grey p-2"> at </span>
</div>
</div>
<div class="col">
<span class="oe_edit_only o_pls_probability">
<label for="probability"/>
<button class="btn btn-link" name="action_set_automated_probability" type="object"
attrs="{'invisible': [('is_automated_probability', '=', True)]}">
<i class="fa fa-gear" role="img" title="Switch to automatic probability" aria-label="Switch to automatic probability"></i>
</button>
<small class="oe_grey" attrs="{'invisible': [('is_automated_probability', '=', True)]}"><field name="automated_probability"/> %%</small>
</span>
<div id="probability" class="o_row d-flex">
<field name="is_automated_probability" invisible="1"/>
<field name="probability" widget="float" class="oe_inline"/>
<span class="oe_grey"> %%</span>
</div>
</div>
</h2>
</div>
<group>
<group attrs="{'invisible': [('type', '=', 'opportunity')]}">
<!-- Preload all the partner's information -->
<field name="partner_id" widget="res_partner_many2one"
context="{'default_name': contact_name,
'default_street': street,
'default_city': city,
'default_state_id': state_id,
'default_zip': zip,
'default_country_id': country_id,
'default_function': function,
'default_phone': phone,
'default_mobile': mobile,
'default_email': email_from,
'default_user_id': user_id,
'default_team_id': team_id,
'default_website': website,
'show_vat': True
}" groups="base.group_no_one"/>
<field name="partner_name"/>
<label for="street" string="Address"/>
<div class="o_address_format">
<field name="street" placeholder="Street..." class="o_address_street"/>
<field name="street2" placeholder="Street 2..." class="o_address_street"/>
<field name="city" placeholder="City" class="o_address_city"/>
<field name="state_id" class="o_address_state" placeholder="State" options='{"no_open": True}'/>
<field name="zip" placeholder="ZIP" class="o_address_zip"/>
<field name="country_id" placeholder="Country" class="o_address_country" options='{"no_open": True, "no_create": True}'/>
</div>
<field name="website" widget="url" placeholder="e.g. https://www.odoo.com"/>
<field name="lang_id"/>
</group>
<group attrs="{'invisible': [('type', '=', 'lead')]}">
<field name="partner_id"
widget="res_partner_many2one"
string="Customer"
context="{'res_partner_search_mode': type == 'opportunity' and 'customer' or False,
'default_name': contact_name or partner_name,
'default_street': street,
'default_is_company': type == 'opportunity' and contact_name == False,
'default_company_name': type == 'opportunity' and partner_name,
'default_street2': street2,
'default_city': city,
'default_title': title,
'default_state_id': state_id,
'default_zip': zip,
'default_country_id': country_id,
'default_function': function,
'default_phone': phone,
'default_mobile': mobile,
'default_email': email_from,
'default_user_id': user_id,
'default_team_id': team_id,
'default_website': website,
'show_vat': True,
}"
/>
<field name="is_blacklisted" invisible="1"/>
<field name="partner_is_blacklisted" invisible="1"/>
<field name="email_state" invisible="1"/>
<field name="phone_state" invisible="1"/>
<label for="email_from" class="oe_inline"/>
<div class="o_row o_row_readonly">
<i class="fa fa-ban" style="color: red;" role="img" title="This email is blacklisted for mass mailing"
aria-label="Blacklisted" attrs="{'invisible': ['|', ('is_blacklisted', '=', False), ('partner_address_email', '!=', False)]}" groups="base.group_user"/>
<field name="email_from"
attrs="{'invisible': [('partner_address_email', '!=', False)]}" string="Email" widget="email"/>
<i class="fa fa-ban" style="color: red;" role="img" title="This email is blacklisted for mass mailing"
aria-label="Blacklisted" attrs="{'invisible': ['|', ('partner_is_blacklisted', '=', False), ('partner_address_email', '=', False)]}" groups="base.group_user"/>
<field name="partner_address_email"
attrs="{'invisible': [('partner_address_email', '==', False)]}" widget="email" string="Email"/>
</div>
<field name="partner_address_phone"
attrs="{'invisible': [('partner_address_phone', '==', False)]}" readonly="1" widget="phone" string="Phone"/>
<field name="phone"
attrs="{'invisible': [('partner_address_phone', '!=', False)]}" widget="phone"/>
</group>
<group attrs="{'invisible': [('type', '=', 'opportunity')]}">
<label for="contact_name"/>
<div class="o_row">
<field name="contact_name"/>
<field name="title" placeholder="Title" domain="[]" options='{"no_open": True}'/>
</div>
<field name="is_blacklisted" invisible="1"/>
<field name="email_state" invisible="1"/>
<field name="phone_state" invisible="1"/>
<label for="email_from" class="oe_inline"/>
<div class="o_row o_row_readonly">
<i class="fa fa-ban" style="color: red;" role="img" title="This email is blacklisted for mass mailing"
aria-label="Blacklisted" attrs="{'invisible': [('is_blacklisted', '=', False)]}" groups="base.group_user"/>
<field name="email_from" widget="email"/>
</div>
<field name="email_cc" groups="base.group_no_one"/>
<field name="function"/>
<field name="phone" widget="phone"/>
<field name="mobile"/>
</group>
<group attrs="{'invisible': [('type', '=', 'lead')]}">
<field name="date_deadline"/>
<field name="priority" widget="priority"/>
<field name="tag_ids" widget="many2many_tags" options="{'color_field': 'color', 'no_create_edit': True}"/>
</group>
<group>
<field name="user_id" domain="[('share', '=', False)]"
context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'sales_team.group_sale_salesman_all_leads'], 'team_id': team_id}"/>
<field name="team_id" widget="selection"
domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]"/>
<field name="type" invisible="1"/>
</group>
<group name="lead_priority" attrs="{'invisible': [('type', '=', 'opportunity')]}">
<field name="priority" widget="priority"/>
<field name="tag_ids" widget="many2many_tags" options="{'color_field': 'color', 'no_create_edit': True}"/>
</group>
<group attrs="{'invisible': [('type', '=', 'lead')]}">
<field name="lost_reason" attrs="{'invisible': [('active', '=', True)]}"/>
<field name="date_conversion" invisible="1"/>
<field name="company_id" groups="base.group_multi_company"/>
</group>
</group>
<notebook>
<page string="Internal Notes">
<field name="description" placeholder="Add a description..."/>
</page>
<page name="extra" string="Extra Info" attrs="{'invisible': [('type', '=', 'opportunity')]}">
<group>
<group string="Email" groups="base.group_no_one">
<field name="message_bounce" readonly="1"/>
</group>
<group string="Tracking" groups="base.group_multi_company" name="categorization">
<field name="company_id"
options="{'no_create': True}"/>
<field name="campaign_id" />
<field name="medium_id"/>
<field name="source_id"/>
<field name="referred"/>
</group>
<group string="Analysis">
<field name="date_open"/>
<field name="date_closed"/>
<field name="probability"/>
</group>
</group>
</page>
<page name="lead" string="Followup" attrs="{'invisible': [('type', '=', 'lead')]}">
<group>
<group string="Contact Information">
<field name="partner_name"/>
<label for="street" string="Address"/>
<div class="o_address_format">
<field name="street" placeholder="Street..." class="o_address_street"/>
<field name="street2" placeholder="Street 2..." class="o_address_street"/>
<field name="city" placeholder="City" class="o_address_city"/>
<field name="state_id" class="o_address_state" placeholder="State" options='{"no_open": True}'/>
<field name="zip" placeholder="ZIP" class="o_address_zip"/>
<field name="country_id" placeholder="Country" class="o_address_country" options='{"no_open": True, "no_create": True}'/>
</div>
<field name="website" widget="url" placeholder="e.g. https://www.odoo.com"/>
<field name="lang_id"/>
</group>
<group class="mt48">
<label for="contact_name"/>
<div class="o_row">
<field name="contact_name"/>
<field name="title" placeholder="Title" domain="[]" options='{"no_open": True}'/>
</div>
<field name="function"/>
<field name="mobile"/>
</group>
<group string="Marketing">
<field name="campaign_id" />
<field name="medium_id" />
<field name="source_id" />
</group>
<group string="Misc" name="Misc">
<field name="day_open" groups="base.group_no_one"/>
<field name="day_close" groups="base.group_no_one"/>
<field name="referred"/>
<field name="type" invisible="1"/>
</group>
</group>
</page>
</notebook>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers"/>
<field name="activity_ids" widget="mail_activity"/>
<field name="message_ids" widget="mail_thread" options="{'post_refresh': 'recipients'}"/>
</div>
</form>
</field>
</record>
<!--
crm.lead (as Lead) views
-->
@@ -48,136 +307,6 @@
view_mode="tree,form,calendar"
context="{'default_duration': 4.0, 'default_opportunity_id': active_id}"/>
<record id="crm_case_form_view_leads" model="ir.ui.view">
<field name="name">crm.lead.form.lead</field>
<field name="model">crm.lead</field>
<field name="arch" type="xml">
<form string="Leads Form">
<header>
<button name="%(crm.action_crm_lead2opportunity_partner)d" string="Convert to Opportunity" type="action"
help="Convert to Opportunity" class="oe_highlight" attrs="{'invisible': ['|', ('type', '=', 'opportunity'), ('active', '=', False)]}"/>
<button name="toggle_active"
string="Restore"
type="object"
attrs="{'invisible': ['|', ('probability', '&gt;', 0), ('active', '=', True)]}"/>
<button name="action_set_lost"
string="Mark as Lost"
type="object"
attrs="{'invisible': ['&amp;', ('probability', '=', 0), ('active', '=', False)]}"/>
</header>
<sheet>
<field name="active" invisible="1"/>
<div class="oe_button_box" name="button_box"/>
<widget name="web_ribbon" text="Lost" bg_color="bg-danger" attrs="{'invisible': ['|', ('probability', '&gt;', 0), ('active', '=', True)]}"/>
<widget name="web_ribbon" text="Won" attrs="{'invisible': [('probability', '&lt;', 100)]}" />
<div class="oe_title">
<label for="name" class="oe_edit_only" string="Lead"/>
<h1><field name="name" placeholder="Describe the lead..."/></h1>
<h2 class="o_row row no-gutters d-flex">
<div class="col">
<span class="oe_edit_only o_pls_probability">
<label for="probability"/>
<button class="btn btn-link" name="action_set_automated_probability" type="object"
attrs="{'invisible': [('is_automated_probability', '=', True)]}">
<i class="fa fa-gear" role="img" title="Switch to automatic probability" aria-label="Switch to automatic probability"></i>
</button>
<small class="oe_grey" attrs="{'invisible': [('is_automated_probability', '=', True)]}"><field name="automated_probability"/> %%</small>
</span>
<div id="probability" class="o_row d-flex">
<field name="is_automated_probability" invisible="1"/>
<field name="probability" widget="float" class="oe_inline"/>
<span class="oe_grey"> %%</span>
</div>
</div>
</h2>
</div>
<group>
<group>
<!-- Preload all the partner's information -->
<field name="partner_id"
widget="res_partner_many2one"
context="{'default_name': contact_name, 'default_street': street, 'default_city': city, 'default_state_id': state_id, 'default_zip': zip, 'default_country_id': country_id, 'default_function': function, 'default_phone': phone, 'default_mobile': mobile, 'default_email': email_from, 'default_user_id': user_id, 'default_team_id': team_id, 'default_website': website, 'show_vat': True}"
groups="base.group_no_one"/>
<field name="partner_name"/>
<label for="street" string="Address"/>
<div class="o_address_format">
<field name="street" placeholder="Street..." class="o_address_street"/>
<field name="street2" placeholder="Street 2..." class="o_address_street"/>
<field name="city" placeholder="City" class="o_address_city"/>
<field name="state_id" class="o_address_state" placeholder="State" options='{"no_open": True}'/>
<field name="zip" placeholder="ZIP" class="o_address_zip"/>
<field name="country_id" placeholder="Country" class="o_address_country" options='{"no_open": True, "no_create": True}'/>
</div>
<field name="website" widget="url" placeholder="e.g. https://www.odoo.com"/>
<field name="lang_id"/>
</group>
<group>
<label for="contact_name"/>
<div class="o_row">
<field name="contact_name"/>
<field name="title" placeholder="Title" domain="[]" options='{"no_open": True}'/>
</div>
<field name="is_blacklisted" invisible="1"/>
<field name="email_state" invisible="1"/>
<field name="phone_state" invisible="1"/>
<label for="email_from" class="oe_inline"/>
<div class="o_row o_row_readonly">
<i class="fa fa-ban" style="color: red;" role="img" title="This email is blacklisted for mass mailing"
aria-label="Blacklisted" attrs="{'invisible': [('is_blacklisted', '=', False)]}" groups="base.group_user"></i>
<field name="email_from" widget="email"/>
</div>
<field name="email_cc" groups="base.group_no_one"/>
<field name="function"/>
<field name="phone" widget="phone" options="{'enable_sms': True}"/>
<field name="mobile" widget="phone" options="{'enable_sms': True}"/>
</group>
<group>
<field name="user_id" domain="[('share', '=', False)]"
context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'sales_team.group_sale_salesman_all_leads'], 'team_id': team_id}"/>
<field name="team_id" widget="selection" domain="[('use_leads','=',True),'|', ('company_id', '=', False), ('company_id', '=', company_id)]"/>
<field name="type" invisible="1"/>
</group>
<group>
<field name="priority" widget="priority"/>
<field name="tag_ids" widget="many2many_tags" options="{'color_field': 'color', 'no_create_edit': True}"/>
</group>
</group>
<notebook>
<page string="Internal Notes">
<field name="description"/>
</page>
<page name="extra" string="Extra Info">
<group>
<group string="Email" groups="base.group_no_one">
<field name="message_bounce" readonly="1"/>
</group>
<group string="Tracking" groups="base.group_multi_company" name="categorization">
<field name="company_id"
groups="base.group_multi_company"
options="{'no_create': True}"/>
<field name="campaign_id" />
<field name="medium_id"/>
<field name="source_id"/>
<field name="referred"/>
</group>
<group string="Analysis">
<field name="date_open"/>
<field name="date_closed"/>
<field name="probability"/>
</group>
</group>
</page>
</notebook>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers"/>
<field name="activity_ids" widget="mail_activity"/>
<field name="message_ids" widget="mail_thread" options="{'post_refresh': 'recipients'}"/>
</div>
</form>
</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>
@@ -442,200 +571,6 @@
<!--
crm.lead (as Opportunity) views
-->
<record id="crm_case_form_view_oppor" model="ir.ui.view">
<field name="name">crm.lead.form.opportunity</field>
<field name="model">crm.lead</field>
<field name="priority">20</field>
<field name="arch" type="xml">
<form string="Opportunities" class="o_opportunity_form">
<header>
<button name="action_set_won_rainbowman" string="Mark Won"
type="object" class="oe_highlight"
attrs="{'invisible': ['|', ('active','=',False), ('probability', '=', 100)]}"/>
<button name="%(crm.crm_lead_lost_action)d" string="Mark Lost"
type="action" class="oe_highlight"
context="{'default_lead_id': active_id}"
attrs="{'invisible': [('active', '=', False),('probability', '&lt;', 100)]}"/>
<button name="toggle_active"
string="Restore"
type="object"
attrs="{'invisible': ['|', ('probability', '&gt;', 0), ('active', '=', True)]}"/>
<field name="stage_id" widget="statusbar"
options="{'clickable': '1', 'fold_field': 'fold'}"
domain="['|', ('team_id', '=', team_id), ('team_id', '=', False)]"
attrs="{'invisible': [('active', '=', False)]}"/>
</header>
<sheet>
<field name="active" invisible="1"/>
<div class="oe_button_box" name="button_box">
<button class="oe_stat_button" type="object"
context="{'partner_id': partner_id}"
name="action_schedule_meeting" icon="fa-calendar">
<div class="o_stat_info">
<field name="meeting_count" class="o_stat_value"/>
<span class="o_stat_text" attrs="{'invisible': [('meeting_count', '&lt;', 2)]}"> Meetings</span>
<span class="o_stat_text" attrs="{'invisible': [('meeting_count', '&gt;', 1)]}"> Meeting</span>
</div>
</button>
</div>
<widget name="web_ribbon" text="Lost" bg_color="bg-danger" attrs="{'invisible': ['|', ('probability', '&gt;', 0), ('active', '=', True)]}" />
<widget name="web_ribbon" text="Won" attrs="{'invisible': [('probability', '&lt;', 100)]}" />
<div class="oe_title">
<label for="name" class="oe_edit_only"/>
<h1><field name="name" placeholder="e.g. Product Pricing"/></h1>
<h2 class="o_row row no-gutters d-flex">
<div class="col">
<label for="planned_revenue" class="oe_edit_only" />
<div class="o_row">
<field name="company_currency" invisible="1"/>
<field name="planned_revenue" class="oe_inline" widget='monetary' options="{'currency_field': 'company_currency'}"/>
<span class="oe_grey p-2"> at </span>
</div>
</div>
<div class="col">
<span class="oe_edit_only o_pls_probability">
<label for="probability"/>
<button class="btn btn-link" name="action_set_automated_probability" type="object"
attrs="{'invisible': [('is_automated_probability', '=', True)]}">
<i class="fa fa-gear" role="img" title="Switch to automatic probability" aria-label="Switch to automatic probability"></i>
</button>
<small class="oe_grey" attrs="{'invisible': [('is_automated_probability', '=', True)]}"><field name="automated_probability"/> %%</small>
</span>
<div id="probability" class="o_row d-flex">
<field name="is_automated_probability" invisible="1"/>
<field name="probability" widget="float" class="oe_inline"/>
<span class="oe_grey"> %%</span>
</div>
</div>
</h2>
</div>
<group>
<group>
<field name="partner_id"
widget="res_partner_many2one"
string="Customer"
context="{'res_partner_search_mode': 'customer',
'default_name': contact_name or partner_name,
'default_street': street,
'default_is_company': contact_name == False,
'default_company_name': partner_name,
'default_street2': street2,
'default_city': city,
'default_title': title,
'default_state_id': state_id,
'default_zip': zip,
'default_country_id': country_id,
'default_function': function,
'default_phone': phone,
'default_mobile': mobile,
'default_email': email_from,
'default_user_id': user_id,
'default_team_id': team_id,
'default_website': website,
'show_vat': True,
}"
/>
<field name="is_blacklisted" invisible="1"/>
<field name="partner_is_blacklisted" invisible="1"/>
<field name="email_state" invisible="1"/>
<field name="phone_state" invisible="1"/>
<label for="email_from" class="oe_inline"/>
<div class="o_row o_row_readonly">
<i class="fa fa-ban" style="color: red;" role="img" title="This email is blacklisted for mass mailing"
aria-label="Blacklisted" attrs="{'invisible': ['|', ('is_blacklisted', '=', False), ('partner_address_email', '!=', False)]}" groups="base.group_user"></i>
<field name="email_from"
attrs="{'invisible': [('partner_address_email', '!=', False)]}"
string="Email"
widget="email"/>
<i class="fa fa-ban" style="color: red;" role="img" title="This email is blacklisted for mass mailing"
aria-label="Blacklisted" attrs="{'invisible': ['|', ('partner_is_blacklisted', '=', False), ('partner_address_email', '=', False)]}" groups="base.group_user"></i>
<field name="partner_address_email"
attrs="{'invisible': [('partner_address_email', '==', False)]}"
widget="email"
string="Email"/>
</div>
<field name="partner_address_phone"
attrs="{'invisible': [('partner_address_phone', '==', False)]}"
readonly="1"
widget="phone"
string="Phone"
options="{'enable_sms': True}"/>
<field name="phone"
attrs="{'invisible': [('partner_address_phone', '!=', False)]}"
widget="phone"
options="{'enable_sms': True}"/>
</group>
<group>
<field name="date_deadline"/>
<field name="priority" widget="priority"/>
<field name="tag_ids" widget="many2many_tags" options="{'color_field': 'color', 'no_create_edit': True}"/>
</group>
<group>
<field name="user_id" context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'sales_team.group_sale_salesman_all_leads'], 'team_id': team_id}" domain="[('share', '=', False)]"/>
<field name="team_id" widget="selection" domain="[('use_opportunities', '=', True), '|', ('company_id', '=', False), ('company_id', '=', company_id)]"/>
</group>
<group>
<field name="lost_reason" attrs="{'invisible': [('active', '=', True)]}"/>
<field name="date_conversion" invisible="1"/>
<field name="company_id" groups="base.group_multi_company"/>
</group>
</group>
<notebook colspan="4">
<page string="Internal Notes">
<field name="description" placeholder="Add a description..."/>
</page>
<page name="lead" string="Followup">
<group>
<group string="Contact Information">
<field name="partner_name"/>
<label for="street" string="Address"/>
<div class="o_address_format">
<field name="street" placeholder="Street..." class="o_address_street"/>
<field name="street2" placeholder="Street 2..." class="o_address_street"/>
<field name="city" placeholder="City" class="o_address_city"/>
<field name="state_id" class="o_address_state" placeholder="State" options='{"no_open": True}'/>
<field name="zip" placeholder="ZIP" class="o_address_zip"/>
<field name="country_id" placeholder="Country" class="o_address_country" options='{"no_open": True, "no_create": True}'/>
</div>
<field name="website" widget="url" placeholder="e.g. https://www.odoo.com"/>
<field name="lang_id" />
</group>
<group class="mt48">
<label for="contact_name"/>
<div class="o_row">
<field name="contact_name"/>
<field name="title" placeholder="Title" domain="[]" options='{"no_open": True}'/>
</div>
<field name="function"/>
<field name="mobile" widget="phone" options="{'enable_sms': True}"/>
</group>
<group string="Marketing">
<field name="campaign_id" />
<field name="medium_id" />
<field name="source_id" />
</group>
<group string="Misc" name="Misc">
<field name="day_open" groups="base.group_no_one"/>
<field name="day_close" groups="base.group_no_one"/>
<field name="referred"/>
<field name="type" invisible="1"/>
</group>
</group>
</page>
</notebook>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers"/>
<field name="activity_ids" widget="mail_activity"/>
<field name="message_ids" widget="mail_thread" options="{'post_refresh': 'recipients'}"/>
</div>
</form>
</field>
</record>
<record id="crm_case_tree_view_oppor" model="ir.ui.view">
<field name="name">crm.lead.tree.opportunity</field>
@@ -982,13 +917,6 @@ if record:
<field name="act_window_id" ref="crm_lead_opportunities"/>
</record>
<record id="crm_lead_opportunities_view_form" model="ir.actions.act_window.view">
<field name="sequence" eval="2"/>
<field name="view_mode">form</field>
<field name="view_id" ref="crm_case_form_view_oppor"/>
<field name="act_window_id" ref="crm_lead_opportunities"/>
</record>
<record id="crm_lead_opportunities_view_graph" model="ir.actions.act_window.view">
<field name="sequence" eval="3"/>
<field name="view_mode">graph</field>
@@ -1057,13 +985,6 @@ if record:
<field name="act_window_id" ref="crm_lead_opportunities_tree_view"/>
</record>
<record id="crm_lead_opportunities_tree_view_view_form" model="ir.actions.act_window.view">
<field name="sequence" eval="4"/>
<field name="view_mode">form</field>
<field name="view_id" ref="crm_case_form_view_oppor"/>
<field name="act_window_id" ref="crm_lead_opportunities_tree_view"/>
</record>
<record id="crm_lead_opportunities_tree_view_view_graph" model="ir.actions.act_window.view">
<field name="sequence" eval="5"/>
<field name="view_mode">graph</field>
+2 -9
View File
@@ -91,7 +91,7 @@
<field name="res_model">crm.lead</field>
<field name="view_mode">graph,pivot,tree,form</field>
<field name="search_view_id" ref="crm.crm_opportunity_report_view_search"/>
<field name="context">{'search_default_team_id': [active_id], 'form_view_ref': 'crm.crm_case_form_view_oppor', 'tree_view_ref': 'crm.crm_case_tree_view_oppor','search_default_opportunity': True, 'time_ranges': {'field':'create_date', 'range':'last_365_days'}}</field>
<field name="context">{'search_default_team_id': [active_id], 'tree_view_ref': 'crm.crm_case_tree_view_oppor','search_default_opportunity': True, 'time_ranges': {'field':'create_date', 'range':'last_365_days'}}</field>
<field name="domain">[]</field>
<field name="help">Opportunities Analysis gives you an instant access to your opportunities with information such as the expected revenue, planned cost, missed deadlines or the number of interactions per opportunity. This report is mainly used by the sales manager in order to do the periodic review with the channels of the sales pipeline.</field>
</record>
@@ -149,13 +149,6 @@
<field name="act_window_id" ref="crm_case_form_view_salesteams_opportunity"/>
</record>
<record id="action_crm_tag_form_view_salesteams_oppor11" model="ir.actions.act_window.view">
<field name="sequence" eval="2"/>
<field name="view_mode">form</field>
<field name="view_id" ref="crm_case_form_view_oppor"/>
<field name="act_window_id" ref="crm_case_form_view_salesteams_opportunity"/>
</record>
<record id="crm_team_act_tree" model="ir.actions.act_window">
<field name="name">Cases by Sales Team</field>
<field name="res_model">crm.team</field>
@@ -167,7 +160,7 @@
<field name="res_model">crm.lead</field>
<field name="type">ir.actions.act_window</field>
<field name="view_mode">form</field>
<field name="view_id" ref="crm_case_form_view_oppor"/>
<field name="view_id" ref="crm_lead_view_form"/>
<field name="domain">[('type','=','opportunity')]</field>
<field name="context">{
'search_default_team_id': [active_id],
-7
View File
@@ -41,13 +41,6 @@
<field name="act_window_id" ref="relate_partner_opportunities"/>
</record>
<record id="relate_partner_opportunities_form" model="ir.actions.act_window.view">
<field name="sequence" eval="2"/>
<field name="view_mode">form</field>
<field name="view_id" ref="crm_case_form_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>
+1 -1
View File
@@ -136,7 +136,7 @@ class Lead2OpportunityPartner(models.TransientModel):
values.update({'lead_ids': leads.ids, 'user_ids': [self.user_id.id]})
self._convert_opportunity(values)
return leads[0].redirect_opportunity_view()
return leads[0].redirect_lead_opportunity_view()
def _create_partner(self, lead_id, action, partner_id):
""" Create partner based on action.
+1 -6
View File
@@ -39,12 +39,7 @@ class MergeOpportunity(models.TransientModel):
def action_merge(self):
self.ensure_one()
merge_opportunity = self.opportunity_ids.merge_opportunity(self.user_id.id, self.team_id.id)
# The newly created lead might be a lead or an opp: redirect toward the right view
if merge_opportunity.type == 'opportunity':
return merge_opportunity.redirect_opportunity_view()
else:
return merge_opportunity.redirect_lead_view()
return merge_opportunity.redirect_lead_opportunity_view()
@api.onchange('user_id')
def _onchange_user(self):
@@ -1,11 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="crm_reveal_lead_form" model="ir.ui.view">
<field name="name">crm.lead.form</field>
<record id="crm_reveal_lead_opportunity_form" model="ir.ui.view">
<field name="name">crm.lead.inherited.crm</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_case_form_view_leads" />
<field name="inherit_id" ref="crm.crm_lead_view_form"/>
<field name="arch" type="xml">
<xpath expr="//page[@name='lead']/group" position="inside">
<group string="Lead Generation Information" attrs="{'invisible': [('reveal_ip', '=', False)]}" groups="base.group_no_one">
<field name="reveal_ip"/>
<field name="reveal_iap_credits"/>
<field name="reveal_rule_id"/>
</group>
</xpath>
<xpath expr="//page[@name='extra']/group" position="inside">
<group string="Lead Generation Information" attrs="{'invisible': [('reveal_ip', '=', False)]}" groups="base.group_no_one">
<field name="reveal_ip"/>
@@ -15,19 +22,4 @@
</xpath>
</field>
</record>
<record id="crm_reveal_lead_opportunity_form" model="ir.ui.view">
<field name="name">crm.lead.opportunity.inherited.crm</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_case_form_view_oppor"/>
<field name="arch" type="xml">
<xpath expr="//page[@name='lead']/group" position="after">
<group string="Lead Generation Information" attrs="{'invisible': [('reveal_ip', '=', False)]}" groups="base.group_no_one">
<field name="reveal_ip"/>
<field name="reveal_iap_credits"/>
<field name="reveal_rule_id"/>
</group>
</xpath>
</field>
</record>
</odoo>
+4 -4
View File
@@ -4,18 +4,18 @@
<record id="crm_case_form_view_oppor" model="ir.ui.view">
<field name="name">crm.lead.oppor.inherited.crm</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_case_form_view_oppor"/>
<field name="inherit_id" ref="crm.crm_lead_view_form"/>
<field name="arch" type="xml">
<xpath expr="//button[@name='action_set_won_rainbowman']" position="before">
<button string="New Quotation" name="action_sale_quotations_new" type="object" class="oe_highlight"
attrs="{'invisible': ['&amp;', ('probability', '=', 0), ('active', '=', False)]}"/>
attrs="{'invisible': ['|', ('type', '=', 'lead'), '&amp;', ('probability', '=', 0), ('active', '=', False)]}"/>
</xpath>
<button name="action_schedule_meeting" position="after">
<button class="oe_stat_button" type="object"
name="action_view_sale_quotation" icon="fa-pencil-square-o">
name="action_view_sale_quotation" icon="fa-pencil-square-o" attrs="{'invisible': [('type', '=', 'lead')]}">
<field name="quotation_count" widget="statinfo" string="Quotations"/>
</button>
<button class="oe_stat_button" type="object" attrs="{'invisible': [('sale_order_count', '=', 0)]}"
<button class="oe_stat_button" type="object" attrs="{'invisible': ['|', ('sale_order_count', '=', 0), ('type', '=', 'lead')]}"
name="action_view_sale_order" icon="fa-usd">
<div class="o_field_widget o_stat_info">
<span class="o_stat_value"><field name="sale_amount_total" widget="monetary" options="{'currency_field': 'company_currency'}"/></span>
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_crm_opportunity_geo_assign_form" model="ir.ui.view">
<record id="view_crm_lead_opportunity_geo_assign_form" model="ir.ui.view">
<field name="name">crm.lead.geo_assign.inherit</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_case_form_view_oppor"/>
<field name="inherit_id" ref="crm.crm_lead_view_form"/>
<field name="arch" type="xml">
<xpath expr="//notebook/page[@name='lead']" position="after">
<xpath expr="//notebook/page[last()]" position="after">
<page string="Assigned Partner" groups="sales_team.group_sale_salesman">
<group col="3">
<label for="partner_latitude" string="Geolocation"/>
@@ -61,38 +61,6 @@
</field>
</record>
<record id="view_crm_lead_geo_assign_form" model="ir.ui.view">
<field name="name">crm.lead.lead.geo_assign.inherit</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_case_form_view_leads"/>
<field name="arch" type="xml">
<xpath expr="//notebook/page[@name='extra']" position="after">
<page string="Assigned Partner" groups="sales_team.group_sale_salesman">
<group col="3">
<label for="partner_latitude" string="Geolocation"/>
<div class="o_row">
<span class="oe_grey">( </span>
<field name="partner_latitude"/>
<span class="oe_grey" attrs="{'invisible':[('partner_latitude','&lt;=',0)]}">N </span>
<span class="oe_grey" attrs="{'invisible':[('partner_latitude','&gt;=',0)]}">S </span>
<field name="partner_longitude"/>
<span class="oe_grey" attrs="{'invisible':[('partner_longitude','&lt;=',0)]}">E </span>
<span class="oe_grey" attrs="{'invisible':[('partner_longitude','&gt;=',0)]}">W </span>
<span class="oe_grey">) </span>
</div>
<button string="Automatic Assignation" name="action_assign_partner" type="object" class="btn-link"/>
<field name="partner_assigned_id" domain="[('grade_id','!=',False)]"/>
<button string="Send Email" type="action" class="btn-link"
attrs="{'invisible':[('partner_assigned_id','=',False)]}"
name="%(crm_lead_forward_to_partner_act)d"
context="{'default_composition_mode': 'forward','hide_forward_type': 1 , 'default_partner_ids': [partner_assigned_id]}"/>
</group>
</page>
</xpath>
</field>
</record>
<record id="view_crm_lead_geo_assign_tree" model="ir.ui.view">
<field name="name">crm.lead.lead.geo_assign.tree.inherit</field>
<field name="model">crm.lead</field>