Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
5278 Tampilan

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>
Avatar
Buang
Jawaban Terbai

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!

Avatar
Buang
Penulis Jawaban Terbai


Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
1
Feb 21
3517
0
Jun 20
2350
0
Mei 22
3162
1
Mar 22
13149
5
Mar 20
3532