Browse Source

Jun 14: [FIX] Bug Fixed 'all_in_one_dynamic_custom_fields'

14.0
RisvanaCybro 11 months ago
parent
commit
32338edcf4
  1. 6
      all_in_one_dynamic_custom_fields/__init__.py
  2. 8
      all_in_one_dynamic_custom_fields/__manifest__.py
  3. 5
      all_in_one_dynamic_custom_fields/doc/RELEASE_NOTES.md
  4. 6
      all_in_one_dynamic_custom_fields/models/__init__.py
  5. 6
      all_in_one_dynamic_custom_fields/models/dynamic_field_widgets.py
  6. 125
      all_in_one_dynamic_custom_fields/models/dynamic_fields.py
  7. 6
      all_in_one_dynamic_custom_fields/models/ir_model_fields.py
  8. BIN
      all_in_one_dynamic_custom_fields/static/description/assets/screenshots/01.png
  9. BIN
      all_in_one_dynamic_custom_fields/static/description/assets/screenshots/02.png
  10. BIN
      all_in_one_dynamic_custom_fields/static/description/assets/screenshots/03.png
  11. BIN
      all_in_one_dynamic_custom_fields/static/description/assets/screenshots/04.png
  12. BIN
      all_in_one_dynamic_custom_fields/static/description/assets/screenshots/05.png
  13. BIN
      all_in_one_dynamic_custom_fields/static/description/assets/screenshots/06.png
  14. BIN
      all_in_one_dynamic_custom_fields/static/description/assets/screenshots/07.png
  15. 14
      all_in_one_dynamic_custom_fields/static/description/index.html
  16. 56
      all_in_one_dynamic_custom_fields/views/dynamic_fields_views.xml

6
all_in_one_dynamic_custom_fields/__init__.py

@ -1,9 +1,9 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################### ################################################################################
# #
# Cybrosys Technologies Pvt. Ltd. # Cybrosys Technologies Pvt. Ltd.
# #
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). # Copyright (C) 2024-TODAY Cybrosys Technologies (<https://www.cybrosys.com>)
# Author: Ruksana P (<https://www.cybrosys.com>) # Author: Ruksana P (<https://www.cybrosys.com>)
# #
# This program is free software: you can modify # This program is free software: you can modify
@ -19,5 +19,5 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
# #
############################################################################### ################################################################################
from . import models from . import models

8
all_in_one_dynamic_custom_fields/__manifest__.py

@ -1,9 +1,9 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################### ################################################################################
# #
# Cybrosys Technologies Pvt. Ltd. # Cybrosys Technologies Pvt. Ltd.
# #
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). # Copyright (C) 2024-TODAY Cybrosys Technologies (<https://www.cybrosys.com>)
# Author: Ruksana P (<https://www.cybrosys.com>) # Author: Ruksana P (<https://www.cybrosys.com>)
# #
# This program is free software: you can modify # This program is free software: you can modify
@ -19,10 +19,10 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
# #
############################################################################### ################################################################################
{ {
'name': 'All In One Dynamic Fields', 'name': 'All In One Dynamic Fields',
'version': '14.0.1.0.0', 'version': '14.0.1.1.1',
'category': 'Extra Tools', 'category': 'Extra Tools',
'summary': 'Create Custom Fields As Per Your Need Without Any Coding.', 'summary': 'Create Custom Fields As Per Your Need Without Any Coding.',
'description': """This module is used to add dynamic field of any type to 'description': """This module is used to add dynamic field of any type to

5
all_in_one_dynamic_custom_fields/doc/RELEASE_NOTES.md

@ -4,3 +4,8 @@
#### Version 14.0.1.0.0 #### Version 14.0.1.0.0
##### ADD ##### ADD
- Initial commit for All In One Dynamic Fields - Initial commit for All In One Dynamic Fields
#### 14.06.2024
#### Version 14.0.1.1.1
##### UPDATE
- The latest module update includes enhancements to the list view configuration. You can now add the newly created field to the selected list view at the desired position, with the option to enable or disable its visibility by default.

6
all_in_one_dynamic_custom_fields/models/__init__.py

@ -1,9 +1,9 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################### ################################################################################
# #
# Cybrosys Technologies Pvt. Ltd. # Cybrosys Technologies Pvt. Ltd.
# #
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). # Copyright (C) 2024-TODAY Cybrosys Technologies (<https://www.cybrosys.com>)
# Author: Ruksana P (<https://www.cybrosys.com>) # Author: Ruksana P (<https://www.cybrosys.com>)
# #
# This program is free software: you can modify # This program is free software: you can modify
@ -19,7 +19,7 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
# #
############################################################################### ################################################################################
from . import dynamic_fields from . import dynamic_fields
from . import dynamic_field_widgets from . import dynamic_field_widgets
from . import ir_model_fields from . import ir_model_fields

6
all_in_one_dynamic_custom_fields/models/dynamic_field_widgets.py

@ -1,9 +1,9 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################### ################################################################################
# #
# Cybrosys Technologies Pvt. Ltd. # Cybrosys Technologies Pvt. Ltd.
# #
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). # Copyright (C) 2024-TODAY Cybrosys Technologies (<https://www.cybrosys.com>)
# Author: Ruksana P (<https://www.cybrosys.com>) # Author: Ruksana P (<https://www.cybrosys.com>)
# #
# This program is free software: you can modify # This program is free software: you can modify
@ -19,7 +19,7 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
# #
############################################################################### ################################################################################
from odoo import models, fields from odoo import models, fields

