Odoo Help

0

0
2 Answers
1
arthur
1/18/19, 1:32 PM

Alright, so if you made the button appear, I am assuming you create the .xml file and imported it on your qweb list of your module's manifest.

Next, you need to create the .js function that will call the function you want.

That's an example I have:

odoo.define('sale.order', function (require) {
"use strict";

var Model = require("web.rpc");
var ListController = require('web.ListController');

ListController.include({

renderButtons: function () {
this._super.apply(this, arguments);
if (this.$buttons) {
let importButton = this.$buttons.find(".oe_import_last_sales");
importButton && importButton.click(this.proxy("importLastSalesAction"));
}
},

importLastSalesAction: function () {
//implement your click logic here
Model.query({
model: "res.company",
method: "cron_sale",
args: [{}]
}).then(function (data) {
});
}

});
});


Where ".oe_import_last_sales" is the class I added to the qweb button. In your case I guess it will be be ".btn_import_nfe". Then, on my example, the "importLastSalesAction" function calls the method cron_sale, defined under the "res.company" module.

You JS code isn't known by Odoo yet, so next you have got to import it. That can be done by creating another .xml file with the following content:

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template id="assets_backend" name="product_template assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/vtex_connector/static/src/js/import_last_sales.js"></script>
</xpath>
</template>
</data>
</odoo>

Where the src prorperty on the script tag is the path of your .js

You then have to import the .xml file on your manifest data list, upgrade your module and everything should be working.

Boa sorte!

Ask a Question
Keep Informed
1 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now