Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

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

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

How to call JavaScript from python function?

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
javascriptpythonodoo
14302 Vues
Avatar
ameer ashraf

I am trying to call JavaScript from python function.

Python class:

 def print_excel(self, cr, uid, ids, context=None):

return self.print_report(cr, uid, ids, context=context)

def print_report(self, cr, uid, ids, context=None):

if context is None:

context = {}

datas = {'ids': context.get('active_ids', [])}

res = self.read(cr, uid, ids, ['date_start', 'date_end', 'user_ids'], context=None)

res = res and res[0] or {}

datas['form'] = res

if res.get('id',False):

datas['ids']=[res['id']]

if context.get('xls_export'):

return {

'class':'oe_export_excel',

'type': 'text/javascript',

'src':'/export_excel/static/src/js/export_excel_print.js',

}

else:

return self.pool['report'].get_action(cr, uid, [], 'point_of_sale.report_detailsofsales', data=datas, context=None)

JavaScript file:

openerp.export_excel = function(instance, m) {

var _t = instance.web._t;

var QWeb = instance.web.qweb;

instance.web.ListView.include({

load_list: function () {

var self = this;

this._super.apply(this, arguments);

self.$pager.find("oe_export_excel").unbind('click').click(function(event){self.export_to_excel("excel")})

},

export_to_excel: function(export_type) {

var self = this

var export_type = export_type

view = this.getParent()

// Find Header Element

header_eles = self.$el.find('.oe_list_header_columns')

header_name_list = []

$.each(header_eles,function(){

$header_ele = $(this)

header_td_elements = $header_ele.find('th')

$.each(header_td_elements,function(){

$header_td = $(this)

text = $header_td.text().trim() || ""

data_id = $header_td.attr('data-id')

if (text && !data_id){

data_id = 'group_name'

}

header_name_list.push({'header_name': text.trim(), 'header_data_id': data_id})

// }

});

});

//Find Data Element

data_eles = self.$el.find('.oe_list_content > tbody > tr')

export_data = []

$.each(data_eles,function(){

data = []

$data_ele = $(this)

is_analysis = false

if ($data_ele.text().trim()){

//Find group name

group_th_eles = $data_ele.find('th')

$.each(group_th_eles,function(){

$group_th_ele = $(this)

text = $group_th_ele.text().trim() || ""

is_analysis = true

data.push({'data': text, 'bold': true})

});

data_td_eles = $data_ele.find('td')

$.each(data_td_eles,function(){

$data_td_ele = $(this)

text = $data_td_ele.text().trim() || ""

if ($data_td_ele && $data_td_ele[0].classList.contains('oe_number') && !$data_td_ele[0].classList.contains('oe_list_field_float_time')){

text = text.replace('%', '')

text = instance.web.parse_value(text, { type:"float" })

data.push({'data': text || "", 'number': true})

}

else{

data.push({'data': text})

}

});

export_data.push(data)

}

});

//Find Footer Element

footer_eles = self.$el.find('.oe_list_content > tfoot> tr')

$.each(footer_eles,function(){

data = []

$footer_ele = $(this)

footer_td_eles = $footer_ele.find('td')

$.each(footer_td_eles,function(){

$footer_td_ele = $(this)

text = $footer_td_ele.text().trim() || ""

if ($footer_td_ele && $footer_td_ele[0].classList.contains('oe_number')){

text = instance.web.parse_value(text, { type:"float" })

data.push({'data': text || "", 'bold': true, 'number': true})

}

else{

data.push({'data': text, 'bold': true})

}

});

export_data.push(data)

});

//Export to excel

$.blockUI();

if (export_type === 'excel'){

view.session.get_file({

url: '/web/export/zb_excel_export',

data: {data: JSON.stringify({

model : view.model,

headers : header_name_list,

rows : export_data,

})},

complete: $.unblockUI

});

}

},

});

};

When I run this module, the page stopped loading.

What am I doing wrong here?

0
Avatar
Ignorer
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
Call wizard view in js function
javascript python odoo
Avatar
Avatar
1
déc. 22
4359
TypeError: Cannot read property 'taxes_by_id' of undefined at DiscountButton.apply_discount
javascript python odoo
Avatar
0
déc. 20
50
Display header only on the first page and footer on the last page Qweb Odoo 14
javascript python xml odoo
Avatar
Avatar
Avatar
2
août 24
7699
How to set default values to fields in Odoo 14
javascript python xml odoo
Avatar
Avatar
1
oct. 22
25390
How to create a customized Invoice Report . Odoo 14 Résolu
javascript python xml odoo
Avatar
Avatar
Avatar
2
sept. 21
14345
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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