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 restrict a print report from specific views

S'inscrire

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

Cette question a été signalée
printingreport
1 Répondre
7808 Vues
Avatar
Kitti Upariphutthiphong

When I create a new report form, i.e., Customer Invoice. I create it by identify it to a model "account.invoice". Then this "Customer Invoice" show in both Customer Invoice and Supplier Invoice windows. I know, we can restrict access report using group security, but given I am using the same person to work on both sales and purchase, this won't help. (as he/she need to see both forms, but different view)

The question is, are there ways to restrict Customer Invoice (to not show) from the Supplier Invoice window.

Or if it require coding, where is the place to look at (report assign to print menu).

Thank you,

0
Avatar
Ignorer
Avatar
Kitti Upariphutthiphong
Auteur Meilleure réponse

Hello, I have found that we the main method is fields_view_get() in BaseModel (orm.py), where at the end, it writeout as following,

    result['toolbar'] = {
        'print': resprint,
        'action': resaction,
        'relate': resrelate
    }
return result

The reports listing will be in 'print' dict. What I need is to 1) Add restricted Views in Report window and 2) During fieds_view_get() call of each page (i.e., Customer Invoice with model account.invoice) remove Report from the stack if not matched the criteria from (1).

At first I wanted to inherit directly from the BaseModel, but it seem to be beyond my knowledge of python at the moment. Instead I inherit from only account.invoice and account.voucher, as the problem seem to lie on these 2 model anyway.

So, here is what I did,

1) Add restricted view in ir.actions.report.xml

class report_xml(osv.osv):
    _inherit = 'ir.actions.report.xml'
    _columns = {
        'views_id': fields.many2many('ir.ui.view', 'res_views_report_rel', 'uid', 'view_id', 'Views', domain="[('model','=',model),('inherit_id','=',False),('type','in',('tree','form'))]"),
    } report_xml()

2) Remove unmatched report if views criteria from (1) are specified.

# Remove report from the list, if the view security is assigned.
def check_print_list(result):
    view_id = result.get('view_id', False)
    if result.get('toolbar', False):
        reports = result['toolbar']['print'][:] # Pass by value
        i = 0
        for report in reports:
            if report['views_id']:
                if view_id not in report['views_id']:
                    result['toolbar']['print'].pop(i)
                    i = i-1
            i = i+1
    return result

class account_invoice(osv.osv):
    _inherit = 'account.invoice'
    def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False):
        result = super(account_invoice, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu)
        result = check_print_list(result)
        return result
account_invoice()

class account_voucher(osv.osv):
    _inherit = 'account.voucher'
    def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False):
        result = super(account_voucher, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu)
        result = check_print_list(result)
        return result
account_voucher()

It seem to work for me so far. But if anyone know how to modify from the BaseModel, please share with me.

1
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é
Printing my reports come out in text but with the extension .pdf
printing report
Avatar
Avatar
Avatar
3
déc. 21
3658
how to get log of reports being printed ?
printing report
Avatar
Avatar
1
mars 15
5661
Printing Reports?
pdf printing report
Avatar
0
mars 15
4014
Report with a different footer in the first page. How to do it?
report
Avatar
Avatar
2
nov. 25
278
Product Labels Configuration
printing
Avatar
Avatar
Avatar
Avatar
4
sept. 25
7069
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