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

I already do the button appears, but I would like it to appear only in my module, can anyone help me?

<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-extend="ListView.buttons">
<t t-jquery="button.o_list_button_add" t-operation="after">
<t t-esc="doc_model"/>
<t t-if="doc_model in ['manifestation.recipient']">
<button class="btn btn-default btn_import_nfe" type="button">Importar Notas Sefaz</button>
</t>
</t>
</t>
</templates>
Awatar
Odrzuć
Najlepsza odpowiedź

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!

Awatar
Odrzuć
Autor Najlepsza odpowiedź


Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
lut 21
3360
0
cze 20
2175
0
maj 22
2903
1
mar 22
12832
5
mar 20
3350