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

View or hide one report menu based on condition in odoo 8

S'inscrire

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

Cette question a été signalée
viewtemplateodooV8odoo8.0odoo8
2 Réponses
16232 Vues
Avatar
Md. Shahajalal Hossain

I am new in odoo. I am using Odoo 8. It is under stock/stock_report.xml. I inherit one menu option (top dropdown menu) report in my new module. Now I want to show it based on some condition. More clearly, menu="False" if ('state', '==', 'assigned') otherwise, menu="True".

How can I write this in menu. I have tried like following way. But it does not work. Or, if there any other way to do. I must have to do it by inheriting.

<report

string="Picking test"

id="stock.action_report_picking"

model="stock.picking"

report_type="qweb-pdf"

name="stock.report_picking"

file="stock.report_picking"

menu="{'False':['|',('state', '==', 'assigned')]}"

/>



 

0
Avatar
Ignorer
Avatar
Sunny Sheth
Meilleure réponse

Hello,

you can achieve this thing via fields_view_get method inherit in your .py file.

so try below code and some as per you need do some changes according to your requirement.

@api.model

def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):

res = super(stock_picking, self).fields_view_get(

view_id=view_id,

view_type=view_type,

toolbar=toolbar,

submenu=submenu)

if res.get('fields').get('state')['selection'][0][1] == 'assigned':

if res.get('toolbar', False) and res.get('toolbar').get('print', False):

reports = res.get('toolbar').get('print')

for report in reports:

if report.get('report_file', False) and report.get('report_file') == 'stock.report_picking':

res['toolbar']['print'].remove(report)

return res



I Hope it will help you.

Thanks.


3
Avatar
Ignorer
Diego B.

Thanks for the help! It works but, in my case, not in all account.invoice views, only just in one. In the other ones, the option appears in the Print menu, but in the fields_view_get() method that report menu option seems not exists in this loop:

def fields_view_get():

reports = res['toolbar']['print']

for report in reports:

# Here, the logger doesn't show the report option we want to remove

logger.error('## REPORT ## %r', report)

Dharmesh Chudasama

It works me.....! Thank you.
@api.model
def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
context = self._context
res = super(AccountMoveLineInherit, self).fields_view_get(view_id=view_id,view_type=view_type,toolbar=toolbar,submenu=submenu)
if res.get('toolbar', False) and res.get('toolbar').get('print', False):
reports = res.get('toolbar').get('print')
for report in reports:
if context.get('journal_type') and context.get('journal_type') == 'sales':
if report.get('report_file', False) and report.get('report_file') == 'report_account_moves_line_pur_xlsx':
res['toolbar']['print'].remove(report)
if context.get('journal_type') and context.get('journal_type') == 'purchase':
if report.get('report_file', False) and report.get('report_file') == 'report_account_moves_line_sale_xlsx':
res['toolbar']['print'].remove(report)
return res

Davaadorj Uitumen

Thanks all. This is the one more example:

@api.model
def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
res = super(accountInvoice, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu)

if res.get('toolbar', False) and res.get('toolbar').get('print', False):
reports = res.get('toolbar').get('print')

for report in reports:
if report.get('report_name', False) == 'account.report_invoice_with_payments' or report.get('report_name', False) == 'account.report_invoice':
res['toolbar']['print'] = []

return res

Avatar
shalin wilson
Meilleure réponse

Its again a doubt .

fields_view_get method doesnt work first
it works when a reload occurs
how to solve the problem,i am removing one report from the menu depending on company id
it only works on refreshing of form

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é
High Availability Odoo 8.0 on Windows
odooV8 odoo8.0 odoo8
Avatar
0
févr. 21
4572
Product received Administrator in Odoo 8 purchase module
odooV8 odoo8.0 odoo8
Avatar
0
févr. 18
3296
blockUI requires jQuery v1.2.3 or later! You are using v1.11.1 error when installing Odoo 8 on Windows 10
odooV8 odoo8.0 odoo8
Avatar
Avatar
Avatar
3
juin 17
6659
Values are reset on save
odooV8 odoo8.0 odoo8
Avatar
0
janv. 16
4395
How to change Error log window on "client"-side service of Odoo? Résolu
odooV8 odoo8.0 odoo8 Odoo8
Avatar
Avatar
2
août 19
5596
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