Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
351 Widoki

Hello I am trying to when you change a crm from any stage to Lost that the lost reason pops up 
that is external_id crm.crm_lead_lost_view_form

This is what I did
```

```

   def action_show_lost_reason_wizard(self):
        self.ensure_one()
        _logger.warning("🔥 action_show_lost_reason_wizard called for lead %s", self.id)

        action = self.env.ref('crm.crm_lead_lost_action').read()[0]
        action['context'] = {'default_lead_id': self.id}
        action['target'] = 'new'
        return action
odoo.define('crm_lost_wizard.kanban_lead_patch', function (require) {
    "use strict";

    const KanbanRecord = require('crm.LeadKanbanRecord');
    const core = require('web.core');
    const _t = core._t;

    KanbanRecord.include({
        onChangeStage: function (stage_id, options) {
            const self = this;
            console.log('yheeeeeett')
            // Check if the new stage is "Lost"
            // You may also want to dynamically fetch the Lost stage ID in future
            if (stage_id === 5) {  // Replace 5 if your "Lost" stage has a different ID
                return this._rpc({
                    model: 'crm.lead',
                    method: 'action_show_lost_reason_wizard',
                    args: [[this.id]],
                }).then(function (action) {
                    self.do_action(action);
                    return $.Deferred().reject(); // Prevent default stage change
                });
            }

            // Default behavior for other stages
            return this._super.apply(this, arguments);
        }
    });
});
Awatar
Odrzuć

What is your question? Did you succeed? Got different data then you expected? Or maybe an error?

Autor Najlepsza odpowiedź

it doesn't give any error and it doesn't do anything So It doesn't do what it needs to do

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
sie 25
1592
2
sie 25
555
1
sie 25
596
0
lip 25
732
0
lip 25
1272