Skip to Content
Odoo मेन्यू
  • Sign in
  • मुफ़्त में आज़माएं
  • ऐप्लिकेशन
    फ़ाइनेंस
    • अकाउंटिंग
    • इनवॉइसिंग
    • एक्सपेंस
    • स्प्रेडशीट (बीआई)
    • डॉक्यूमेंट्स
    • साइन
    सेल्स
    • सीआरएम
    • सेल्स
    • पीओएस शॉप
    • पीओएस रेस्टोरेंट
    • सब्सक्रिप्शन
    • रेंटल
    वेबसाइट
    • वेबसाइट बिल्डर
    • ई-कॉमर्स
    • ब्लॉग
    • फ़ोरम
    • लाइव चैट
    • ई-लर्निंग
    सप्लाई चेन
    • इन्वेंट्री
    • मैन्युफ़ैक्चरिंग
    • पीएलएम
    • परचेज़
    • मेंटेनेंस
    • क्वालिटी
    मानव संसाधन
    • कर्मचारी
    • रिक्रूटमेंट
    • टाइम ऑफ़
    • अप्रेज़ल
    • रेफ़रल
    • फ़्लीट
    मार्केटिंग
    • सोशल मार्केटिंग
    • ईमेल मार्केटिंग
    • एसएमएस मार्केटिंग
    • इवेंट
    • मार्केटिंग ऑटोमेशन
    • सर्वे
    सेवाएं
    • प्रोजेक्ट
    • टाइमशीट
    • फ़ील्ड सर्विस
    • हेल्पडेस्क
    • प्लानिंग
    • अपॉइंटमेंट
    प्रॉडक्टिविटी
    • डिस्कस
    • अप्रूवल
    • आईओटी
    • वीओआईपी
    • नॉलेज
    • WhatsApp
    तीसरे पक्ष के ऐप्लिकेशन Odoo स्टूडियो Odoo क्लाउड प्लेटफ़ॉर्म
  • इंडस्ट्री
    रीटेल
    • बुक स्टोर
    • क्लोदिंग स्टोर
    • फ़र्नीचर स्टोर
    • ग्रॉसरी स्टोर
    • हार्डवेयर स्टोर
    • टॉय स्टोर
    Food & Hospitality
    • बार और पब
    • रेस्टोरेंट
    • फ़ास्ट फ़ूड
    • Guest House
    • बेवरिज डिस्ट्रीब्यूटर
    • होटल
    रियल एस्टेट
    • Real Estate Agency
    • आर्किटेक्चर फ़र्म
    • कंसट्रक्शन
    • एस्टेट मैनेजमेंट
    • गार्ड्निंग
    • प्रॉपर्टी ओनर असोसिएशन
    कंसल्टिंग
    • अकाउंटिंग फ़र्म
    • Odoo पार्टनर
    • मार्केटिंग एजेंसी
    • लॉ फ़र्म
    • टैलेंट ऐक्विज़िशन
    • ऑडिट & सर्टिफ़िकेशन
    मैन्युफ़ैक्चरिंग
    • टेक्सटाइल
    • Metal
    • फ़र्नीचर
    • फ़ूड
    • Brewery
    • कॉर्पोरेट गिफ़्ट
    हेल्थ & फिटनेस
    • स्पोर्ट्स क्लब
    • आईवियर स्टोर
    • फिटनेस सेंटर
    • वेलनेस प्रैक्टिशनर
    • फॉर्मेसी
    • हेयर सैलून
    Trades
    • Handyman
    • आईटी हॉर्डवेयर और सपोर्ट
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    अन्य
    • Nonprofit Organization
    • एन्वायरमेंटल एजेंसी
    • बिलबोर्ड रेंटल
    • फ़ोटोग्राफी
    • बाइक लीजिंग
    • सॉफ़्टवेयर रीसेलर
    Browse all Industries
  • कम्यूनिटी
    सीखें
    • ट्यूटोरियल्स
    • दस्तावेज़
    • सर्टिफ़िकेशन
    • ट्रेनिंग
    • ब्लॉग
    • पॉडकास्ट
    शिक्षा को बढ़ावा दें
    • एजुकेशन प्रोग्राम
    • स्केल अप! बिजनेस गेम
    • Odoo के ऑफ़िस में आएं
    सॉफ़्टवेयर पाएं
    • डाउनलोड
    • वर्शन की तुलना करें
    • रिलीज़
    साथ मिलकर काम करें
    • Github
    • फ़ोरम
    • इवेंट
    • अनुवाद
    • पार्टनर बनें
    • Services for Partners
    • अपना अकाउंटिंग फ़र्म रजिस्टर करें
    सेवाएं पाएं
    • पार्टनर ढूंढें
    • अकाउंटेंट खोजें
    • सलाहकार की मदद लें
    • इम्प्लिमेंटेशन सेवाएं
    • कस्टमर रेफ़रेंस
    • सहायता
    • अपग्रेड
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    डेमो देखें
  • कीमत
  • सहायता

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

  • सीआरएम
  • e-Commerce
  • लेखांकन
  • इन्वेंटरी
  • PoS
  • प्रोजेक्ट
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
Help