125
all_in_one_dynamic_custom_fields/models/dynamic_fields.py

@ -1,9 +1,9 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################### ################################################################################
# #
# Cybrosys Technologies Pvt. Ltd. # Cybrosys Technologies Pvt. Ltd.
# #
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). # Copyright (C) 2024-TODAY Cybrosys Technologies (<https://www.cybrosys.com>)
# Author: Ruksana P (<https://www.cybrosys.com>) # Author: Ruksana P (<https://www.cybrosys.com>)
# #
# This program is free software: you can modify # This program is free software: you can modify
@ -19,7 +19,9 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
# #
############################################################################### ################################################################################
from xlrd.xlsx import ET
from odoo import api, fields, models, _ from odoo import api, fields, models, _
from odoo.exceptions import ValidationError from odoo.exceptions import ValidationError
@ -39,18 +41,22 @@ class DynamicFields(models.Model):
field_list.remove(('reference', 'reference')) field_list.remove(('reference', 'reference'))
return field_list return field_list
dynamic_field_id = fields.Many2one('ir.model.fields', string='Field Name', dynamic_field_id = fields.Many2one('ir.model.fields',
string='Field Name',
required=True, ondelete='cascade', required=True, ondelete='cascade',
help='Please Enter the name of field') help='Please Enter the name of field')
position = fields.Selection([('before', 'Before'), ('after', 'After')], position = fields.Selection([('before', 'Before'),
('after', 'After')],
string='Position', required=True, string='Position', required=True,
help='Select the position of dynamic field ' help='Select the position of dynamic field '
'relative to reference field') 'relative to reference field')
model_id = fields.Many2one('ir.model', string='Model', required=True, model_id = fields.Many2one('ir.model', string='Model',
required=True,
index=True, ondelete='cascade', index=True, ondelete='cascade',
help="Mention the model name for this field " help="Mention the model name for this field "
"to be added") "to be added")
ref_model_id = fields.Many2one('ir.model', string='Reference Model', ref_model_id = fields.Many2one('ir.model',
string='Reference Model',
help='Choose the model id for which we want ' help='Choose the model id for which we want '
'to add field', index=True, ) 'to add field', index=True, )
selection_field = fields.Char(string="Selection Options", selection_field = fields.Char(string="Selection Options",
@ -60,36 +66,65 @@ class DynamicFields(models.Model):
help='Select the field type here') help='Select the field type here')
ttype = fields.Selection(string="Field Type", related='field_type', ttype = fields.Selection(string="Field Type", related='field_type',
help='Select the field type here') help='Select the field type here')
widget_id = fields.Many2one('dynamic.field.widgets', string='Widget', widget_id = fields.Many2one('dynamic.field.widgets',
string='Widget',
help='Choose the field widget') help='Choose the field widget')
groups = fields.Many2many('res.groups', 'employee_dynamic_fields_group_rel', groups = fields.Many2many('res.groups',
'field_id', 'group_id', string='Group', 'employee_dynamic_fields_group_rel',
'field_id', 'group_id',
string='Group',
help='Enter the group for which this field is' help='Enter the group for which this field is'
' visible') ' visible')
is_extra_features = fields.Boolean(string="Show Extra Properties", is_extra_features = fields.Boolean(string="Show Extra Properties",
help='Please enable this field for extra' help='Please enable this field for extra'
' attributes') ' attributes')
status = fields.Selection([('draft', 'Draft'), ('form', 'Field Created'), status = fields.Selection([('draft', 'Draft'),
('tree', 'Added in Tree View')], string='Status', ('form', 'Field Created'),
('tree', 'Added in Tree View')],
string='Status',
index=True, readonly=True, tracking=True, index=True, readonly=True, tracking=True,
copy=False, default='draft', copy=False, default='draft',
help='The status of dynamic field creation') help='The status of dynamic field creation')
form_view_id = fields.Many2one('ir.ui.view', string="Form View ID", form_view_id = fields.Many2one('ir.ui.view',
required=True, help='Enter the form view id') string="Form View ID",
required=True,
help='Enter the form view id')
form_view_inherit = fields.Char(string="Form View Inherit Id", form_view_inherit = fields.Char(string="Form View Inherit Id",
related='form_view_id.xml_id', related='form_view_id.xml_id',
help='Enter the inherited form view id') help='Enter the inherited form view id')
custom_form_view_id = fields.Many2one('ir.ui.view', string="Form View ID", custom_form_view_id = fields.Many2one('ir.ui.view',
string="Form View ID",
help='Enter the custom form view id') help='Enter the custom form view id')
is_field_in_tree = fields.Boolean(string="Add Field to the Tree View", is_field_in_tree = fields.Boolean(string="Add Field to the Tree View",
help='Enable for tree view') help='Enable for tree view')
tree_view_id = fields.Many2one('ir.ui.view', string="Tree View ID", tree_view_id = fields.Many2one('ir.ui.view',
string="Tree View ID",
help='Enter the tree view id', ) help='Enter the tree view id', )
tree_view_inherit = fields.Char(string="Tree View Inherit Id", tree_view_inherit = fields.Char(string="Tree View Inherit Id",
related='tree_view_id.xml_id', related='tree_view_id.xml_id',
help='Enter the inherited tree view id') help='Enter the inherited tree view id')
custom_tree_view_id = fields.Many2one('ir.ui.view', string="Tree View ID", custom_tree_view_id = fields.Many2one('ir.ui.view',
string="Tree View ID",
help='Enter the custom tree view id') help='Enter the custom tree view id')
tree_field_ids = fields.Many2many('ir.model.fields',
string='Tree field domain field',
compute='_compute_tree_field_ids',
help='Tree fields domain')
tree_field_id = fields.Many2one('ir.model.fields',
string='Tree Field',
domain="[('id', 'in', "
"tree_field_ids)]",
help='Tree field')
tree_field_position = fields.Selection([('before', 'Before'),
('after', 'After')],
string='Position',
help='Select the position of '
'dynamic field relative to '
'reference field in tree view')
is_visible_in_tree_view = fields.Boolean(string='Visible in tree view',
help='Weather toggle visible the '
'newly created field in '
'tree view')
@api.onchange('model_id') @api.onchange('model_id')
def _onchange_model_id(self): def _onchange_model_id(self):
@ -107,6 +142,34 @@ class DynamicFields(models.Model):
'dynamic_field_id': [('id', 'in', field_list)] 'dynamic_field_id': [('id', 'in', field_list)]
}} }}
@api.depends('tree_view_id')
def _compute_tree_field_ids(self):
"""Compute function to find the tree view fields of selected tree view
in field tree_view_id"""
for rec in self:
if rec.tree_view_id:
field_list = []
if rec.tree_view_id.xml_id:
tree_fields = ET.fromstring(self.env.ref(
rec.tree_view_id.xml_id).arch).findall(".//field")
for field in tree_fields:
field_list.append(field.get('name'))
inherit_id = rec.tree_view_id.inherit_id \
if rec.tree_view_id.inherit_id else False
while inherit_id:
if inherit_id.xml_id:
tree_fields = ET.fromstring(self.env.ref(
inherit_id.xml_id).arch).findall(".//field")
for field in tree_fields:
field_list.append(field.get('name'))
inherit_id = inherit_id.inherit_id \
if inherit_id.inherit_id else False
self.tree_field_ids = self.env['ir.model.fields'].search(
[('model_id', '=', self.model_id.id),
('name', 'in', field_list)])
else:
rec.tree_field_ids = False
@api.onchange('field_type') @api.onchange('field_type')
def _onchange_field_type(self): def _onchange_field_type(self):
"""When changing field type, this method returns widget of """When changing field type, this method returns widget of
@ -118,7 +181,7 @@ class DynamicFields(models.Model):
'float': [('name', '=', 'monetary')], 'float': [('name', '=', 'monetary')],
'many2one': [('name', '=', 'selection')], 'many2one': [('name', '=', 'selection')],
} }
return {'domain': {'widget': widget_mapping.get(self.field_type, return {'domain': {'widget_id': widget_mapping.get(self.field_type,
[('id', '=', False)])}} [('id', '=', False)])}}
def action_create_dynamic_fields(self): def action_create_dynamic_fields(self):
@ -197,13 +260,13 @@ class DynamicFields(models.Model):
inherit_tree_view_name = str( inherit_tree_view_name = str(
self.tree_view_id.name) + ".inherit.dynamic.custom" + \ self.tree_view_id.name) + ".inherit.dynamic.custom" + \
str(self.field_description) + ".field" str(self.field_description) + ".field"
tree_view_arch_base = _( optional = "show" if self.is_visible_in_tree_view else "hide"
'<?xml version="1.0"?>' tree_view_arch_base = (_(f'''
'<data>' <data>
'''<xpath expr="//tree" position="inside">''' <xpath expr="//field[@name='{self.tree_field_id.name}']" position="{self.tree_field_position}">
'''<field name="%s" optional="show"/>''' <field name="{self.name}" optional="{optional}"/>
'''</xpath>''' </xpath>
'''</data>''') % self.name </data>'''))
self.custom_tree_view_id = self.env['ir.ui.view'].sudo().create( self.custom_tree_view_id = self.env['ir.ui.view'].sudo().create(
{'name': inherit_tree_view_name, {'name': inherit_tree_view_name,
'type': 'tree', 'type': 'tree',
@ -222,14 +285,13 @@ class DynamicFields(models.Model):
_('Error! Selected Model You cannot add a custom field to the ' _('Error! Selected Model You cannot add a custom field to the '
'tree view.')) 'tree view.'))
@api.depends('model_id') @api.onchange('model_id', 'is_field_in_tree')
@api.onchange('model_id')
def onchange_domain(self): def onchange_domain(self):
"""Return the fields that currently present in the form""" """Return the fields that currently present in the form"""
form_view_ids = self.model_id.view_ids.filtered( form_view_ids = self.model_id.view_ids.filtered(
lambda l: l.type == 'form' and l.mode == 'primary') lambda x: x.type == 'form' and x.mode == 'primary')
tree_view_ids = self.model_id.view_ids.filtered( tree_view_ids = self.model_id.view_ids.filtered(
lambda l: l.type == 'tree' and l.mode == 'primary') lambda x: x.type == 'tree' and x.mode == 'primary')
field_records = self.env['ir.model.fields'].sudo().search([ field_records = self.env['ir.model.fields'].sudo().search([
('model', '=', self.model_id.model)]) ('model', '=', self.model_id.model)])
field_list = [field.id for record in field_records for field in record] field_list = [field.id for record in field_records for field in record]
@ -239,7 +301,6 @@ class DynamicFields(models.Model):
'position_field': [('id', 'in', field_list)] 'position_field': [('id', 'in', field_list)]
}} }}
@api.depends('field_type')
@api.onchange('field_type') @api.onchange('field_type')
def onchange_field_type(self): def onchange_field_type(self):
""""Onchange method of field_type, when changing field type it will """"Onchange method of field_type, when changing field type it will
@ -257,8 +318,8 @@ class DynamicFields(models.Model):
def unlink(self): def unlink(self):
""" Unlinking method of dynamic field""" """ Unlinking method of dynamic field"""
if self.form_view_id: if self.form_view_id:
self.form_view_id.active = False self.custom_form_view_id.active = False
if self.tree_view_id: if self.tree_view_id:
self.tree_view_id.active = False self.custom_tree_view_id.active = False
result = super().unlink() result = super().unlink()
return result return result

