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

Problem with inheritance of a view.

S'inscrire

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

Cette question a été signalée
viewinheritance
1 Répondre
8705 Vues
Avatar
Luis Filipe Castanheira

In order to show some workflow buttons to members of a group and hide them from all others, I am trying to inherit a view of a custom module that I am developing in OpenERP 7.0

In my original view I have the following code:

<?xml version="1.0"?>
<openerp>
    <data>
(...)
        <!-- ### GENERIC REQUEST ### -->
        <record model="ir.ui.view" id="view_generic_request_form">
            <field name="name">generic_request.form</field>
            <field name="model">generic.request</field>
            <!-- ####### F O R M   V I E W  ###### -->        
            <field name="arch" type="xml">
                <form string="generic_request" version="7.0">
                    <header>
     (...)                   
                        <!-- treatment (authorized & approved)-->

                        <button name="wtv" invisible="1" />
                        <button name="close_request" class="oe_highlight oe_view_mode_only" string="Close Request Process" help="This will close the request and end the process here" type="workflow" attrs="{'invisible':['|', ('state', 'not in', ['treatment', 'authorized', 'approved']), ('ami_owner', '=', False)]}"  />
                        <button name="%(action_auth_generic_request)d" class="oe_view_mode_only" string="Ask for authorization wiz" help="" type="action" attrs="{'invisible':['|', '|', ('state', 'not in', ['treatment', 'authorized', 'approved']), ('authorized','=', True), ('ami_owner', '=', False)]}" />
                        <button name="%(action_appr_generic_request)d" class="oe_view_mode_only" string="Ask for approval wiz" help="" type="action"  attrs="{'invisible':['|', '|', '|', ('state', 'not in', ['treatment', 'authorized', 'approved']), ('authorized','=', True), ('approved','=', True), ('ami_owner', '=', False)]}"  />
                        <button name="%(action_reformulate_generic_request)d" class="oe_view_mode_only" string="Send to be reformulated w2" help="Send request back to requester to be reformulated" type="action"  attrs="{'invisible': ['|',('state', 'not in', ['treatment', 'authorized', 'approved']), ('ami_owner', '=', False)]}"/>

                            <!-- give and take buttons -->                    
                            <button name="take_request" string="Take request" help="Take this request to your responsability" attrs="{'invisible': ['|',('ami_owner', '=', True), ('state', 'not in', ['treatment', 'authorized', 'approved']),]}" />
                            <button name="%(action_give_request)d" string="Give request wiz" help="Give this request to someone else's responsability" type="action" attrs="{'invisible': ['|',('ami_owner', '=', False),'|', ('state', 'not in', ['treatment', 'authorized', 'approved']),]}"  />

    (...)             

    
In my inherited view XML I have this:

<?xml version="1.0"?>
<openerp>
    <data>
<!-- ###  SHOW WTV BUTTON ONLY TO HR MEMBERS  ### -->
<record model="ir.ui.view"  id="view_generic_request_form_hr">
    <field name="name">view.generic.request.form.hr</field>
    <field name="model">generic.request</field>
    <field name="inherit_id" ref="processos_uc.view_generic_request_form"/>
    <field name="groups_id" eval="[(6, 0, [ref('processos_uc.group_processos_hr') ])]"/>
    <field name="arch" type="xml">
        <field name="wtv" position="attributes">
            <attribute name="invisible">0</attribute>
        </field>
    </field>
</record>
    </data>
</openerp>

And I get this error:

AttributeError: View definition error for inherited view '' on model 'generic.request': Element '<field name="wtv">' not found in parent view 'processos_uc.view_generic_request_form'

I've seen other examples of inheritance and can't figure out what I'm doing wrong. Can anyone help?

Here is the full (and now correct) trace :

