Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
3015 Weergaven

created model to inherit res.users and added 'supervisor' field and i can see this field in pgAdmin and also in Settings ->Technical -> Fields

i am trying to add 'supervisor' in user's form, please check below 2 screenshots, what am i doing wrong here? the inherited Users form not showing my custom field 'supervisor' after partner_id ( Related Partner in below form ). note i have added view file name in manifest file, also added 'base' in manifest file, then start server with upgrade the module using -u custom_module -d db_17 



plesae help.

regards

Avatar
Annuleer
Beste antwoord

The field PARTNER_ID appears twice in the View you are inheriting.

Your field is being added after the FIRST occurrence, which will be hidden unless the User is archived and the Contact is not:

You want to add it after the SECOND occurrence.

See https://www.odoo.com/forum/help-1/select-multiple-elements-with-xpath-116090


You may be misunderstanding the Odoo data model - a User is a set of credentials and access rights - it is not an Employee.

The Employee App already has a Manager:




Avatar
Annuleer
Auteur

thank you @Ray for reply.
yes, Manager is exist but the requirement is what i am trying to implement.

i have modified code (as per what i understand from link provided) but it is still not showing on user's form view, please check what i am missing or doing wrong here.

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Define a new view for inherited model -->
<record id="view_custom_res_user_form" model="ir.ui.view">
<field name="name">custom.res.users.form</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='partner_id'][1]" position="after">
<xpath expr="//field[@name='partner_id'][2]" position="after">
<field name="supervisor"/>
</xpath>
</xpath>
</field>
</record>
</odoo>

regards

Auteur

The error in Odoo.log file as below:

Error while parsing or validating view:

Element '<xpath expr="//field[@name=&#39;partner_id&#39;][2]">' cannot be located in parent view

View error context:
{'file': 'd:\\program files\\odoo '
'17.0.20240101\\server\\odoo\\custom_addons\\brb_customizations\\views\\res_users_view.xml',
'line': 2,
'name': 'custom.res.users.form',
'view': ir.ui.view(1338,),
'view.model': 'res.users',
'view.parent': ir.ui.view(162,),
'xmlid': 'view_custom_res_user_form'}

.

Auteur

sorry @Ray, by mistake i posted above error in Odoo.log please ignore it, it was because of before my posted code in your reply.

Auteur

my first Comment to your Answer is valid, the 2nd one in which i posted error in Odoo.log is not.
waiting for your reply on my first Comment.
regards

In your first comment, you have an xpath inside an xpath and this is not supported.

If you wish to place your field after the second partner_id just reference the second partner_id - you don't need to reference the first at all

Auteur

@Ray
i have check with code below, its not even start Odoo Server and showing errors in odoo.log file as below:
-------
Element '<xpath expr="//field[@name=&#39;partner_id&#39;][2]">' cannot be located in parent view

View error context:
{'file': 'd:\\program files\\odoo '
'17.0.20240101\\server\\odoo\\custom_addons\\brb_customizations\\views\\res_users_view.xml',
'line': 3,
'name': 'custom.res.users.form',
'view': ir.ui.view(1338,),
'view.model': 'res.users',
'view.parent': ir.ui.view(162,),
'xmlid': 'view_custom_res_user_form'}
--------

modified code as per your instruction:

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Define a new view for inherited model -->
<record id="view_custom_res_user_form" model="ir.ui.view">
<field name="name">custom.res.users.form</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='partner_id'][2]" position="after">
<field name="supervisor"/>
</xpath>
</field>
</record>
</odoo>

please advice and help.
regards

Gerelateerde posts Antwoorden Weergaven Activiteit
2
okt. 24
1788
2
jun. 24
1143
0
jan. 24
1357
1
mrt. 20
2772
12
dec. 18
33931