6
all_in_one_dynamic_custom_fields/models/ir_model_fields.py

@ -1,9 +1,9 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################### ################################################################################
# #
# Cybrosys Technologies Pvt. Ltd. # Cybrosys Technologies Pvt. Ltd.
# #
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). # Copyright (C) 2024-TODAY Cybrosys Technologies (<https://www.cybrosys.com>)
# Author: Ruksana P (<https://www.cybrosys.com>) # Author: Ruksana P (<https://www.cybrosys.com>)
# #
# This program is free software: you can modify # This program is free software: you can modify
@ -19,7 +19,7 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
# #
############################################################################### ################################################################################
from odoo import models, fields from odoo import models, fields

BIN
all_in_one_dynamic_custom_fields/static/description/assets/screenshots/01.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

BIN
all_in_one_dynamic_custom_fields/static/description/assets/screenshots/02.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

BIN
all_in_one_dynamic_custom_fields/static/description/assets/screenshots/03.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

BIN
all_in_one_dynamic_custom_fields/static/description/assets/screenshots/04.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

BIN
all_in_one_dynamic_custom_fields/static/description/assets/screenshots/05.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB

BIN
all_in_one_dynamic_custom_fields/static/description/assets/screenshots/06.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

BIN
all_in_one_dynamic_custom_fields/static/description/assets/screenshots/07.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 KiB

