[IMP] crm: remove loss reason toggle

To set the lost reason you currently need to toggle a field
in the wizard if you are marking a lead as lost.

As the loss reason isn't technically necessary, we can just let users
choose whether to input anything or not without having to click anything

We also introduce groups so field strings are displayed.
As the first field cannot easily be implied
to be the loss reason anymore.

task-3356095

X-original-commit: b5181ea609f798e09e2032fe182e01fd07d1c10e
Part-of: odoo/odoo#124437
This commit is contained in:
Renaud Thiry
2023-06-09 13:49:57 +02:00
parent cfc7df15a7
commit 629666c489
2 changed files with 4 additions and 11 deletions
+2 -7
View File
@@ -10,19 +10,14 @@ class CrmLeadLost(models.TransientModel):
_name = 'crm.lead.lost'
_description = 'Get Lost Reason'
set_reason = fields.Boolean(string='Set a Loss Reason', compute='_compute_set_reason',
readonly=False, store=True)
set_reason = fields.Boolean(string='Set a Loss Reason', default=True,
readonly=True, store=True)
lead_ids = fields.Many2many('crm.lead', string='Leads')
lost_reason_id = fields.Many2one('crm.lost.reason', 'Lost Reason')
lost_feedback = fields.Html(
'Closing Note', sanitize=True
)
@api.depends('lead_ids')
def _compute_set_reason(self):
for wizard in self:
wizard.set_reason = bool(wizard.lead_ids.filtered(lambda lead: lead.type == 'opportunity'))
def action_lost_reason_apply(self):
"""Mark lead as lost and apply the loss reason"""
self.ensure_one()
+2 -4
View File
@@ -6,12 +6,10 @@
<field name="arch" type="xml">
<form string="Lost Lead">
<field name="lead_ids" invisible="1"></field>
<label for="set_reason">Set a Loss Reason</label>
<field name="set_reason" widget="boolean_toggle"></field>
<group attrs="{'invisible': [('set_reason', '=', False)]}">
<group>
<field name="lost_reason_id" options="{'no_create_edit': True}" />
<field name="lost_feedback" placeholder="What went wrong?"/>
</group>
<field name="lost_feedback" placeholder="What went wrong?" attrs="{'invisible': [('set_reason', '=', False)]}"/>
<footer>
<button name="action_lost_reason_apply" string="Mark as Lost" type="object" class="btn-primary" data-hotkey="q"/>
<button string="Cancel" class="btn-secondary" special="cancel" data-hotkey="z"/>