diff --git a/all_in_one_dynamic_custom_fields/__manifest__.py b/all_in_one_dynamic_custom_fields/__manifest__.py index 3c6a0aec9..1e28076d8 100644 --- a/all_in_one_dynamic_custom_fields/__manifest__.py +++ b/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, ' diff --git a/all_in_one_dynamic_custom_fields/doc/RELEASE_NOTES.md b/all_in_one_dynamic_custom_fields/doc/RELEASE_NOTES.md index 7aa46580f..d59a4f85b 100644 --- a/all_in_one_dynamic_custom_fields/doc/RELEASE_NOTES.md +++ b/all_in_one_dynamic_custom_fields/doc/RELEASE_NOTES.md @@ -8,4 +8,9 @@ #### 12.06.2024 #### 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. \ No newline at end of file +- 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. \ No newline at end of file diff --git a/all_in_one_dynamic_custom_fields/models/dynamic_fields.py b/all_in_one_dynamic_custom_fields/models/dynamic_fields.py index e7d0c749e..70dd2fbe2 100644 --- a/all_in_one_dynamic_custom_fields/models/dynamic_fields.py +++ b/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 = _('' diff --git a/all_in_one_dynamic_custom_fields/models/ir_model_fields.py b/all_in_one_dynamic_custom_fields/models/ir_model_fields.py index f8ff916f9..71fd641a1 100644 --- a/all_in_one_dynamic_custom_fields/models/ir_model_fields.py +++ b/all_in_one_dynamic_custom_fields/models/ir_model_fields.py @@ -20,7 +20,7 @@ # along with this program. If not, see . # ################################################################################ -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 \ No newline at end of file diff --git a/all_in_one_dynamic_custom_fields/static/description/assets/screenshots/field_info_1.png b/all_in_one_dynamic_custom_fields/static/description/assets/screenshots/field_info_1.png new file mode 100644 index 000000000..47448cfe5 Binary files /dev/null and b/all_in_one_dynamic_custom_fields/static/description/assets/screenshots/field_info_1.png differ diff --git a/all_in_one_dynamic_custom_fields/static/description/assets/screenshots/field_info_2.png b/all_in_one_dynamic_custom_fields/static/description/assets/screenshots/field_info_2.png new file mode 100644 index 000000000..3d96f2e0f Binary files /dev/null and b/all_in_one_dynamic_custom_fields/static/description/assets/screenshots/field_info_2.png differ diff --git a/all_in_one_dynamic_custom_fields/static/description/assets/screenshots/field_info_3.png b/all_in_one_dynamic_custom_fields/static/description/assets/screenshots/field_info_3.png new file mode 100644 index 000000000..0e283afe9 Binary files /dev/null and b/all_in_one_dynamic_custom_fields/static/description/assets/screenshots/field_info_3.png differ diff --git a/all_in_one_dynamic_custom_fields/static/description/index.html b/all_in_one_dynamic_custom_fields/static/description/index.html index 32ef23280..70f22bf7f 100644 --- a/all_in_one_dynamic_custom_fields/static/description/index.html +++ b/all_in_one_dynamic_custom_fields/static/description/index.html @@ -205,11 +205,28 @@ +
+

View Field Info +

+

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. +

+ +
+ +
+

Edit Field Info +

+

By clicking Field Info, it is possible to change the field label (string) from there. +

+ +
+ +

Sale Order Tree/List View

A new custom field is created in the sale order tree view.

- +
diff --git a/all_in_one_dynamic_custom_fields/views/dynamic_fields_views.xml b/all_in_one_dynamic_custom_fields/views/dynamic_fields_views.xml index 3deac28b0..28a0b0d46 100644 --- a/all_in_one_dynamic_custom_fields/views/dynamic_fields_views.xml +++ b/all_in_one_dynamic_custom_fields/views/dynamic_fields_views.xml @@ -22,6 +22,8 @@