Skip to Content
Menu
This question has been flagged

I want to get location of the user when a button is pressed from a form view. 
I couldn't get to trigger anything , not even a 'console log' when that button is pressed. 
I am using a publicWidget. 

Am i missing something? 
Is a button in a form view accessible from "web assets_frontend" ?? 

Avatar
Discard
Best Answer

p>Hi,

Try this code:
1. You can add the following templates

<?xml version="1.0" encoding="UTF-8"?>
<templates>
<t t-extend="FormView.buttons" t-name="button_near_create.buttons">
<t t-jquery="button.o_list_button_add" t-operation="after">
           <button type="button" class="btn btn-primary open_wizard_action">
               Open Wizard
           </button>
       </t>
   </t>
</templates>
2. Add following js code
/** @odoo-module **/
     import FormController from 'web.FormController';
    import FormView from 'web.FormView';
    import viewRegistry from 'web.view_registry';

    var SaleFormController = FormController.extend({  buttons_template: 'button_near_create.buttons',
events: _.extend({}, ListController.prototype.events, {
       'click .open_wizard_action': '_MoreOptions',
   }),
   _MoreOptions: function () {
     console.log('Hello World!')
   }
});
var SFormView = FormView.extend({
        config: _.extend({}, FormView.prototype.config, {
            Controller: CrmFormController,
        }),
    });

viewRegistry.add('sale_order_blog', CrmFormView);

    export default {
        CrmFormController: CrmFormController,
        CrmFormView: CrmFormView,
    };


Hope it helps

Avatar
Discard
Related Posts Replies Views Activity
1
Oct 24
965
2
May 24
1283
2
May 24
2983
5
Feb 24
3064
0
Feb 18
3966