14
all_in_one_dynamic_custom_fields/static/description/index.html

@ -193,7 +193,7 @@
Open the module and Click CREATE button to create new custom Open the module and Click CREATE button to create new custom
fields and fill the details.Then click the CREATE FIELD.</p> fields and fill the details.Then click the CREATE FIELD.</p>
<img src="assets/screenshots/2.png" class="img-thumbnail"> <img src="assets/screenshots/2.png" class="img-thumbnail">
<img src="assets/screenshots/3.png" class="img-thumbnail"> <img src="assets/screenshots/01.png" class="img-thumbnail">
</div> </div>
<div style="display: block; margin: 30px auto;"> <div style="display: block; margin: 30px auto;">
<h3 style="font-family: 'Montserrat', sans-serif; font-size: 18px; font-weight: bold;"> <h3 style="font-family: 'Montserrat', sans-serif; font-size: 18px; font-weight: bold;">
@ -202,7 +202,7 @@
<p style="font-weight: 400; font-family: 'Montserrat', sans-serif; font-size: 14px;"> <p style="font-weight: 400; font-family: 'Montserrat', sans-serif; font-size: 14px;">
Select the Model for which you want to create a custom Select the Model for which you want to create a custom
field.</p> field.</p>
<img src="assets/screenshots/4.png" class="img-thumbnail"> <img src="assets/screenshots/02.png" class="img-thumbnail">
</div> </div>
<div style="display: block; margin: 30px auto;"> <div style="display: block; margin: 30px auto;">
<h3 style="font-family: 'Montserrat', sans-serif; font-size: 18px; font-weight: bold;"> <h3 style="font-family: 'Montserrat', sans-serif; font-size: 18px; font-weight: bold;">
@ -210,7 +210,7 @@
</h3> </h3>
<p style="font-weight: 400; font-family: 'Montserrat', sans-serif; font-size: 14px;"> <p style="font-weight: 400; font-family: 'Montserrat', sans-serif; font-size: 14px;">
Choose the Field Type</p> Choose the Field Type</p>
<img src="assets/screenshots/5.png" class="img-thumbnail"> <img src="assets/screenshots/03.png" class="img-thumbnail">
</div> </div>
<div style="display: block; margin: 30px auto;"> <div style="display: block; margin: 30px auto;">
<h3 style="font-family: 'Montserrat', sans-serif; font-size: 18px; font-weight: bold;"> <h3 style="font-family: 'Montserrat', sans-serif; font-size: 18px; font-weight: bold;">
@ -219,7 +219,7 @@
<p style="font-weight: 400; font-family: 'Montserrat', sans-serif; font-size: 14px;"> <p style="font-weight: 400; font-family: 'Montserrat', sans-serif; font-size: 14px;">
The custom field also we can add to the module List/Tree view. The custom field also we can add to the module List/Tree view.
</p> </p>
<img src="assets/screenshots/6.png" class="img-thumbnail"> <img src="assets/screenshots/04.png" class="img-thumbnail">
<img src="assets/screenshots/7.png" class="img-thumbnail"> <img src="assets/screenshots/7.png" class="img-thumbnail">
<img src="assets/screenshots/8.png" class="img-thumbnail"> <img src="assets/screenshots/8.png" class="img-thumbnail">
</div> </div>
@ -229,7 +229,7 @@
</h3> </h3>
<p style="font-weight: 400; font-family: 'Montserrat', sans-serif; font-size: 14px;"> <p style="font-weight: 400; font-family: 'Montserrat', sans-serif; font-size: 14px;">
A new custom field is created in the sale order form view.</p> A new custom field is created in the sale order form view.</p>
<img src="assets/screenshots/9.png" class="img-thumbnail"> <img src="assets/screenshots/05.png" class="img-thumbnail">
</div> </div>
<div style="display: block; margin: 30px auto;"> <div style="display: block; margin: 30px auto;">
<h3 style="font-family: 'Montserrat', sans-serif; font-size: 18px; font-weight: bold;"> <h3 style="font-family: 'Montserrat', sans-serif; font-size: 18px; font-weight: bold;">
@ -237,8 +237,8 @@
</h3> </h3>
<p style="font-weight: 400; font-family: 'Montserrat', sans-serif; font-size: 14px;"> <p style="font-weight: 400; font-family: 'Montserrat', sans-serif; font-size: 14px;">
A new custom field is created in the sale order tree view.</p> A new custom field is created in the sale order tree view.</p>
<img src="assets/screenshots/10.png" class="img-thumbnail"> <img src="assets/screenshots/06.png" class="img-thumbnail">
<img src="assets/screenshots/11.png" class="img-thumbnail"> <img src="assets/screenshots/07.png" class="img-thumbnail">
</div> </div>
</div> </div>
</div> </div>

