Ir al contenido
Odoo Menú
  • Identificarse
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • TPV para tiendas
    • TPV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en directo
    • eLearning
    Cadena de suministro
    • Inventario
    • Fabricación
    • PLM
    • Compra
    • Mantenimiento
    • Calidad
    Recursos Humanos
    • Empleados
    • Reclutamiento
    • Ausencias
    • Evaluación
    • Referencias
    • Flota
    Marketing
    • Marketing social
    • Marketing por correo electrónico
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyecto
    • Partes de horas
    • Servicio de campo
    • Servicio de asistencia
    • Planificación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Información
    • WhatsApp
    Aplicaciones de terceros Studio de Odoo Plataforma de Odoo Cloud
  • Industrias
    Comercio al por menor
    • Librería
    • Tienda de ropa
    • Tienda de muebles
    • Tienda de ultramarinos
    • Ferretería
    • Juguetería
    Alimentación y hostelería
    • Bar y taberna
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidor de bebidas
    • Hotel
    Inmueble
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Empresa contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textil
    • Metal
    • Muebles
    • Alimentos
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y asistencia informática
    • Sistemas de energía solar
    • Zapatero
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin ánimo de lucro
    • Agencia de protección del medio ambiente
    • Alquiler de paneles publicitarios
    • Estudio fotográfico
    • Alquiler de bicicletas
    • Distribuidor de software
    Browse all Industries
  • Comunidad
    Aprender
    • Tutoriales
    • Documentación
    • Certificaciones
    • Formación
    • Blog
    • Podcast
    Potenciar la educación
    • Programa de formación
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtener el software
    • Descargar
    • Comparar ediciones
    • Versiones
    Colaborar
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Convertirse en partner
    • Services for Partners
    • Registrar tu empresa contable
    Obtener servicios
    • Encontrar un partner
    • Encontrar un asesor fiscal
    • Contacta con un experto
    • Servicios de implementación
    • Referencias de clientes
    • Ayuda
    • Actualizaciones
    GitHub YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicitar una demostración
  • Precios
  • Ayuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyecto
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

Odoo 15 - Issue adding buttons next to the Create button in HR Employee list view

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
listviewfrontendListController
2 Respuestas
8707 Vistas
Avatar
Marco Duran
                    

Hello,


Currently we’re having issues with Odoo v15 (previous versions 14, 13 and 12 are unaffected) in a plugin we have developed inhouse. Here’s how the button appears on odoo 14 (labeled INS):

We are aware that there’s changes in Odoo 15 compared to previous versions and we followed the official documentation and some examples from the Odoo 15 source code. Sadly, neither of them function properly, the button does not render at all in the view and we can’t even get access to the functions.


Here’s the view code as we implemented it in odoo 15:

XML:


JavaScript:

odoo.define('hr.ExportReportListView', function (require) {
    "use strict";
    var ListView = require('web.ListView');
    var ListController = require('web.ListController');
    var viewRegistry = require('web.view_registry');
    var core = require('web.core');
    var qweb = core.qweb;
    var HrExportReportListController = ListController.extend({
        buttons_template: 'HrExportReport.Buttons',
           renderButtons: function ($node) {
            this._super.apply(this, arguments);
            this.$buttons = $(qweb.render('HrExportReport.Buttons'));
            this.$buttons.on('click', '.oe_export_ins', this._onExportTxt.bind(this));
        },
        _onExportTxt: function () {
            var self = this;
            return rpc.query({
                model: 'export_ins',
                method: 'odoo_button_click'
            }, {
                shadow: true
            }).then(function (res) {
                return self.do_action(res)
            });
        }
    });
    var HrExportReportListView = ListView.extend({
        config: _.extend({}, ListView.prototype.config, {
            Controller: HrExportReportListController,
        }),
    });
    viewRegistry.add('hr_export_report_list', HrExportReportListView);
    return HrExportReportListView;
});

__manifest__.py:

"assets": {
        "web.assets_backend": [
            "/hr_employee_report_ins_rt_cr/static/src/js/hr_export_ins.js",
        ],
        "web.assets_qweb": [
            "/hr_employee_report_ins_rt_cr/views/hr_views.xml",
        ]
    },
Is there something we’re missing in the implementation of this code?
0
Avatar
Descartar
Avatar
Jainesh Shah(Aktiv Software)
Mejor respuesta

Hello Marco Duran,

I understand your question and yes the code is changed in V15.

I tried adding a button on sale order list view and I could achive it using below code.

Js file code:

