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
    Restauration & Hôtellerie
    • 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
    • Brasserie
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Commerce
    • Bricoleur
    • Matériel informatique & 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
    Parcourir toutes les 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
    • Devenir partenaire
    • Services pour partenaires
    • 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
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

load external file script via action button click

S'inscrire

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

Cette question a été signalée
buttons
2 Réponses
8748 Vues
Avatar
Rizan Zaky

I want to run an external script by a button click. The button is placed in the tree view

    <tree string="Session Tree">
         <field name="name"/>
         <button name='myButton' type='action' string="Click me"/>
     </tree>

How can I achieve that?

0
Avatar
Ignorer
Avatar
Logicious
Meilleure réponse

Once i was used a pyhton code for getting document from external folder, i just made a small python script for that , you can refer this.

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

matter_obj = self.pool.get('project.project')

attach_obj=self.pool.get('ir.attachment')

wizard_obj = self.pool.get('matter.attachment.wizard')

wizard_data = wizard_obj.browse(cr,uid,ids[0])

print'!!!!!!!!!!!!!!!',wizard_data.csv_file_path

print'!!!!!!!!!!!!!!!',wizard_data.document_path

if not os.path.exists(wizard_data.csv_file_path):

raise osv.except_osv(_('Warning!'), _('There is no CSV File Path exist, Choose right path'))

if not os.path.exists(wizard_data.document_path):

raise osv.except_osv(_('Warning!'), _('There is no Document File Path exist, Choose right path'))

files = glob.glob(wizard_data.csv_file_path)

for file in files:

f=open(file, 'r')

for m in f.readlines():

print '%s' % m

get_lst=m.split(',')

if len(get_lst)>=4:

print'-------',get_lst[1]

print'#########',get_lst[4]

d = get_lst[4]

print 'dddddddddddddddd',d

search_ids= matter_obj.search(cr,uid,[('name','=',get_lst[1])])

print'%%%%%%%%%',len(search_ids)

if len(search_ids):

matter_data = matter_obj.browse(cr,uid,search_ids[0])

matter_obj.write(cr,uid,matter_data.id,{'info':''})

if get_lst[4]!=False:

print']]]]]]]',"/home/logicious/Downloads/document/files/"+get_lst[4]

file_name=get_lst[4]

# if get_lst[4].find('.')!=-1:

# ext=get_lst[4].split('.')[1]

# file_name=get_lst[4].split('.')[0]+'.'+ext.lower()

# print'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++',"/home/logicious/Downloads/document/files/"+file_name

# print '****************************',wizard_data.document_path+file_name

if os.path.exists(wizard_data.document_path+file_name):

m = open(wizard_data.document_path+file_name,'rb')

# search in matter with matter_data.name res_model res_id

#if yes than delte unlink

exist_data = attach_obj.search(cr,uid,[('res_id','=',matter_data.id)],[('res_model','=','project.project')])

print 'eeeeeeeeeee',exist_data

if exist_data:

attach_obj.unlink(cr, uid, ids, context=contex)

else:

attach_vals = {

'name': str(get_lst[4]),

'datas': base64.b64encode(m.read()),

'description': 'files',

'user_id':str(get_lst[7]),

'res_name': matter_data.name,

'res_model': 'project.project',

'res_id': matter_data.id,

}

attach_id = attach_obj.create(cr, uid, attach_vals)

else:

#message = matter_obj.browse(cr,uid,import_info)

message = matter_obj.browse(cr, uid,matter_data.id)

print'============',message.import_info

if message.import_info!=False:

matter_obj.write(cr,uid,matter_data.id,{'import_info':message.import_info +str(get_lst[4])+ ' File not attached...'})

else:

print'======@@@@@@@@@@@@@',matter_data.id

matter_obj.write(cr,uid,matter_data.id,{'import_info':str(get_lst[4])+ ' File not attached....'})

f.close()

return True


, i created a wizard based on this , and i just create one button and to getting the documents.


0
Avatar
Ignorer
Avatar
André Pereira
Meilleure réponse

I am assuming you're using Odoo 8. What we usually do is add a class to the button, e.g.:

<button name="myButton" class="session-button" ...

And then we load a JavaScript file that attaches an event to that button using the class to identify it, e.g.:

$('.session-button').click(function() {
// your code here...
});

This JavaScript file can be loaded by extending the assets backend view:

<template id="assets_backend" name="my-module assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/my-module/static/src/js/my-js-file.js"></script>
</xpath>
</template>

I recommend adding a dependency on the "web" module as well.

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é
Custom stat button (eo_stat_button) for a custom field on a partner
buttons
Avatar
Avatar
Avatar
2
mars 23
11712
Cacher le bouton "créer" d'une liste Résolu
buttons
Avatar
Avatar
2
mars 23
3653
Add class to button from function Résolu
buttons
Avatar
Avatar
2
mai 22
5982
Bind object btn to model_id action btn?
buttons
Avatar
0
mars 22
2487
PLEASE HELP - Odoo 12 - How do you replace Create button when you inherit Product.Template
buttons
Avatar
Avatar
1
mai 21
5505
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
  • Devenir 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 Svenska ภาษาไทย 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