Skip to Content
Menu
This question has been flagged
1 Reply
5226 Views

This is my issue. I have a form to which I have added a button to scan near to Save button. What should happen is ,when pressing the button scan a wizard should be shown, but it does not happen. Why ?

template xml

<t t-extend="FormView.buttons">
<t t-jquery=".o_form_buttons_edit" t-operation="append">
<button t-if="widget.modelName == 'model name'" accesskey="w" class="btn btn-success btn-sm o_button_scan" type="button">
<i class="fa fa-leanpub"></i>
Scan file
</button>
</t>
</t>
.js

const ExtendFormController = FormController.include({
renderButtons: function ($node) {
this._super.apply(this, arguments);
this.$buttons.on('click', '.o_button_scan', this._force_f.bind(this));
this._updateButtons();
},
_force_f: function () {
var self = this;
rpc.query({
model: 'model name',
method: 'call_wizard',
context: self.context,
// args: [125447],
}).then(function (result) {
console.log('rpc result');
console.log(result);
});
},
_updateButtons: function () {
this._super.apply(this, arguments);
}
.py

def call_wizard(self):
compose_form = self.env.ref(
'l10n_cu_document.wizard_with_scanners_form'
)

# your treatment to click button next
# ...
# update state to step2
self_class = self.env['df.client.thread.class']
self.env['df.client.thread.class'].discovery(self_class)
# return view
return {
'type': 'ir.actions.act_window',
'res_model': 'wizard_with_scanner',
'view_mode': 'form',
'view_type': 'form',
'views': [(compose_form.id, 'form')],
'view_id': compose_form.id,
'target': 'new',
}
Avatar
Discard
Author

I already resolved it. Thank

Hi Wildredo,

You may want to tag this one as Solved and even supply what you did so it can help others :)

Best Answer

Hi,

You can just call wizard by using js as below:

var core = require('web.core');
var ListController = require('web.ListController');
var rpc = require('web.rpc');
var session = require('web.session');
var _t = core._t;
ListController.include({
renderButtons: function($node) {
this._super.apply(this, arguments);
if (this.$buttons) {
this.$buttons.find('.oe_action_button').click(this.proxy('action_def')) ; }
},
action_def: function () {
var self =this
var user = session.uid;
var file = false
self.do_action({
name: _t('Warning Receive Invoices'),
type: 'ir.actions.act_window',
res_model: 'Wizard Model Name',
views: [[false, 'form']],
view_mode: 'form',
target: 'new',
})
}
});


Regards

Avatar
Discard