Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged

i want to hide or disable add a properties button, how can i do that.
By the way, I would like to ask how to hide or disable the edit properties field button (pencil icon) and how to require the field when creating the properties field.

Avatar
Zrušit
Nejlepší odpověď
  1. Create a new module or identify the existing module where you want to make the changes.

  2. Inside your module, create a new XML file, let's call it views/assets.xml, and add the following code:

  3. note: here i remove the XML tag like(< >) because when i edit the tag and save the answer the I didn't see the full code of XML,
    so please add the (<>) once you edit the XML file
odoo
data
# Override the field properties view
template id="view_field_property_form_inherit" inherit_id="base.view_field_property_form"
xpath expr="//field[@name='field_id']/form" position="attributes"
#Hide the "Add a Property" button
attribute name="create">0 /xpath
xpath expr="//field[@name='field_id']/form/group/group[1]/field[@name='fields_view_id']/form" position="attributes"
#Disable the "Edit" button
attribute name="options">{'no_edit': True} /xpath
/template
/data
/odoo


In the above code, we override the view_field_property_form template and modify the XML structure using XPath expressions.
  1. In your module's manifest file (e.g., __manifest__.py), make sure to include the XML file in the data section:


{
'name': 'Your Module',
'version': '1.0',
'summary': 'Module Summary',
'data': [
'views/assets.xml',
],
'installable': True,
'application': True,
'auto_install': False,
}
  1. Update the module list and restart the Odoo server for the changes to take effect.

After making these changes, the "Add a Property" button will be hidden, and the "Edit" button will be disabled in the field properties form.

Note that this approach overrides the existing field properties view and applies the modifications globally. If you want to apply the changes to specific models or views, you may need to adjust the XPath expressions accordingly.

Additionally, ensure that you have the necessary access rights to modify views and create a custom module in your Odoo installation.


Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
0
lis 22
1798
1
lis 24
2602
1
kvě 23
1945
1
zář 24
1568
1
úno 23
3930