Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
9063 Lượt xem

Hello, I am trying to display a button next to the create button but I am having an issue that the button is not rendering in the view. Here my code:

manifest

'assets': {
'web.assets_backend': [
'/module/static/src/js/action_call.js',
'/module/static/src/xml/tree_button.xml',
],
},

xml

<template xml:space="preserve"> 

   <t-extend="ListView.buttons">      

​<t-jquery="button.o_list_button_add" t-operation="after">              ​                    <button class="oe_button" type="button"> YOU BUTTON button>     

         t> 

   t>

template>

Help please!!


Ảnh đại diện
Huỷ bỏ
Tác giả

Thanks, it worked!

Câu trả lời hay nhất

Hi,

Try like below.

In views

<?xml version="1.0" encoding="UTF-8"?>


<odoo>


   <data>


       <record id="inherited_tree_view" model="ir.ui.view">


           <field name="name">tree.inherit</field>


           <field name="model">your.model</field>


           <field name="inherit_id" ref="external_id"/>


           <field name="arch" type="xml">


               <xpath expr="//tree" position="attributes">


                   <attribute name="js_class">button_in_tree</attribute>


               </xpath>


           </field>


       </record>


   </data>


</odoo>

in static/src/xml

<?xml version="1.0" encoding="UTF-8"?>


<templates>


   <t t-extend="ListView.buttons" t-name="module_name_input_v16.buttons">


       <t t-jquery="button.o_list_button_add" t-operation="after">


           <button type="object" class="btn btn-primary import_your_action" style="margin-left:10px;">


              Import


           </button>


       </t>


   </t>


</templates>

in static/src/js

odoo.define('module-name.tree_button', function (require) {
"use strict";
var ListController = require('web.ListController');
var ListView = require('web.ListView');
var viewRegistry = require('web.view_registry');
var TreeButton = ListController.extend({
buttons_template: 'module_name.buttons',
events: _.extend({}, ListController.prototype.events, {
'click .import_your_action': '_OpenWizard',
}),
_OpenWizard: function () {
var self = this;
 
}
});
var InputListView = ListView.extend({
config: _.extend({}, ListView.prototype.config, {
Controller: TreeButton,
}),
});
viewRegistry.add('button_in_tree', InputListView);
});

Regards

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

hi, you can follow this: 


hope it helps

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi Carmen, 

Try changing your manifest to:


For the xml try adding the "t-name":

Or, if it didn't work you may use this tutorial:

https://www.cybrosys.com/blog/how-to-add-a-create-button-near-tree-kanban-view-in-odoo-15

Hope this helps you!

Thanks.

Ảnh đại diện
Huỷ bỏ