Skip to Content
Menu
This question has been flagged
1 Reply
2940 Views

i tried to delete one of my custom field (ex: x_yz). when i save error popup.

Properties of base fields cannot be altered in this manner! Please modify them through Python code, preferably through a custom addon!


but in miscellaneous, it show type custom field.

how to delete this field

Even when i create or edit , the error in shown up

Avatar
Discard
Best Answer

Hi Arun

The error message "Properties of base fields cannot be altered in this manner! Please modify them through Python code, preferably through a custom addon!" indicates that you're attempting to modify a field that Odoo considers a base field. Base fields are essential fields that are part of Odoo's core framework and cannot be directly edited through the user interface.

In your case, the field "x_yz" is likely considered a base field, even though it appears under the "Custom Field" category in Odoo's Miscellaneous section. This could be due to its underlying relationship with another model or its involvement in some core Odoo functionality.  

To delete this field, you'll need to modify it through Python code. Follow these steps:

  1. Create a Custom Addon: Create a new Odoo module to house the code for deleting the field. This will allow you to make changes to Odoo's code without directly modifying the core files.
  2. Locate the Field Definition: Identify the model where the field "x_yz" is defined. This can be found in the model's .py file, usually under the fields attribute.
  3. Remove the Field Definition: Remove the field definition from the model's fields attribute. This will effectively remove the field from the model and its associated views.
  4. Update the Odoo Database: Once you've modified the field definition, you need to update the Odoo database to reflect the change. This can be done by restarting the Odoo server or manually clearing the database cache.
  5. Verify the Field Deletion: After the Odoo server restarts or the cache is cleared, check the model's form view to ensure the field "x_yz" has been removed.

Here's an example code snippet for removing the field "x_yz" from the res.partner model:

class PartnerCustom(models.Model):

    _inherit = 'res.partner'


    def _remove_x_yz_field(self):

        # Remove the x_yz field from the model's fields attribute

        del self._fields['x_yz']


        # Update the database to reflect the change. This might require restarting the Odoo server or clearing the database cache.


This code defines a new class PartnerCustom that inherits from the res.partner model. It defines a method _remove_x_yz_field that removes the field x_yz from the model's fields attribute. This method can be called to remove the field from the database.


Thanks,

Syama Prajith 

Avatar
Discard
Related Posts Replies Views Activity
2
Dec 24
3867
1
Nov 24
2669
2
Aug 23
2125
2
Apr 23
17179
1
Mar 23
1964