i tried to get a wizard by asking everything is filled correctlt and do cross check, when i change the state in to Closed Won - 100%
but im not able to do by onchange , contrains, write method.
i tried using js file also but its not working
can anyone help me to get solve this problem??
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
1. Create a Wizard Model (Python)
# models/won_wizard.py
from odoo import models, fields
class CRMWonWizard(models.TransientModel):
_name = 'crm.won.wizard'
_description = 'Wizard triggered when deal is Closed Won'
message = fields.Text(string="Message", default="You have marked this opportunity as Closed Won.")
def action_confirm(self):
return {'type': 'ir.actions.act_window_close'}
2. Define Wizard View (XML)
<!-- views/won_wizard_view.xml -->
<odoo>
<record id="view_crm_won_wizard_form" model="ir.ui.view">
<field name="name">crm.won.wizard.form</field>
<field name="model">crm.won.wizard</field>
<field name="arch" type="xml">
<form string="Closed Won Confirmation">
<group>
<field name="message" readonly="1"/>
</group>
<footer>
<button name="action_confirm" type="object" class="btn-primary" string="OK"/>
</footer>
</form>
</field>
</record>
<record id="action_crm_won_wizard" model="ir.actions.act_window">
<field name="name">Closed Won Wizard</field>
<field name="res_model">crm.won.wizard</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_crm_won_wizard_form"/>
<field name="target">new</field>
</record>
</odoo>
3. Extend JS to Trigger Wizard
// static/src/js/crm_stage_wizard.js
odoo.define('your_module_name.crm_stage_wizard', function (require) {
"use strict";
const FormController = require('web.FormController');
const core = require('web.core');
const rpc = require('web.rpc');
const Dialog = require('web.view_dialogs');
FormController.include({
_saveRecord: function () {
const self = this;
return this._super.apply(this, arguments).then(function (result) {
if (self.modelName === 'crm.lead' && self.renderer.state.data.stage_id.display_name === 'Closed Won - 100%') {
rpc.query({
model: 'ir.actions.act_window',
method: 'search_read',
domain: [['res_model', '=', 'crm.won.wizard']],
fields: ['id'],
limit: 1,
}).then(function (actions) {
if (actions.length) {
self.do_action(actions[0].id);
}
});
}
return result;
});
},
});
});
4. Load JS in Assets (XML)
<!-- views/assets.xml -->
<odoo>
<template id="assets_backend" name="CRM Wizard Assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/your_module_name/static/src/js/crm_stage_wizard.js"/>
</xpath>
</template>
</odoo>
5. Don't forget to:
- Add the wizard view and assets to your module’s __manifest__.py
- Upgrade your module
- Clear browser cache (for JS changes)
Why This JS Method Works :
- _saveRecord is triggered after the user changes the stage and hits Save.
- The JS checks if the stage_id name is "Closed Won - 100%".
- If true, it finds the action linked to the wizard model and opens it using do_action().
Thanks & Regards,
Email :- contact@datainteger.com
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
1
thg 7 23
|
1238 | ||
Hide Sales Menu in CRM
Đã xử lý
|
|
1
thg 6 23
|
1774 | |
|
2
thg 1 23
|
2779 | ||
|
1
thg 3 15
|
5716 | ||
|
0
thg 3 15
|
2854 |