Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Social media Marketing
    • E-mailmarketing
    • SMS Marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Goedkeuringen
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelzaak
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Food & Hospitality
    • Bar en Pub
    • Restaurant
    • Fastfood
    • Gastenverblijf
    • Drankenhandelaar
    • Hotel
    Vastgoed
    • Makelaarskantoor
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accountantskantoor
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textiel
    • Metaal
    • Meubels
    • Eten
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Zonne-energiesystemen
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC-diensten
    Andere
    • Non-profitorganisatie
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Browse all Industries
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijs- programma
    • Scale Up! Business Game
    • Bezoek Odoo
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Word een Partner
    • Services for Partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help

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

  • CRM
  • e-Commerce
  • Boekhouding
  • Voorraad
  • PoS
  • Project
  • MRP
All apps
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

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

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
listviewfrontendListController
2 Antwoorden
8714 Weergaven
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
Annuleer
Avatar
Jainesh Shah(Aktiv Software)
Beste antwoord

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
Annuleer
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
Auteur Beste antwoord

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
Annuleer
Marco Duran
Auteur

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>
```

Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Gerelateerde posts Antwoorden Weergaven Activiteit
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
3497
Is Edit List View via the Developer Mode for any module a native function by odoo? Opgelost
listview
Avatar
Avatar
1
nov. 22
3678
Front-end Odoo language
frontend
Avatar
Avatar
1
aug. 22
7860
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Word een Partner
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة 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 is een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

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