Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textile
    • Kov
    • Nábytek
    • Jídlo
    • Brewery
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • IT hardware a podpora
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Browse all Industries
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Services for Partners
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

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

Odebírat

Get notified when there's activity on this post

This question has been flagged
listviewfrontendListController
2 Odpovědi
8701 Zobrazení
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
Zrušit
Avatar
Jainesh Shah(Aktiv Software)
Nejlepší odpověď

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
Zrušit
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 Nejlepší odpověď

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
Zrušit
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>
```

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
Odoo 15 Listview ListController & ListRender field value
javascript listview ListController ListRenderer
Avatar
Avatar
1
pro 22
5146
How to Implement Column-wise Filters in CRM List View (Odoo 18)
listview
Avatar
Avatar
1
srp 25
1496
Can't open records from list view in js action odoo16
javascript listview odoo ListController odoo16features
Avatar
0
úno 23
3480
Is Edit List View via the Developer Mode for any module a native function by odoo? Vyřešeno
listview
Avatar
Avatar
1
lis 22
3672
Front-end Odoo language
frontend
Avatar
Avatar
1
srp 22
7852
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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