function ccButton() {
if (this.$buttons) {
var self = this;
this.$buttons.on('click', '.o_button_custom', function () {
self.do_action({
name: 'Generate Leads',
type: 'ir.actions.act_window',
res_model: 'sale.order',
target: 'new',
views: [[false, 'form']],
});
});
}
}


var cListController = ListController.extend({
willStart: function() {
var self = this;
// var ready = self.buttons_template = 'CustListView.buttons';
var ready = this.getSession().user_has_group('sales_team.group_sale_manager')
.then(function (is_sale_manager) {
if (is_sale_manager) {
self.buttons_template = 'CustListView.buttons';
}
});
return Promise.all([this._super.apply(this, arguments), ready]);
},
renderButtons: function () {
this._super.apply(this, arguments);
ccButton.apply(this, arguments);
}
});


var CustListView = ListView.extend({
config: _.extend({}, ListView.prototype.config, {
Controller: cListController,
}),
});

viewRegistry.add('cust_tree', CustListView);

Xml file code :

sale.order.tree
sale.order

primary


cust_tree




Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

1
Avatar
Descartar
Jainesh Shah(Aktiv Software)

Xml file code :

<field name="name">sale.order.tree</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_quotation_tree_with_onboarding"/>
<field name="mode">primary</field>
<field name="arch" type="xml">
<xpath expr="//tree" position="attributes">
<attribute name="js_class">cust_tree</attribute>
</xpath>
</field>
</record>
</odoo>

Avatar
Marco Duran
Autor Mejor respuesta

Hello Jainesh Shah, thank you for the reply.

Checking your answer, we still could not render the button on the page. We found out that part of the problem with the render is a tag named t-name. With this tag, the button would not render:


t t-extend="ListView.buttons" t-name="HrExportListView.buttons"
    t t-jquery="button.o_list_export_xlsx" t-operation="after"
        button type="button" class="oe_export_ins">INS    /t
/t

But without it, it does:

t t-extend="ListView.buttons"
    t t-jquery="button.o_list_export_xlsx" t-operation="after"
        button type="button" class="oe_export_ins">INS    /t
/t


https://pastebin.com/NA8kMxDR

Although the button is being rendered, there’s no reaction when you click it. The Javascript is instantiated in the DOM but the content does not work properly.

In the Javascript, when we print the ListController and ListView instances, the console print out the following message:

ƒ Class(){
    if(this.constructor!==OdooClass){
        throw new Error("You can only instantiate objects with the 'new' operator");
    }
    this._super=null;
    if(!initializing&&this.init){
        var ret=this.init.apply(this,arguments);
        if(ret){
            return ret;
        }
    }
    return this;
}

We tried checking everything but no success. Anyone know why this happens and where could be the problem with my implementation? The Odoo version we are using is 15.0-20220110 (Community Edition).

0
Avatar
Descartar
Marco Duran
Autor

Update

Solution I found:

```
odoo.define('export_ins.print_ins', function (require) {
"use strict";

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

ListController.include({
renderButtons: function ($node) {
this._super.apply(this, arguments);
if (this.$buttons) {
this.$buttons.find('.oe_export_ins').click(this.proxy('action_def'));
}
},
action_def: function () {
console.log('click export');
var self = this;
return rpc.query({
model: 'export_ins',
method: 'odoo_button_click'
}, {
shadow: true
}).then(function (res) {
return self.do_action(res)
});
}
});
});
```

```
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-extend="ListView.buttons">
<t t-jquery="button.o_list_export_xlsx" t-operation="after">
<button t-if="widget.modelName == 'hr.employee'" type="button" class="btn btn-secondary oe_export_ins">INS Report</button>
</t>
</t>
</templates>
```

¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Inscribirse
Publicaciones relacionadas Respuestas Vistas Actividad
Odoo 15 Listview ListController & ListRender field value
javascript listview ListController ListRenderer
Avatar
Avatar
1
dic 22
5157
How to Implement Column-wise Filters in CRM List View (Odoo 18)
listview
Avatar
Avatar
1
ago 25
1506
Can't open records from list view in js action odoo16
javascript listview odoo ListController odoo16features
Avatar
0
feb 23
3494
Is Edit List View via the Developer Mode for any module a native function by odoo? Resuelto
listview
Avatar
Avatar
1
nov 22
3677
Front-end Odoo language
frontend
Avatar
Avatar
1
ago 22
7856
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento Odoo.sh
  • Ayuda
  • Actualizar
  • Desarrollos personalizados
  • Educación
  • Encontrar un asesor fiscal
  • Encontrar un partner
  • Convertirse en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contacta con nosotros
  • Puestos de trabajo
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Información legal • Privacidad
  • Seguridad
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y totalmente integrado.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now