2014-05-27 14:16:52,567 4156 INFO may_9 openerp.modules.loading: module processos_uc: loading inherit_view.xml
2014-05-27 14:16:52,596 4156 ERROR may_9 openerp.addons.base.ir.ir_ui_view: Can't render view  for model: generic.request
Traceback (most recent call last):
  File "/opt/openerp/v7/server/openerp/addons/base/ir/ir_ui_view.py", line 126, in _check_render_view
    fvg = self.pool.get(view.model).fields_view_get(cr, uid, view_id=view.id, view_type=view.type, context=context)
  File "/opt/openerp/v7/server/openerp/osv/orm.py", line 2237, in fields_view_get
    arch=apply_view_inheritance(cr, user, source, sql_res['id']),
  File "/opt/openerp/v7/server/openerp/osv/orm.py", line 2195, in apply_view_inheritance
    source = apply_inheritance_specs(source, view_arch, view_id)
  File "/opt/openerp/v7/server/openerp/osv/orm.py", line 2179, in apply_inheritance_specs
    raise_view_error("Element '%s' not found in parent view '%%(parent_xml_id)s'" % tag, inherit_id)
  File "/opt/openerp/v7/server/openerp/osv/orm.py", line 2072, in raise_view_error
    %  (child_view.xml_id, self._name, error_msg))
AttributeError: View definition error for inherited view '' on model 'generic.request': Element '<field name="wtv">' not found in parent view 'processos_uc.view_generic_request_form'
2014-05-27 14:16:52,598 4156 ERROR may_9 openerp.tools.convert: Parse error in /home/lfc/openerp/v7/addons/processos_uc/inherit_view.xml:5:
<record model="ir.ui.view" id="view_generic_request_form_hr">
    <field name="name">view.generic.request.form.hr</field>
    <field name="model">generic.request</field>
    <field name="inherit_id" ref="processos_uc.view_generic_request_form"/>
    <field name="groups_id" eval="[(6, 0, [ref('processos_uc.group_processos_hr') ])]"/>
    <field name="arch" type="xml">
        <field name="wtv" position="attributes">
            <attribute name="invisible">0</attribute>
        </field>
    </field>
</record>
Traceback (most recent call last):
  File "/opt/openerp/v7/server/openerp/tools/convert.py", line 847, in parse
    self._tags[rec.tag](self.cr, rec, n)
  File "/opt/openerp/v7/server/openerp/tools/convert.py", line 814, in _tag_record
    id = self.pool.get('ir.model.data')._update(cr, self.uid, rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode, context=rec_context )
  File "/opt/openerp/v7/server/openerp/addons/base/ir/ir_model.py", line 964, in _update
    res_id = model_obj.create(cr, uid, values, context=context)
  File "/opt/openerp/v7/server/openerp/addons/base/ir/ir_ui_view.py", line 103, in create
    return super(view, self).create(cr, uid, values, context)
  File "/opt/openerp/v7/server/openerp/osv/orm.py", line 4472, in create
    self._validate(cr, user, [id_new], context)
  File "/opt/openerp/v7/server/openerp/osv/orm.py", line 1546, in _validate
    raise except_orm('ValidateError', '\n'.join(error_msgs))