Error Access when implement custom field on inherited view res.users

Subscribe

Get notified when there's activity on this post

This question has been flagged
res.usersodooV17OdooV17
1 Reply
3022 Views
Avatar
Aji Ananta

I make field custom type binary (x_signature) to model res.users, and i try to add this custom field to view. When i implement this, when user click My Profile get Access Error. Its solved if i grant user access to Employees both administrator/officer. but i don't want it. i want still implement custom field on inherited view without give grant access Employees and not access error


Inherited view: res.users.preferences.form.inherit

<data>
    <xpath expr="//field[@name='employee_type']" position="after">
        <field name="x_signature" widget="image"/>
    </xpath>
</data>

Access Error

Access Error

Close

The requested operation can not be completed due to security restrictions. Document type: User (res.users) Operation: read User: 14 Fields: - barcode (allowed for groups 'Employees / Officer: Manage all employees') - birthday (allowed for groups 'Employees / Officer: Manage all employees') - certificate (allowed for groups 'Employees / Officer: Manage all employees') - children (allowed for groups 'Employees / Officer: Manage all employees') - country_of_birth (allowed for groups 'Employees / Officer: Manage all employees') - emergency_contact (allowed for groups 'Employees / Officer: Manage all employees') - emergency_phone (allowed for groups 'Employees / Officer: Manage all employees') - employee_bank_account_id (allowed for groups 'Employees / Officer: Manage all employees')

... ...

...

0
Avatar
Discard
Avatar
Gracious Joseph
Best Answer

The Access Error occurs because the res.users model and its inherited fields (such as fields added by the Employees module) require specific access rights that your users do not have. When you add a custom field (x_signature) to the res.users model, any reference to that field in the res.users view triggers access checks for related fields as well. In this case, fields inherited from hr.employee (e.g., barcode, birthday) are restricted to users with specific Employee-related permissions.

Here’s how you can resolve this without granting additional access rights to the Employees module:

Solution 1: Use a Separate Model for the Custom Field

Instead of adding the custom field (x_signature) directly to res.users, create a new model and link it to res.users. This isolates your custom field from access rules defined for the Employees module.

  1. Create a New Model: Define a new model (res.user.signature) with a Many2One relation to res.users:
    pythonCopy codefrom odoo import models, fields
    
    class ResUserSignature(models.Model):
        _name = 'res.user.signature'
        _description = 'User Signature'
    
        user_id = fields.Many2one('res.users', string="User", required=True, ondelete='cascade')
        signature = fields.Binary(string="Signature")
    
  2. Add the Field to the View: Extend the res.users view to include the signature field from the new model:
    xmlCopy code<record id="view_res_users_signature" model="ir.ui.view">
        <field name="name">res.users.signature.form.inherit</field>
        <field name="model">res.users</field>
        <field name="inherit_id" ref="base.view_users_form" />
        <field name="arch" type="xml">
            <xpath expr="//field[@name='employee_type']" position="after">
                <field name="user_signature_ids.signature" widget="image"/>
            </xpath>
        </field>
    </record>
    
    • Ensure you add a computed or related field in res.users to link the signature:
      pythonCopy codeclass ResUsers(models.Model):
          _inherit = 'res.users'
      
          user_signature_ids = fields.One2many(
              'res.user.signature', 'user_id', string="Signatures"
          )
      
  3. Test Access Rights: This approach isolates the x_signature field, and users will not encounter access errors since you’re no longer inheriting restricted fields from hr.employee.

Solution 2: Adjust Field Access Control