56
all_in_one_dynamic_custom_fields/views/dynamic_fields_views.xml

@ -35,60 +35,66 @@
<sheet> <sheet>
<group> <group>
<group string="Field Info"> <group string="Field Info">
<field name="name"/> <field name="name" attrs="{'readonly': [('status', '!=', 'draft')]}"/>
<field name="field_description"/> <field name="field_description" attrs="{'readonly': [('status', '!=', 'draft')]}"/>
<field name="state" readonly="1" <field name="state" readonly="1"
groups="base.group_no_one"/> groups="base.group_no_one"/>
<field name="model_id" <field name="model_id" attrs="{'readonly': [('status', '!=', 'draft')]}"
options='{"no_open": True, "no_create": True}'/> options='{"no_open": True, "no_create": True}'/>
<field name="field_type"/> <field name="field_type" attrs="{'readonly': [('status', '!=', 'draft')]}"/>
<field name="selection_field" <field name="selection_field"
placeholder="[('blue', 'Blue'),('yellow', 'Yellow')]" placeholder="[('blue', 'Blue'),('yellow', 'Yellow')]"
attrs="{'required': [('field_type','in',['selection','reference'])], attrs="{'required': [('field_type','in',['selection','reference'])],
'readonly': [('field_type','not in',['selection','reference'])], 'readonly': ['|',('field_type','not in',['selection','reference']),('status', '!=', 'draft')],
'invisible': [('field_type','not in',['selection','reference'])]}"/> 'invisible': [('field_type','not in',['selection','reference'])]}"/>
<field name="ref_model_id" <field name="ref_model_id"
options='{"no_open": True, "no_create": True}' options='{"no_open": True, "no_create": True}'
attrs="{'required': [('field_type','in',['many2one','many2many'])], attrs="{'required': [('field_type','in',['many2one','many2many'])],
'readonly': [('field_type','not in',['many2one','many2many'])], 'readonly': [('field_type','not in',['many2one','many2many'])],
'invisible': [('field_type','not in',['many2one','many2many'])]}"/> 'invisible': [('field_type','not in',['many2one','many2many'])],
'readonly': [('status', '!=', 'draft')]}"/>
<field name="widget_id" widget="selection" <field name="widget_id" widget="selection"
attrs="{'invisible': [('field_type','not in',['binary', 'many2many', 'selection', 'float', 'many2one'])]}"/> attrs="{'invisible': [('field_type','not in',['binary', 'many2many', 'selection', 'float', 'many2one'])],'readonly': [('status', '!=', 'draft')]}"/> <field name="required" attrs="{'readonly': [('status', '!=', 'draft')]}"/>
<field name="required"/> <field name="form_view_id" options='{"no_open": True, "no_create": True}' attrs="{'readonly': [('status', '!=', 'draft')]}"/>
<field name="form_view_id" <field name="custom_form_view_id" options='{"no_open": True, "no_create": True}'
attrs="{'invisible': [('status', 'in', ['form','tree'])]}"/> invisible="1"/>
<field name="custom_form_view_id"
attrs="{'invisible': [('status', '=', 'draft')]}"/>
<field name="form_view_inherit"/> <field name="form_view_inherit"/>
</group> </group>
<group string="Tree View" <group string="Tree View"
attrs="{'invisible': [('status', '=', 'draft')]}"> attrs="{'invisible': [('status', '=', 'draft')]}">
<field name="is_field_in_tree"/> <field name="is_field_in_tree" attrs="{'readonly': [('status', 'not in', ['draft', 'form'])]}"/>
<field name="tree_view_id" attrs="{'invisible': ['|',('is_field_in_tree', '=', False) ,('status','in',['tree','draft'])], <field name="tree_view_id" options='{"no_open": True, "no_create": True}' attrs="{'invisible': [('is_field_in_tree', '=', False)],
'required': [('is_field_in_tree', '=', True)]}"/> 'required': [('is_field_in_tree', '=', True)], 'readonly': [('status', 'not in', ['draft', 'form'])]}"/>
<field name="custom_tree_view_id" attrs="{'invisible': [('status','in',['form','draft'])], <field name="custom_tree_view_id" options='{"no_open": True, "no_create": True}' attrs="{'invisible': [('status','in',['form','draft', 'tree'])],
'required': [('status', '=', 'tree')]}"/> 'required': [('status', '=', 'tree')]}"/>
<field name="tree_view_inherit" <field name="tree_view_inherit"
attrs="{'invisible': [('is_field_in_tree', '=', False)]}"/> attrs="{'invisible': [('is_field_in_tree', '=', False)]}"/>
<field name="tree_field_id" options='{"no_open": True, "no_create": True}' attrs="{'invisible': [('is_field_in_tree', '=', False)],
'required': [('is_field_in_tree', '=', True)], 'readonly': [('status', 'not in', ['draft', 'form'])]}"/>
<field name="tree_field_ids" invisible="1"/>
<field name="tree_field_position" attrs="{'invisible': [('is_field_in_tree', '=', False)],
'required': [('is_field_in_tree', '=', True)], 'readonly': [('status', 'not in', ['draft', 'form'])]}"/>
<field name="is_visible_in_tree_view" attrs="{'invisible': [('is_field_in_tree', '=', False)],
'required': [('is_field_in_tree', '=', True)], 'readonly': [('status', 'not in', ['draft', 'form'])]}"/>
</group> </group>
<group string="Position"> <group string="Position">
<field name="dynamic_field_id" <field name="dynamic_field_id"
options='{"no_open": True, "no_create": True}'/> options='{"no_open": True, "no_create": True}' attrs="{'readonly': [('status', '!=', 'draft')]}"/>
<field name="position"/> <field name="position" attrs="{'readonly': [('status', '!=', 'draft')]}"/>
</group> </group>
</group> </group>
<group string="Extra Properties"> <group string="Extra Properties">
<group> <group>
<field name="is_extra_features"/> <field name="is_extra_features" attrs="{'readonly': [('status', '!=', 'draft')]}"/>
</group> </group>
<group attrs="{'invisible': [('is_extra_features', '=', False)]}"> <group attrs="{'invisible': [('is_extra_features', '=', False)],'readonly': [('status', '!=', 'draft')]}">
<field name="help"/> <field name="help" attrs="{'readonly': [('status', '!=', 'draft')]}"/>
</group> </group>
<group attrs="{'invisible': [('is_extra_features', '=', False)]}"> <group attrs="{'invisible': [('is_extra_features', '=', False)]}">
<field name="readonly"/> <field name="readonly" attrs="{'readonly': [('status', '!=', 'draft')]}"/>
<field name="store"/> <field name="store" attrs="{'readonly': [('status', '!=', 'draft')]}"/>
<field name="index"/> <field name="index" attrs="{'readonly': [('status', '!=', 'draft')]}"/>
<field name="copied"/> <field name="copied" attrs="{'readonly': [('status', '!=', 'draft')]}"/>
</group> </group>
</group> </group>
</sheet> </sheet>

Loading…
Cancel
Save