@ -0,0 +1,48 @@ |
|||||
|
.. image:: https://img.shields.io/badge/licence-OPL--1-red.svg |
||||
|
:target: https://www.odoo.com/documentation/18.0/legal/licenses.html#odoo-apps |
||||
|
:alt: License: OPL-1 |
||||
|
|
||||
|
Remove Studio Fields |
||||
|
==================== |
||||
|
This module helps to remove the fields added using the Studio Module. |
||||
|
|
||||
|
Configuration |
||||
|
============= |
||||
|
Add the users to the new security group 'Remove Studio Fields' to give access to |
||||
|
the new menu item. |
||||
|
|
||||
|
License |
||||
|
------- |
||||
|
Odoo Proprietary License v1.0 (OPL-1) |
||||
|
(https://www.odoo.com/documentation/17.0/legal/licenses.html#odoo-apps) |
||||
|
|
||||
|
Company |
||||
|
------- |
||||
|
* `Cybrosys Techno Solutions <https://cybrosys.com/>`__ |
||||
|
|
||||
|
Credits |
||||
|
------- |
||||
|
Developer: Mruthul Raj @cybrosys, Contact: odoo@cybrosys.com |
||||
|
|
||||
|
Contacts |
||||
|
-------- |
||||
|
* Mail Contact : odoo@cybrosys.com |
||||
|
* Website : https://cybrosys.com |
||||
|
|
||||
|
Bug Tracker |
||||
|
----------- |
||||
|
Bugs are tracked on GitHub Issues. In case of trouble, please check there if |
||||
|
your issue has already been reported. |
||||
|
|
||||
|
Maintainer |
||||
|
========== |
||||
|
.. image:: https://cybrosys.com/images/logo.png |
||||
|
:target: https://cybrosys.com |
||||
|
|
||||
|
This module is maintained by Cybrosys Technologies. |
||||
|
|
||||
|
For support and more information, please visit `Our Website <https://cybrosys.com/>`__ |
||||
|
|
||||
|
Further information |
||||
|
=================== |
||||
|
HTML Description: `<static/description/index.html>`__ |
@ -0,0 +1,23 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################### |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Mruthul Raj (Contact : odoo@cybrosys.com) |
||||
|
# |
||||
|
# This program is under the terms of the Odoo Proprietary License v1.0 |
||||
|
# (OPL-1) |
||||
|
# It is forbidden to publish, distribute, sublicense, or sell copies of the |
||||
|
# Software or modified copies of the Software. |
||||
|
# |
||||
|
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL |
||||
|
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,DAMAGES OR OTHER |
||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,ARISING |
||||
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
|
# DEALINGS IN THE SOFTWARE. |
||||
|
# |
||||
|
############################################################################### |
||||
|
from . import wizard |
@ -0,0 +1,49 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################### |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Mruthul Raj (Contact : odoo@cybrosys.com) |
||||
|
# |
||||
|
# This program is under the terms of the Odoo Proprietary License v1.0 |
||||
|
# (OPL-1) |
||||
|
# It is forbidden to publish, distribute, sublicense, or sell copies of the |
||||
|
# Software or modified copies of the Software. |
||||
|
# |
||||
|
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL |
||||
|
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,DAMAGES OR OTHER |
||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,ARISING |
||||
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
|
# DEALINGS IN THE SOFTWARE. |
||||
|
# |
||||
|
############################################################################### |
||||
|
{ |
||||
|
'name': 'Remove Studio Fields', |
||||
|
'version': '18.0.1.0.0', |
||||
|
'category': 'Extra Tools', |
||||
|
'summary': 'The module helps to remove fields added from Studio', |
||||
|
'description': """ |
||||
|
We can add fields in models and add them in the views of the corresponding |
||||
|
model using the Odoo Studio. In some cases, the type of fields that we |
||||
|
will create will be Basic. This module simplify the deletion of those |
||||
|
fields, and Custom fields created using Odoo Studio. |
||||
|
""", |
||||
|
'author': 'Cybrosys Techno Solutions', |
||||
|
'company': 'Cybrosys Techno Solutions', |
||||
|
'maintainer': 'Cybrosys Techno Solutions', |
||||
|
'website': 'https://www.cybrosys.com', |
||||
|
'depends': ['base', 'web', 'web_studio'], |
||||
|
'data': [ |
||||
|
'security/remove_studio_field_groups.xml', |
||||
|
'security/ir.model.access.csv', |
||||
|
'wizard/remove_studio_field_views.xml' |
||||
|
], |
||||
|
'images': ['static/description/banner.jpg'], |
||||
|
'license': 'OPL-1', |
||||
|
'installable': True, |
||||
|
'auto_install': False, |
||||
|
'application': False |
||||
|
} |
@ -0,0 +1,7 @@ |
|||||
|
## Module <remove_studio_field> |
||||
|
|
||||
|
#### 19.02.2024 |
||||
|
#### Version 178.0.1.0.0 |
||||
|
#### ADD |
||||
|
|
||||
|
- Initial commit for Remove Studio Fields |
|
@ -0,0 +1,14 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
<!-- Module category for the security groups of this module --> |
||||
|
<record id="ir_module_category_remove_studio_field" model="ir.module.category"> |
||||
|
<field name="name">Remove Studio Fields</field> |
||||
|
<field name="description">Helps to manage access to the wizard for removing fields added through Studio</field> |
||||
|
</record> |
||||
|
<!-- Security group to use the Remove Custom Fields wizard --> |
||||
|
<record id="remove_studio_field_group_admin" model="res.groups"> |
||||
|
<field name="name">Administrator</field> |
||||
|
<field name="comment">Access to the Remove Studio Fields wizard menu</field> |
||||
|
<field name="category_id" ref="remove_studio_field.ir_module_category_remove_studio_field"/> |
||||
|
</record> |
||||
|
</odoo> |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 628 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 210 KiB |
After Width: | Height: | Size: 209 KiB |
After Width: | Height: | Size: 109 KiB |
After Width: | Height: | Size: 495 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 624 B |
After Width: | Height: | Size: 136 KiB |
After Width: | Height: | Size: 214 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 310 B |
After Width: | Height: | Size: 929 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 542 B |
After Width: | Height: | Size: 576 B |
After Width: | Height: | Size: 733 B |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 738 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 911 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 600 B |
After Width: | Height: | Size: 673 B |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 926 B |
After Width: | Height: | Size: 9.0 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 878 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 653 B |
After Width: | Height: | Size: 800 B |
After Width: | Height: | Size: 905 B |
After Width: | Height: | Size: 189 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 839 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 427 B |
After Width: | Height: | Size: 627 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 988 B |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 875 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 912 KiB |
After Width: | Height: | Size: 767 KiB |
After Width: | Height: | Size: 1.3 MiB |
After Width: | Height: | Size: 138 KiB |
After Width: | Height: | Size: 697 KiB |
After Width: | Height: | Size: 89 KiB |
After Width: | Height: | Size: 89 KiB |
After Width: | Height: | Size: 126 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 776 KiB |
After Width: | Height: | Size: 105 KiB |
After Width: | Height: | Size: 148 KiB |
After Width: | Height: | Size: 148 KiB |
After Width: | Height: | Size: 144 KiB |
After Width: | Height: | Size: 149 KiB |
After Width: | Height: | Size: 202 KiB |
After Width: | Height: | Size: 167 KiB |
After Width: | Height: | Size: 880 KiB |
After Width: | Height: | Size: 84 KiB |
After Width: | Height: | Size: 8.7 KiB |
@ -0,0 +1,23 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################### |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Mruthul Raj (Contact : odoo@cybrosys.com) |
||||
|
# |
||||
|
# This program is under the terms of the Odoo Proprietary License v1.0 |
||||
|
# (OPL-1) |
||||
|
# It is forbidden to publish, distribute, sublicense, or sell copies of the |
||||
|
# Software or modified copies of the Software. |
||||
|
# |
||||
|
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL |
||||
|
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,DAMAGES OR OTHER |
||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,ARISING |
||||
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
|
# DEALINGS IN THE SOFTWARE. |
||||
|
# |
||||
|
############################################################################### |
||||
|
from . import remove_studio_field |
@ -0,0 +1,120 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################### |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Mruthul Raj (Contact : odoo@cybrosys.com) |
||||
|
# |
||||
|
# This program is under the terms of the Odoo Proprietary License v1.0 |
||||
|
# (OPL-1) |
||||
|
# It is forbidden to publish, distribute, sublicense, or sell copies of the |
||||
|
# Software or modified copies of the Software. |
||||
|
# |
||||
|
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL |
||||
|
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,DAMAGES OR OTHER |
||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,ARISING |
||||
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
|
# DEALINGS IN THE SOFTWARE. |
||||
|
# |
||||
|
############################################################################### |
||||
|
""" |
||||
|
The module helps to remove fields added from Odoo UI or Studio. |
||||
|
""" |
||||
|
import logging |
||||
|
|
||||
|
from odoo import fields, models, _ |
||||
|
from odoo.exceptions import UserError, ValidationError |
||||
|
|
||||
|
_logger = logging.getLogger(__name__) |
||||
|
|
||||
|
|
||||
|
class RemoveStudioField(models.TransientModel): |
||||
|
""" |
||||
|
Wizard to select studio fields(x_studio_) and remove them. |
||||
|
Methods: |
||||
|
action_remove_studio_field(): |
||||
|
Delete the selected studio fields. |
||||
|
""" |
||||
|
_name = 'remove.studio.field' |
||||
|
_description = 'Remove Studio Fields' |
||||
|
|
||||
|
field_ids = fields.Many2many( |
||||
|
'ir.model.fields', string='Studio Fields', required=True, |
||||
|
domain="[('name', 'like', 'x_studio_')]", |
||||
|
help='You can select the fields which are added through Odoo Studio.') |
||||
|
|
||||
|
def action_remove_studio_field(self): |
||||
|
""" Search for the selected fields(x_studio_) in views. If any of the |
||||
|
field is used in any view an error is thrown with the fields and |
||||
|
corresponding views. If the selected fields are not used in any views, |
||||
|
remove them. |
||||
|
Raises: UserError: If any of the selected fields is/are still present |
||||
|
in any view. |
||||
|
Raises: UserError: if there is any error while unlinking the fields. |
||||
|
Returns: |
||||
|
dict: dictionary to show the success notification. |
||||
|
""" |
||||
|
# Makes the given fields clean on all records - remove pending write of |
||||
|
# this field and pop the pending updates of the fields out from the |
||||
|
# cache before unlinking the fields |
||||
|
for record in self.field_ids: |
||||
|
field = self.pool[record.model]._fields.get(record.name, False) |
||||
|
if field: |
||||
|
self.env.cache.clear_dirty_field(field) |
||||
|
error_popup_message = '' |
||||
|
for field in self.field_ids: |
||||
|
self.env[field.model]._pop_field(field.name) |
||||
|
domain = [('arch_db', 'like', field.name), |
||||
|
('model', '=', field.model)] |
||||
|
views = self.env['ir.ui.view'].search(domain) |
||||
|
field_views = [] |
||||
|
for view in views: |
||||
|
try: |
||||
|
view._check_xml() |
||||
|
except ValidationError as error: |
||||
|
_logger.info(error) |
||||
|
field_views.append(view.name) |
||||
|
if field_views: |
||||
|
error_popup_message = '\n'.join( |
||||
|
[error_popup_message, _('Field: %s', field.display_name), |
||||
|
_('Views: %s') % ', '.join( |
||||
|
str(view) for view in field_views) |
||||
|
]) |
||||
|
# If the fields are present in any views, display them, so that those |
||||
|
# can be removed from the mentioned views |
||||
|
if error_popup_message: |
||||
|
# if Studio module is installed, we will perform a module upgrade |
||||
|
studio = self.env['ir.module.module'].sudo().search( |
||||
|
[('name', '=', 'web_studio')], limit=1) |
||||
|
if studio and studio.state == 'installed': |
||||
|
studio.button_immediate_upgrade() |
||||
|
raise UserError('\n'.join([ |
||||
|
_("Cannot delete the fields that are still present in views:"), |
||||
|
error_popup_message |
||||
|
])) |
||||
|
# Set the state of the selected fields as Custom Field(manual) and then |
||||
|
# unlink those fields |
||||
|
query = f""" |
||||
|
UPDATE ir_model_fields set state = 'manual' |
||||
|
WHERE id in {str(tuple(self.field_ids.ids)).replace(',)', ')')}; |
||||
|
DELETE FROM ir_model_fields |
||||
|
WHERE id in {str(tuple(self.field_ids.ids)).replace(',)', ')')}; |
||||
|
""" |
||||
|
try: |
||||
|
self.env.cr.execute(query) |
||||
|
except Exception as error: |
||||
|
raise UserError(f'An error occurred! {error}') from error |
||||
|
return { |
||||
|
'type': 'ir.actions.client', |
||||
|
'tag': 'display_notification', |
||||
|
'params': { |
||||
|
'title': _('Success'), |
||||
|
'message': _('The selected fields are deleted.'), |
||||
|
'sticky': False, |
||||
|
'type': 'success', |
||||
|
'next': {'type': 'ir.actions.act_window_close'}, |
||||
|
} |
||||
|
} |
@ -0,0 +1,45 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<odoo> |
||||
|
<!-- Form view for the Remove Studio Fields wizard --> |
||||
|
<record id="remove_studio_field_view_form" model="ir.ui.view"> |
||||
|
<field name="name">remove.studio.field.view.form</field> |
||||
|
<field name="model">remove.studio.field</field> |
||||
|
<field name="arch" type="xml"> |
||||
|
<form string="Remove Studio Fields"> |
||||
|
<sheet> |
||||
|
<div class="alert alert-danger" role="alert" invisible="not field_ids"> |
||||
|
You will lose the data once you remove the fields! |
||||
|
</div> |
||||
|
<div class="alert alert-info" role="alert" invisible="field_ids"> |
||||
|
You can only select the fields which are added through Odoo Studio(If any)! |
||||
|
</div> |
||||
|
<group colspan="12"> |
||||
|
<field name="field_ids" widget="many2many_tags" |
||||
|
options="{'no_create_edit': True, 'no_create': True}"/> |
||||
|
</group> |
||||
|
<footer> |
||||
|
<button name="action_remove_studio_field" string="Remove Fields" |
||||
|
type="object" disabled="1" invisible="field_ids" |
||||
|
style="border: 1px solid #999999; background-color: #cccccc; color: #666666;"/> |
||||
|
<button name="action_remove_studio_field" string="Remove Fields" |
||||
|
type="object" class="oe_highlight" invisible="not field_ids" |
||||
|
confirm="Are you sure you want to delete the selected fields?"/> |
||||
|
<button string="Cancel" class="btn btn-default" special="cancel"/> |
||||
|
</footer> |
||||
|
</sheet> |
||||
|
</form> |
||||
|
</field> |
||||
|
</record> |
||||
|
<!-- Action window for the Remove Studio Fields wizard --> |
||||
|
<record id="remove_studio_field_action" model="ir.actions.act_window"> |
||||
|
<field name="name">Remove Studio Fields</field> |
||||
|
<field name="res_model">remove.studio.field</field> |
||||
|
<field name="type">ir.actions.act_window</field> |
||||
|
<field name="view_mode">form</field> |
||||
|
<field name="target">new</field> |
||||
|
</record> |
||||
|
<!-- Menu for the Remove Studio Fields wizard --> |
||||
|
<menuitem id="remove_studio_field_menu_action" name="Remove Studio Fields" |
||||
|
action="remove_studio_field_action" parent="base.next_id_9" sequence="5" |
||||
|
groups="remove_studio_field.remove_studio_field_group_admin"/> |
||||
|
</odoo> |