If you need to keep the x_signature field on the res.users model, explicitly set its access rights to make it accessible for users without permissions to the Employees module.

  1. Grant Access to the Custom Field: Add a record rule or modify field-level security for x_signature:
    pythonCopy codefrom odoo import models, fields
    
    class ResUsers(models.Model):
        _inherit = 'res.users'
    
        x_signature = fields.Binary(string="Signature", groups="base.group_user")
    
    • The groups="base.group_user" ensures that all regular users can access this field.
  2. Ensure the Field is Readable by All Users:
    • If the default security on res.users restricts access to fields such as barcode or birthday, ensure your custom field doesn’t trigger access checks for restricted fields. Use sudo() in your Python code if necessary when reading or writing the field.

Solution 3: Use Computed or Related Fields

If the custom field is related to hr.employee but needs to be accessible in res.users, use a computed field that respects user permissions.

  1. Add a Computed Field: Define the x_signature field as a computed field:
    pythonCopy codeclass ResUsers(models.Model):
        _inherit = 'res.users'
    
        x_signature = fields.Binary(string="Signature", compute="_compute_signature")
    
        def _compute_signature(self):
            for user in self:
                if user.employee_id:
                    user.x_signature = user.employee_id.sudo().x_signature
                else:
                    user.x_signature = False
    
  2. Test Access: Using sudo() ensures that the computation bypasses the restrictive access rules for employee_id fields, while users can still view the field on the form.

Solution 4: Adjust the Record Rule for res.users

If you prefer to adjust access rules directly:

  1. Relax the Record Rules: Identify the restrictive record rules for res.users (related to the Employees module) and customize them. For example, you might find rules like this:
    xmlCopy code<record id="hr_employee_rule_users" model="ir.rule">
        <field name="name">Employees: User Read Access</field>
        <field name="model_id" ref="base.model_res_users" />
        <field name="groups" eval="[(4, ref('hr.group_hr_user'))]" />
        <field name="domain_force">['|', ('id', '=', user.id), ('employee_ids', '!=', False)]</field>
    </record>
    
    • Modify or disable the restrictive rule, but note that this is not recommended as it might introduce unintended side effects.

Conclusion

The best solution depends on your specific use case:

  • Use Solution 1 if you want a clean separation of concerns (best practice).
  • Use Solution 2 if you want to simplify and directly expose the custom field.
  • Use Solution 3 if the field is related to hr.employee but should respect access rights.

1
Avatar
Discard
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
disable edit on sale order
sale.order odooV17 OdooV17
Avatar
Avatar
Avatar
3
अक्तू॰ 25
676
Easypost default package
odooV17
Avatar
Avatar
1
सित॰ 25
1126
Adding a Button in POS
odooV17
Avatar
Avatar
1
जन॰ 25
2515
How to Restrict Default CRM Access for All Users in Odoo 17 and Assign Permissions Selectively
odooV17
Avatar
Avatar
1
नव॰ 24
2956
Purchase order confirmation data display without time Solved
odooV17
Avatar
Avatar
Avatar
2
सित॰ 24
2409
कम्यूनिटी
  • ट्यूटोरियल्स
  • दस्तावेज़
  • फ़ोरम
ओपन सोर्स
  • डाउनलोड
  • Github
  • रनबॉट
  • अनुवाद
सेवाएं
  • Odoo.sh Hosting
  • सहायता
  • अपग्रेड
  • कस्टम डेवलपमेंट्स
  • शिक्षा
  • अकाउंटेंट खोजें
  • पार्टनर ढूंढें
  • पार्टनर बनें
हमारे बारे में
  • हमारी कंपनी
  • ब्रांड ऐसेट
  • संपर्क करें
  • नौकरियां
  • इवेंट
  • पॉडकास्ट
  • ब्लॉग
  • ग्राहक
  • लीगल • गोपनीयता
  • सुरक्षा
الْعَرَبيّة 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, बिज़नेस से जुड़े ऐप्लिकेशन का एक कलेक्शन है जो ओपन सोर्स पर आधारित है. इसमें आपकी कंपनी की हर ज़रूरत के लिए ऐप्लिकेशन हैं. जैसे, सीआरएम, ई-कॉमर्स, अकाउंटिंग, इन्वेंट्री, पॉइंट ऑफ़ सेल, प्रोजेक्ट मैनेजमेंट वगैरह.

Odoo की सबसे बड़ी खासियत है कि यह इस्तेमाल करने में बहुत आसान है और यह पूरी तरह से इंटिग्रेट किया हुआ है.

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