Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Social media Marketing
    • E-mailmarketing
    • SMS Marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Goedkeuringen
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelzaak
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Food & Hospitality
    • Bar en Pub
    • Restaurant
    • Fastfood
    • Gastenverblijf
    • Drankenhandelaar
    • Hotel
    Vastgoed
    • Makelaarskantoor
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accountantskantoor
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textiel
    • Metaal
    • Meubels
    • Eten
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Zonne-energiesystemen
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC-diensten
    Andere
    • Non-profitorganisatie
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Browse all Industries
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijs- programma
    • Scale Up! Business Game
    • Bezoek Odoo
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Word een Partner
    • Services for Partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help

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

  • CRM
  • e-Commerce
  • Boekhouding
  • Voorraad
  • PoS
  • Project
  • MRP
All apps
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

How to inherit a view with the purpose of hidding a <page> from a group

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
2 Antwoorden
11760 Weergaven
Avatar
Aitor Bouzas

Title says it all...

I'm inheriting the view base.view_partner_form and i'm trying to hide <page string="Sales &amp; Purchases"></page> from a group called 'ajuste_did.group_did_del_sales'.

Right know I tried with

<xpath expr="/form/notebook/page[@string='Sales &amp; Purchases']" position="replace">

    <page string="Sales &amp; Purchases" groups_id="[(3,reg('ajuste_did.group_did_del_saes'))]">

    ...

    </page>

</xpath>

But with no positive result... Any suggestion?

Thanks

EDIT:

Now i'm having an 'Error occurred while validating the field(s) arch: Invalid XML for View Architecture!'

This is my partner.py file:

class res_partner(osv.osv):
    _name = "res.partner"
    _inherit = ['res.partner']
    
    _columns = {
        'hide': fields.boolean('Hide'),
    }
    
    _defaults = {
        'hide': True,
    }

...

And this is my res_partner_view.xml file:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record id="view_partner_form" model="ir.ui.view">
            <field name="name">base.partner.form.inherit</field>
            <field name="model">res.partner</field>
            <field name="type">form</field>
            <field name="inherit_id" ref="base.view_partner_form" />
            <field name="arch" type="xml">
                <data>
                    <field name="image" position="after">
                        <field name="hide" invisible="1" />
                        <field name="contrato_promocional" invisible="1" />
                        <button name="generate_recurring_orders_agreement" string="Generar contrato" type="object" groups="base.group_sale_manager,base.group_sale_salesman" attrs="{'invisible': [('contrato_promocional','=', True)]}"/>
                    </field>
                    <field name="property_account_receivable" position="replace">
                        <field name="property_account_receivable" groups="account.group_account_invoice,ajuste_did.group_did_del_sales" />
                    </field>
                    <field name="property_account_payable" position="replace">
                        <field name="property_account_payable" groups="account.group_account_invoice,ajuste_did.group_did_del_sales" />
                    </field>
                    <xpath expr="//form//sheet//notebook//spage[@string='Sales &amp; Purchases']"  position="attributes">
                        <attribute name="invisible">[('hide','=',true)]</attribute>
                    </xpath>
                </data>
            </field>
        </record>
    </data>
</openerp>


'Hide' get's by default 'True' value because i'm just checking the functionality... But it gives me the error I mentioned.

0
Avatar
Annuleer
Avatar
Ivan
Beste antwoord

@Aitor, first, you cannot specify group_id to a view element.  The accepted attribute is groups.  (You might be getting the code from https://www.odoo.com/forum/help-1/question/hide-menu-for-existing-group-18704.  The approach only works for records, not view elements).

In general, there is no straight forward way to hide a page from a group. OpenERP/Odoo approach is that you assign a group to an element and that group can view the element.

So, you're left with 2 workaround, AFAIK:

  1. Create a function field in res.partner that will check if a user belong to the group, then return a value.  Include that column in the view and then you can use the value of this function field to trigger the invisible attrs of the view element.  For example your function field is called "hide" returns True if the logged in user belong to the (ajuste_did.group_did_del_saes) group.  Then the page should be re-defined as

    <field name="hide"/><xpath expr="/form/notebook/page[@string='Sales &amp; Purchases']" position="attributes"><attribute name="invisible">[('hide', '=', True)]</attribute></xpath>

  2. The other workaround is to assign a new group that has access to the page and let groups other than the one that you don't want to view the element to inherit this new group.  For example you define a new group with XML ID 'group_that_has_access'.  Let all groups except those that should not view the element (except ajuste_did.group_did_del_saes, that is) to inherit from this new group, then redefine the page as follows:

    <xpath expr="/form/notebook/page[@string='Sales &amp; Purchases']" position="attributes"><attribute name="groups">group_that_has_access</attribute></xpath>

1
Avatar
Annuleer
Aitor Bouzas
Auteur

The first workaround is a good one... But it does not seems to work in my case, check the edit in the main post, I have an 'Error ocurred while validating the field(s) arch: Invalid XML for View Architecture!'

Ivan

Could you check the server log to see what is wrong with the XML? Also, have you tried using True, not true as the value to check against?

Aitor Bouzas
Auteur

Thank so much @Ivan, the problem was that the 't' of 'true' had to be in capital letters... Regards and thanks again!

Avatar
Emipro Technologies Pvt. Ltd.
Beste antwoord

Try following:

<xpath expr="/form/notebook/page[@string='Sales &amp; Purchases']" position="attributes">
    <attribute name="groups"><<your group name without quote>></attribute>
</xpath>

Hope this helps!!.

1
Avatar
Annuleer
Aitor Bouzas
Auteur

But this is for adding groups, I want to unlink one group... Am I wrong?

Emipro Technologies Pvt. Ltd.

ok.. then just write down those groups which you want ane remove the one which you don't want. The method remains the same here you can specify the comma separated values of groups.

Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Word een Partner
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة 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 is een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

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