Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

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

Odoberať

Get notified when there's activity on this post

This question has been flagged
listviewfrontendListController
2 Replies
8716 Zobrazenia
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šiť
Avatar
Jainesh Shah(Aktiv Software)
Best Answer

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šiť
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 Best Answer

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šiť
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!

Registrácia
Related Posts Replies Zobrazenia Aktivita
Odoo 15 Listview ListController & ListRender field value
javascript listview ListController ListRenderer
Avatar
Avatar
1
dec 22
5164
How to Implement Column-wise Filters in CRM List View (Odoo 18)
listview
Avatar
Avatar
1
aug 25
1510
Can't open records from list view in js action odoo16
javascript listview odoo ListController odoo16features
Avatar
0
feb 23
3498
Is Edit List View via the Developer Mode for any module a native function by odoo? Solved
listview
Avatar
Avatar
1
nov 22
3678
Front-end Odoo language
frontend
Avatar
Avatar
1
aug 22
7860
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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