except_orm: ('ValidateError', u'Error occurred while validating the field(s) arch: Invalid XML for View Architecture!')
2014-05-27 14:16:52,599 4156 ERROR may_9 openerp.netsvc: ValidateError
Error occurred while validating the field(s) arch: Invalid XML for View Architecture!
Traceback (most recent call last):
  File "/opt/openerp/v7/server/openerp/netsvc.py", line 292, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/opt/openerp/v7/server/openerp/service/web_services.py", line 622, in dispatch
    security.check(db,uid,passwd)
  File "/opt/openerp/v7/server/openerp/service/security.py", line 40, in check
    pool = pooler.get_pool(db)
  File "/opt/openerp/v7/server/openerp/pooler.py", line 49, in get_pool
    return get_db_and_pool(db_name, force_demo, status, update_module)[1]
  File "/opt/openerp/v7/server/openerp/pooler.py", line 33, in get_db_and_pool
    registry = RegistryManager.get(db_name, force_demo, status, update_module)
  File "/opt/openerp/v7/server/openerp/modules/registry.py", line 192, in get
    update_module)
  File "/opt/openerp/v7/server/openerp/modules/registry.py", line 218, in new
    openerp.modules.load_modules(registry.db, force_demo, status, update_module)
  File "/opt/openerp/v7/server/openerp/modules/loading.py", line 350, in load_modules
    force, status, report, loaded_modules, update_module)
  File "/opt/openerp/v7/server/openerp/modules/loading.py", line 256, in load_marked_modules
    loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
  File "/opt/openerp/v7/server/openerp/modules/loading.py", line 187, in load_module_graph
    load_update_xml(module_name, idref, mode)
  File "/opt/openerp/v7/server/openerp/modules/loading.py", line 74, in <lambda>
    load_update_xml = lambda *args: _load_data(cr, *args, kind='update_xml')
  File "/opt/openerp/v7/server/openerp/modules/loading.py", line 124, in _load_data
    tools.convert_xml_import(cr, module_name, fp, idref, mode, noupdate, report)
  File "/opt/openerp/v7/server/openerp/tools/convert.py", line 954, in convert_xml_import
    obj.parse(doc.getroot())
  File "/opt/openerp/v7/server/openerp/tools/convert.py", line 847, in parse
    self._tags[rec.tag](self.cr, rec, n)
  File "/opt/openerp/v7/server/openerp/tools/convert.py", line 814, in _tag_record
    id = self.pool.get('ir.model.data')._update(cr, self.uid, rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode, context=rec_context )
  File "/opt/openerp/v7/server/openerp/addons/base/ir/ir_model.py", line 964, in _update
    res_id = model_obj.create(cr, uid, values, context=context)
  File "/opt/openerp/v7/server/openerp/addons/base/ir/ir_ui_view.py", line 103, in create
    return super(view, self).create(cr, uid, values, context)
  File "/opt/openerp/v7/server/openerp/osv/orm.py", line 4472, in create
    self._validate(cr, user, [id_new], context)
  File "/opt/openerp/v7/server/openerp/osv/orm.py", line 1546, in _validate
    raise except_orm('ValidateError', '\n'.join(error_msgs))
except_orm: ('ValidateError', u'Error occurred while validating the field(s) arch: Invalid XML for View Architecture!')
2014-05-27 14:16:52,607 4156 INFO may_9 werkzeug: 193.136.201.121 - - [27/May/2014 14:16:52] "POST /web/dataset/call_button HTTP/1.1" 200 -

 

0
Avatar
Ignorer
Luis Filipe Castanheira
Auteur

Question / Error and trace updated (I was trying to simplify and I guess I complicated things a bit)

Ludo - 21South

I edited my comment below.

Avatar
Ludo - 21South
Meilleure réponse

This often happens when developing different versions and switching back and forth between them. The view that is causing the crash (view_generic_request_form_hr) still refers to a field called "close_request". Make sure you are updating/editing the right view.

If you are 100% sure you are updating the right view and it is linked correctly, then look for this field "close_request" on the form you try to inherit. I don't see it in the top view that you posted, but you left out some information on purpose as well.

[EDIT]

Oke, I read your comment. In that case, it is trying to alter a field, while you are trying to alter a button.

So you have:

<field name="close_request position="attributes">

replace that with:

<button name="close_request position="attributes">

1
Avatar
Ignorer
Luis Filipe Castanheira
Auteur

Yeah, I did for simplicity sake. I edited the code and those are the buttons I want to Hide (the "wtv" button was added as an example)

Luis Filipe Castanheira
Auteur

That was it! Thanks!

Ludo - 21South

Glad to hear. If this is resolved now, please mark the answer.

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é
View inheritance Résolu
view inheritance
Avatar
Avatar
1
mars 20
4360
How do I remove fields from a view in a custom module? Résolu
view inheritance
Avatar
Avatar
Avatar
Avatar
12
déc. 18
36187
Weird error "Expression cannot be located in parent view" in view inheritance Résolu
view inheritance
Avatar
Avatar
1
juil. 16
7914
Two-level view inheritance, what am I missing?
view inheritance
Avatar
Avatar
2
mars 15
6839
Is "search + use arch" the right way to derive a form ?
view inheritance
Avatar
0
mars 15
4571
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