Browse Source

Jun 23: [FIX] Bug Fixed 'all_in_one_dynamic_custom_fields'

pull/380/merge
Cybrosys Technologies 4 days ago
parent
commit
a9e2ee8843
  1. 2
      all_in_one_dynamic_custom_fields/__manifest__.py
  2. 5
      all_in_one_dynamic_custom_fields/doc/RELEASE_NOTES.md
  3. 24
      all_in_one_dynamic_custom_fields/models/dynamic_fields.py
  4. 21
      all_in_one_dynamic_custom_fields/models/ir_model_fields.py
  5. BIN
      all_in_one_dynamic_custom_fields/static/description/assets/screenshots/field_info_1.png
  6. BIN
      all_in_one_dynamic_custom_fields/static/description/assets/screenshots/field_info_2.png
  7. BIN
      all_in_one_dynamic_custom_fields/static/description/assets/screenshots/field_info_3.png
  8. 19
      all_in_one_dynamic_custom_fields/static/description/index.html
  9. 5
      all_in_one_dynamic_custom_fields/views/dynamic_fields_views.xml

2
all_in_one_dynamic_custom_fields/__manifest__.py

@ -22,7 +22,7 @@
################################################################################
{
'name': 'All in One Dynamic Fields',
'version': '16.0.1.2.4',
'version': '16.0.1.3.0',
'category': 'Extra Tools',
'summary': 'Create Custom Fields As Per Your Need Without Any Coding.',
'description': 'All in One Dynamic Fields, All in One Custom Fields, '

5
all_in_one_dynamic_custom_fields/doc/RELEASE_NOTES.md

@ -9,3 +9,8 @@
#### Version 16.0.1.2.4
##### 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.
#### 17.06.2025
#### Version 16.0.1.3.0
##### UPDATE
- Introduced a new feature that allows users to edit the label (string) of a field after creation. This is done via a newly added field and a button that updates the field label.

24
all_in_one_dynamic_custom_fields/models/dynamic_fields.py

@ -29,7 +29,7 @@ from odoo.exceptions import ValidationError
class DynamicFields(models.Model):
"""Class DynamicFields to create fields dynamically to any model"""
_name = 'dynamic.fields'
_rec_name = 'field_description'
_rec_name = 'field_label'
_description = 'Custom Dynamic Fields'
_inherit = 'ir.model.fields'
@ -128,6 +128,18 @@ class DynamicFields(models.Model):
created_tree_view_id = fields.Many2one('ir.ui.view',
help='Dynamic Created tree view id',
string='Dynamic Tree view id')
field_label = fields.Char('Field Label')
create_field_id = fields.Many2one('ir.model.fields')
def action_open_create_field(self):
return {
'type': 'ir.actions.act_window',
'res_model': 'ir.model.fields',
'res_id': self.create_field_id.id,
'name': _("Field Info"),
'target': 'current',
'views': [(False, 'form')],
}
@api.depends('tree_view_id')
def _compute_tree_field_ids(self):
@ -171,9 +183,9 @@ class DynamicFields(models.Model):
'relation': 'res.currency',
'is_dynamic_field': True
})
self.env['ir.model.fields'].sudo().create({
create_field_id = self.env['ir.model.fields'].sudo().create({
'name': self.name,
'field_description': self.field_description,
'field_description': self.field_label,
'model_id': self.model_id.id,
'ttype': self.field_type,
'relation': self.ref_model_id.model,
@ -184,11 +196,13 @@ class DynamicFields(models.Model):
'readonly': self.readonly,
'selection': self.selection_field,
'copied': self.copied,
'is_dynamic_field': True
'is_dynamic_field': True,
'custom_field_id': self.id,
})
self.create_field_id = create_field_id.id
inherit_form_view_name = (str(
self.form_view_id.name) + ".inherit.dynamic.custom." +
str(self.field_description) + ".field")
str(self.field_label) + ".field")
xml_id = self.form_view_id.xml_id
inherit_id = self.env.ref(xml_id)
arch_base = _('<?xml version="1.0"?>'

21
all_in_one_dynamic_custom_fields/models/ir_model_fields.py

@ -20,7 +20,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
################################################################################
from odoo import models, fields
from odoo import api, models, fields
class IrModelFields(models.Model):
@ -31,3 +31,22 @@ class IrModelFields(models.Model):
is_dynamic_field = fields.Boolean(string="Dynamic Field",
help="id created using All In One "
"Dynamic Custom Fields")
custom_field_id = fields.Many2one('dynamic.fields','Custom Field')
@api.model
def create(self, vals):
record = super().create(vals)
if vals.get('field_description') and record.custom_field_id:
record.custom_field_id.write({
'field_label': vals['field_description']
})
return record
def write(self, vals):
res = super().write(vals)
for rec in self:
if 'field_description' in vals and rec.custom_field_id:
rec.custom_field_id.write({
'field_label': vals['field_description']
})
return res

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

19
all_in_one_dynamic_custom_fields/static/description/index.html

@ -205,11 +205,28 @@
<img src="assets/screenshots/dynamic10.png" class="img-thumbnail">
</div>
<div style="display: block; margin: 30px auto;">
<h3 style="font-family: 'Montserrat', sans-serif; font-size: 18px; font-weight: bold;"> View Field Info
</h3>
<p style="font-weight: 400; font-family: 'Montserrat', sans-serif; font-size: 14px;"> We can view the details of the created field in ir.model.fields by clicking Field Info. and it is also possible to change the field label (string) from there.
</p>
<img src="assets/screenshots/field_info_1.png" class="img-thumbnail">
</div>
<div style="display: block; margin: 30px auto;">
<h3 style="font-family: 'Montserrat', sans-serif; font-size: 18px; font-weight: bold;"> Edit Field Info
</h3>
<p style="font-weight: 400; font-family: 'Montserrat', sans-serif; font-size: 14px;"> By clicking Field Info, it is possible to change the field label (string) from there.
</p>
<img src="assets/screenshots/field_info_2.png" class="img-thumbnail">
</div>
<div style="display: block; margin: 30px auto;">
<h3 style="font-family: 'Montserrat', sans-serif; font-size: 18px; font-weight: bold;"> Sale Order Tree/List View
</h3>
<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>
<img src="assets/screenshots/4.png" class="img-thumbnail">
<img src="assets/screenshots/field_info_3.png" class="img-thumbnail">
<img src="assets/screenshots/dynamic12.png" class="img-thumbnail">
</div>

5
all_in_one_dynamic_custom_fields/views/dynamic_fields_views.xml

@ -22,6 +22,8 @@
<header>
<button name="action_create_dynamic_fields" string="Create Field" type="object" class="oe_highlight"
attrs="{'invisible': [('status', 'in', ['form','tree'])]}" groups="all_in_one_dynamic_custom_fields.group_all_in_one_dynamic_custom_fields_administrator"/>
<button name="action_open_create_field" string="Field Info" type="object" class="oe_highlight"
attrs="{'invisible': [('status', 'in', ['draft'])]}" groups="all_in_one_dynamic_custom_fields.group_all_in_one_dynamic_custom_fields_administrator"/>
<button name="action_add_field_to_tree_view" string="Add to Tree View" type="object" class="oe_highlight"
attrs="{'invisible': [('status', 'in', ['draft','tree'])]}" groups="all_in_one_dynamic_custom_fields.group_all_in_one_dynamic_custom_fields_administrator"/>
<field name="status" widget="statusbar"
@ -31,7 +33,7 @@
<group>
<group string="Field Info">
<field name="name" attrs="{'readonly': [('status', '!=', 'draft')]}"/>
<field name="field_description" attrs="{'readonly': [('status', '!=', 'draft')]}"/>/>
<field name="field_label" attrs="{'readonly': [('status', '!=', 'draft')]}"/>/>
<field name="state" readonly="1" groups="base.group_no_one"/>
<field name="model_id" options='{"no_open": True, "no_create": True}' attrs="{'readonly': [('status', '!=', 'draft')]}"/>
<field name="field_type" attrs="{'readonly': [('status', '!=', 'draft')]}"/>
@ -48,6 +50,7 @@
<field name="required" attrs="{'readonly': [('status', '!=', 'draft')]}"/>
<field name="form_view_id" options='{"no_open": True, "no_create": True}' attrs="{'readonly': [('status', '!=', 'draft')]}"/>
<field name="form_view_inherit_id"/>
<!-- <field name="custom_field_label" force_save="1"/>-->
</group>
<group string="Tree View">
<field name="is_add_field_in_tree" attrs="{'readonly': [('status', 'not in', ['draft', 'form'])]}"/>

Loading…
Cancel
Save