diff --git a/employee_dynamic_fields/README.rst b/employee_dynamic_fields/README.rst new file mode 100644 index 000000000..f1e943bb0 --- /dev/null +++ b/employee_dynamic_fields/README.rst @@ -0,0 +1,44 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +Employee Dynamic Fields +======================= + +Employee Dynamic Fields + +Installation +============ +- www.odoo.com/documentation/13.0/setup/install.html +- Install our custom addon + +Company +------- +* `Cybrosys Techno Solutions `__ + +Credits +------- +* Developer: + Version 14: Minhaj T @cybrosys + Version 15: Musthafa C @cybrosys + +Contacts +-------- +* Mail Contact : odoo@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 `__ + +Further information +=================== +HTML Description: ``__ \ No newline at end of file diff --git a/employee_dynamic_fields/__init__.py b/employee_dynamic_fields/__init__.py new file mode 100644 index 000000000..350976f47 --- /dev/null +++ b/employee_dynamic_fields/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +################################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-TODAY Cybrosys Technologies (). +# Author: Ajmal JK () +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################### + +from . import models +from . import wizard diff --git a/employee_dynamic_fields/__manifest__.py b/employee_dynamic_fields/__manifest__.py new file mode 100644 index 000000000..257b67148 --- /dev/null +++ b/employee_dynamic_fields/__manifest__.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +################################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-TODAY Cybrosys Technologies (). +# Author: Cybrosys Techno Solutions () +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################### + +{ + 'name': 'Employee Dynamic Fields', + 'version': '15.0.1.0.0', + 'summary': """Ability To Add Custom Fields in Employee From User Level""", + 'description': """Ability To Add Custom Fields in Employee From User Level,Employee Custom Fields, + Employee Dynamic Fields, odoo13, Dynamic Employee Fields, Dynamic Fields, Create Dynamic Fields, Community odoo Studio""", + 'category': 'Extra Tools', + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': "https://www.cybrosys.com", + 'depends': ['hr'], + 'data': [ + 'data/widget_data.xml', + 'security/ir.model.access.csv', + 'security/employee_security_group.xml', + 'wizard/employee_fields_view.xml', + 'views/ir_fields_search_view.xml', + ], + 'images': ['static/description/banner.png'], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/employee_dynamic_fields/data/widget_data.xml b/employee_dynamic_fields/data/widget_data.xml new file mode 100644 index 000000000..8f1ba671a --- /dev/null +++ b/employee_dynamic_fields/data/widget_data.xml @@ -0,0 +1,40 @@ + + + + + + image + Image + + + + many2many_tags + Many2many Tags + + + + binary + Binary + + + + radio + Radio + + + + priority + Priority + + + + monetary + Monetary + + + + selection + Selection + + + diff --git a/employee_dynamic_fields/doc/RELEASE_NOTES.md b/employee_dynamic_fields/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..31c81fc5c --- /dev/null +++ b/employee_dynamic_fields/doc/RELEASE_NOTES.md @@ -0,0 +1,9 @@ +## Module + +#### 03.10.2020 +#### Version 15.0.1.0.0 +##### ADD + +- Initial Commit for employee_dynamic_fields + + diff --git a/employee_dynamic_fields/models/__init__.py b/employee_dynamic_fields/models/__init__.py new file mode 100644 index 000000000..eac19c54f --- /dev/null +++ b/employee_dynamic_fields/models/__init__.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +################################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-TODAY Cybrosys Technologies (). +# Author: Cybrosys Techno Solutions () +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################### + +from . import ir_model_fields +from . import field_widgets + + diff --git a/employee_dynamic_fields/models/field_widgets.py b/employee_dynamic_fields/models/field_widgets.py new file mode 100644 index 000000000..7c988b421 --- /dev/null +++ b/employee_dynamic_fields/models/field_widgets.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +################################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-TODAY Cybrosys Technologies (). +# Author: Cybrosys Techno Solutions () +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################### + +from odoo import api, models, fields, _ + + +class FieldWidgets(models.Model): + """We can't filter a selection field dynamically + so when we select a field its widgets also need to change according to the selected + field type, we can't do it by a 'selection' field, need a 'Many2one' field. + """ + + _name = 'employee.field.widgets' + _rec_name = 'description' + _description = 'Field Widgets' + + name = fields.Char(string="Name") + description = fields.Char(string="Description") diff --git a/employee_dynamic_fields/models/ir_model_fields.py b/employee_dynamic_fields/models/ir_model_fields.py new file mode 100644 index 000000000..dafdf9ff0 --- /dev/null +++ b/employee_dynamic_fields/models/ir_model_fields.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +################################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-TODAY Cybrosys Technologies (). +# Author: Cybrosys Techno Solutions () +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################### + +from odoo import api, models, fields, _ + + +class IrModelFields(models.Model): + """Adding a new field to understand the dynamically created fields.""" + + _inherit = 'ir.model.fields' + + is_employee_dynamic = fields.Boolean(string="Dynamic Field") diff --git a/employee_dynamic_fields/security/employee_security_group.xml b/employee_dynamic_fields/security/employee_security_group.xml new file mode 100644 index 000000000..a925aa4cc --- /dev/null +++ b/employee_dynamic_fields/security/employee_security_group.xml @@ -0,0 +1,8 @@ + + + + + Create Employee Custom Fields + + + diff --git a/employee_dynamic_fields/security/ir.model.access.csv b/employee_dynamic_fields/security/ir.model.access.csv new file mode 100644 index 000000000..ae8548803 --- /dev/null +++ b/employee_dynamic_fields/security/ir.model.access.csv @@ -0,0 +1,4 @@ +id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink +"access_wizard_employee_dynamic_fields_base_user","wizard.employee.dynamic.fields.base.user","model_employee_dynamic_fields",,1,1,1,1 +"access_employee_field_widgets_base_user","wizard.employee.field.widgets.base.user","model_employee_field_widgets",,1,1,1,1 + diff --git a/employee_dynamic_fields/static/description/assets/icons/check.png b/employee_dynamic_fields/static/description/assets/icons/check.png new file mode 100644 index 000000000..c8e85f51d Binary files /dev/null and b/employee_dynamic_fields/static/description/assets/icons/check.png differ diff --git a/employee_dynamic_fields/static/description/assets/icons/chevron.png b/employee_dynamic_fields/static/description/assets/icons/chevron.png new file mode 100644 index 000000000..2089293d6 Binary files /dev/null and b/employee_dynamic_fields/static/description/assets/icons/chevron.png differ diff --git a/employee_dynamic_fields/static/description/assets/icons/cogs.png b/employee_dynamic_fields/static/description/assets/icons/cogs.png new file mode 100644 index 000000000..95d0bad62 Binary files /dev/null and b/employee_dynamic_fields/static/description/assets/icons/cogs.png differ diff --git a/employee_dynamic_fields/static/description/assets/icons/consultation.png b/employee_dynamic_fields/static/description/assets/icons/consultation.png new file mode 100644 index 000000000..8319d4baa Binary files /dev/null and b/employee_dynamic_fields/static/description/assets/icons/consultation.png differ diff --git a/employee_dynamic_fields/static/description/assets/icons/ecom-black.png b/employee_dynamic_fields/static/description/assets/icons/ecom-black.png new file mode 100644 index 000000000..a9385ff13 Binary files /dev/null and b/employee_dynamic_fields/static/description/assets/icons/ecom-black.png differ diff --git a/employee_dynamic_fields/static/description/assets/icons/education-black.png b/employee_dynamic_fields/static/description/assets/icons/education-black.png new file mode 100644 index 000000000..3eb09b27b Binary files /dev/null and b/employee_dynamic_fields/static/description/assets/icons/education-black.png differ diff --git a/employee_dynamic_fields/static/description/assets/icons/hotel-black.png b/employee_dynamic_fields/static/description/assets/icons/hotel-black.png new file mode 100644 index 000000000..130f613be Binary files /dev/null and b/employee_dynamic_fields/static/description/assets/icons/hotel-black.png differ diff --git a/employee_dynamic_fields/static/description/assets/icons/license.png b/employee_dynamic_fields/static/description/assets/icons/license.png new file mode 100644 index 000000000..a5869797e Binary files /dev/null and b/employee_dynamic_fields/static/description/assets/icons/license.png differ diff --git a/employee_dynamic_fields/static/description/assets/icons/lifebuoy.png b/employee_dynamic_fields/static/description/assets/icons/lifebuoy.png new file mode 100644 index 000000000..658d56ccc Binary files /dev/null and b/employee_dynamic_fields/static/description/assets/icons/lifebuoy.png differ diff --git a/employee_dynamic_fields/static/description/assets/icons/logo.png b/employee_dynamic_fields/static/description/assets/icons/logo.png new file mode 100644 index 000000000..478462d3e Binary files /dev/null and b/employee_dynamic_fields/static/description/assets/icons/logo.png differ diff --git a/employee_dynamic_fields/static/description/assets/icons/manufacturing-black.png b/employee_dynamic_fields/static/description/assets/icons/manufacturing-black.png new file mode 100644 index 000000000..697eb0e9f Binary files /dev/null and b/employee_dynamic_fields/static/description/assets/icons/manufacturing-black.png differ diff --git a/employee_dynamic_fields/static/description/assets/icons/pos-black.png b/employee_dynamic_fields/static/description/assets/icons/pos-black.png new file mode 100644 index 000000000..97c0f90c1 Binary files /dev/null and b/employee_dynamic_fields/static/description/assets/icons/pos-black.png differ diff --git a/employee_dynamic_fields/static/description/assets/icons/puzzle.png b/employee_dynamic_fields/static/description/assets/icons/puzzle.png new file mode 100644 index 000000000..65cf854e7 Binary files /dev/null and b/employee_dynamic_fields/static/description/assets/icons/puzzle.png differ diff --git a/employee_dynamic_fields/static/description/assets/icons/restaurant-black.png b/employee_dynamic_fields/static/description/assets/icons/restaurant-black.png new file mode 100644 index 000000000..4a35eb939 Binary files /dev/null and b/employee_dynamic_fields/static/description/assets/icons/restaurant-black.png differ diff --git a/employee_dynamic_fields/static/description/assets/icons/service-black.png b/employee_dynamic_fields/static/description/assets/icons/service-black.png new file mode 100644 index 000000000..301ab51cb Binary files /dev/null and b/employee_dynamic_fields/static/description/assets/icons/service-black.png differ diff --git a/employee_dynamic_fields/static/description/assets/icons/trading-black.png b/employee_dynamic_fields/static/description/assets/icons/trading-black.png new file mode 100644 index 000000000..9398ba2f1 Binary files /dev/null and b/employee_dynamic_fields/static/description/assets/icons/trading-black.png differ diff --git a/employee_dynamic_fields/static/description/assets/icons/training.png b/employee_dynamic_fields/static/description/assets/icons/training.png new file mode 100644 index 000000000..884ca024d Binary files /dev/null and b/employee_dynamic_fields/static/description/assets/icons/training.png differ diff --git a/employee_dynamic_fields/static/description/assets/icons/update.png b/employee_dynamic_fields/static/description/assets/icons/update.png new file mode 100644 index 000000000..ecbc5a01a Binary files /dev/null and b/employee_dynamic_fields/static/description/assets/icons/update.png differ diff --git a/employee_dynamic_fields/static/description/assets/icons/user.png b/employee_dynamic_fields/static/description/assets/icons/user.png new file mode 100644 index 000000000..6ffb23d9f Binary files /dev/null and b/employee_dynamic_fields/static/description/assets/icons/user.png differ diff --git a/employee_dynamic_fields/static/description/assets/icons/wrench.png b/employee_dynamic_fields/static/description/assets/icons/wrench.png new file mode 100644 index 000000000..6c04dea0f Binary files /dev/null and b/employee_dynamic_fields/static/description/assets/icons/wrench.png differ diff --git a/employee_dynamic_fields/static/description/assets/modules/budget_image.png b/employee_dynamic_fields/static/description/assets/modules/budget_image.png new file mode 100644 index 000000000..b50130c7d Binary files /dev/null and b/employee_dynamic_fields/static/description/assets/modules/budget_image.png differ diff --git a/employee_dynamic_fields/static/description/assets/modules/crm_doc_image.png b/employee_dynamic_fields/static/description/assets/modules/crm_doc_image.png new file mode 100644 index 000000000..0e6f19573 Binary files /dev/null and b/employee_dynamic_fields/static/description/assets/modules/crm_doc_image.png differ diff --git a/employee_dynamic_fields/static/description/assets/modules/dynamic_image.png b/employee_dynamic_fields/static/description/assets/modules/dynamic_image.png new file mode 100644 index 000000000..5238bdeab Binary files /dev/null and b/employee_dynamic_fields/static/description/assets/modules/dynamic_image.png differ diff --git a/employee_dynamic_fields/static/description/assets/modules/employee_image.png b/employee_dynamic_fields/static/description/assets/modules/employee_image.png new file mode 100644 index 000000000..30ad58232 Binary files /dev/null and b/employee_dynamic_fields/static/description/assets/modules/employee_image.png differ diff --git a/employee_dynamic_fields/static/description/assets/modules/gantt_image.png b/employee_dynamic_fields/static/description/assets/modules/gantt_image.png new file mode 100644 index 000000000..1ae7cfe3b Binary files /dev/null and b/employee_dynamic_fields/static/description/assets/modules/gantt_image.png differ diff --git a/employee_dynamic_fields/static/description/assets/modules/sale_image.png b/employee_dynamic_fields/static/description/assets/modules/sale_image.png new file mode 100644 index 000000000..004c61a9e Binary files /dev/null and b/employee_dynamic_fields/static/description/assets/modules/sale_image.png differ diff --git a/employee_dynamic_fields/static/description/assets/screenshots/dynamic-1.png b/employee_dynamic_fields/static/description/assets/screenshots/dynamic-1.png new file mode 100644 index 000000000..bc7e78c5e Binary files /dev/null and b/employee_dynamic_fields/static/description/assets/screenshots/dynamic-1.png differ diff --git a/employee_dynamic_fields/static/description/assets/screenshots/dynamic-2.png b/employee_dynamic_fields/static/description/assets/screenshots/dynamic-2.png new file mode 100644 index 000000000..a885d0437 Binary files /dev/null and b/employee_dynamic_fields/static/description/assets/screenshots/dynamic-2.png differ diff --git a/employee_dynamic_fields/static/description/assets/screenshots/dynamic-3.png b/employee_dynamic_fields/static/description/assets/screenshots/dynamic-3.png new file mode 100644 index 000000000..6455f4719 Binary files /dev/null and b/employee_dynamic_fields/static/description/assets/screenshots/dynamic-3.png differ diff --git a/employee_dynamic_fields/static/description/assets/screenshots/dynamic-4.png b/employee_dynamic_fields/static/description/assets/screenshots/dynamic-4.png new file mode 100644 index 000000000..474c91c89 Binary files /dev/null and b/employee_dynamic_fields/static/description/assets/screenshots/dynamic-4.png differ diff --git a/employee_dynamic_fields/static/description/assets/screenshots/dynamic-5.png b/employee_dynamic_fields/static/description/assets/screenshots/dynamic-5.png new file mode 100644 index 000000000..efaf66c0e Binary files /dev/null and b/employee_dynamic_fields/static/description/assets/screenshots/dynamic-5.png differ diff --git a/employee_dynamic_fields/static/description/assets/screenshots/hero.png b/employee_dynamic_fields/static/description/assets/screenshots/hero.png new file mode 100644 index 000000000..1c1b9d4bc Binary files /dev/null and b/employee_dynamic_fields/static/description/assets/screenshots/hero.png differ diff --git a/employee_dynamic_fields/static/description/banner.png b/employee_dynamic_fields/static/description/banner.png new file mode 100644 index 000000000..e69fc4e0a Binary files /dev/null and b/employee_dynamic_fields/static/description/banner.png differ diff --git a/employee_dynamic_fields/static/description/icon.png b/employee_dynamic_fields/static/description/icon.png new file mode 100644 index 000000000..83428b1b2 Binary files /dev/null and b/employee_dynamic_fields/static/description/icon.png differ diff --git a/employee_dynamic_fields/static/description/index.html b/employee_dynamic_fields/static/description/index.html new file mode 100644 index 000000000..0f1d6c746 --- /dev/null +++ b/employee_dynamic_fields/static/description/index.html @@ -0,0 +1,674 @@ +
+
+
+
+ +
+
+
+ Community +
+
+ Enterprise +
+ +
+
+
+
+ +
+
+
+

+ Employee Dynamic Fields

+

+ Create Custom Fields in Employee from User level. +

+ +
+
+ + + + +
+
+

+ Overview +

+
+ +
+

+ Employee Dynamic Fields module helps with easy creation of custom fields in employee without any + coding. + This module helps to add new fields on the employee form as per one's requirement. From the Employee + menu, one can click create fields and can create a new custom field without any coding.

+ +
+
+ + +
+
+

+ Features +

+
+ +
+
+ +
+
+

+ Creates custom fields in employee without coding

+ +
+
+
+
+ +
+
+

+ Can easily set the position of fields

+ +
+
+ +
+
+ +
+
+

+ Can select widgets for fields

+ +
+
+ +
+
+ +
+
+

+ Can set the field properties (help,required,copied,read-only,indexed)

+ +
+
+ +
+
+ +
+
+

+ Can easily filter the dynamically created fields from settings

+ +
+
+ + +
+ +
+
+

+ Screenshots +

+
+
+

+ Create Employee Custom Fields

+

+ After installation, Give Acces to the user to 'Create Employee Custom Fields' from User settings. +

+ +
+ +
+

+ Create Fields

+

+ Click 'Create Fields' menu to create custom fields. +

+ +
+ +
+

+ Widgets

+

+ Fill in the details (also can select 'Widgets' if needed) and click create fields , a new field will + create. +

+ +
+ + +
+

+ Employee View

+

+ A new field is created in the employee view. +

+ +
+ + +
+

+ Filter Dynamically Created Fields

+

+ Can filter the dynamically created fields from the settings. +

+ +
+ + +
+ + + + +
+
+

Suggested Products

+
+ + +
+
+ + +
+
+
+

Our Services

+
+
+ +
+
+ +
+
+ Odoo + Customization
+
+ +
+
+ +
+
+ Odoo + Implementation
+
+ +
+
+ +
+
+ Odoo + Support
+
+ + +
+
+ +
+
+ Hire + Odoo + Developer
+
+ +
+
+ +
+
+ Odoo + Integration
+
+ +
+
+ +
+
+ Odoo + Migration
+
+ + +
+
+ +
+
+ Odoo + Consultancy
+
+ +
+
+ +
+
+ Odoo + Implementation
+
+ +
+
+ +
+
+ Odoo + Licensing Consultancy
+
+
+
+ + + +
+
+
+

Our Industries

+
+
+ +
+
+ +
+ Trading +
+

+ Easily procure + and + sell your products

+
+
+ +
+
+ +
+ POS +
+

+ Easy + configuration + and convivial experience

+
+
+ +
+
+ +
+ Education +
+

+ A platform for + educational management

+
+
+ +
+
+ +
+ Manufacturing +
+

+ Plan, track and + schedule your operations

+
+
+ +
+
+ +
+ E-commerce & Website +
+

+ Mobile + friendly, + awe-inspiring product pages

+
+
+ +
+
+ +
+ Service Management +
+

+ Keep track of + services and invoice

+
+
+ +
+
+ +
+ Restaurant +
+

+ Run your bar or + restaurant methodically

+
+
+ +
+
+ +
+ Hotel Management +
+

+ An + all-inclusive + hotel management application

+
+
+ +
+
+ + + + + +
+
+
+

Need Help?

+
+
+
+ + +
+ +
+ + +
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+
+ + +
\ No newline at end of file diff --git a/employee_dynamic_fields/views/ir_fields_search_view.xml b/employee_dynamic_fields/views/ir_fields_search_view.xml new file mode 100644 index 000000000..c2133bf4e --- /dev/null +++ b/employee_dynamic_fields/views/ir_fields_search_view.xml @@ -0,0 +1,15 @@ + + + + + ir.model.fields.employee.dynamic.fields + ir.model.fields + + + + + + + + + diff --git a/employee_dynamic_fields/wizard/__init__.py b/employee_dynamic_fields/wizard/__init__.py new file mode 100644 index 000000000..27c0be9cd --- /dev/null +++ b/employee_dynamic_fields/wizard/__init__.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +################################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-TODAY Cybrosys Technologies (). +# Author: Cybrosys Techno Solutions () +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################### + +from . import employee_fields + + diff --git a/employee_dynamic_fields/wizard/employee_fields.py b/employee_dynamic_fields/wizard/employee_fields.py new file mode 100644 index 000000000..dd9d0a5f7 --- /dev/null +++ b/employee_dynamic_fields/wizard/employee_fields.py @@ -0,0 +1,138 @@ +# -*- coding: utf-8 -*- +################################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-TODAY Cybrosys Technologies (). +# Author: Cybrosys Techno Solutions () +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################### + +import xml.etree.ElementTree as xee +from odoo import api, models, fields, _ + + +class EmployeeDynamicFields(models.TransientModel): + _name = 'employee.dynamic.fields' + _description = 'Dynamic Fields' + _inherit = 'ir.model.fields' + + @api.model + def get_possible_field_types(self): + """Return all available field types other than 'one2many' and 'reference' fields.""" + field_list = sorted((key, key) for key in fields.MetaField.by_type) + field_list.remove(('one2many', 'one2many')) + field_list.remove(('reference', 'reference')) + return field_list + + def set_domain(self): + """Return the fields that currently present in the form""" + view_id = self.env.ref('hr.view_employee_form') + view_arch = str(view_id.arch_base) + doc = xee.fromstring(view_arch) + field_list = [] + for tag in doc.findall('.//field'): + field_list.append(tag.attrib['name']) + model_id = self.env['ir.model'].sudo().search([('model', '=', 'hr.employee')]) + return [('model_id', '=', model_id.id), ('state', '=', 'base'), ('name', 'in', field_list)] + + def _set_default(self): + model_id = self.env['ir.model'].sudo().search([('model', '=', 'hr.employee')]) + return [('id', '=', model_id.id)] + + def create_fields(self): + self.env['ir.model.fields'].sudo().create({'name': self.name, + 'field_description': self.field_description, + 'model_id': self.model_id.id, + 'ttype': self.field_type, + 'relation': self.ref_model_id.model, + 'required': self.required, + 'index': self.index, + 'store': self.store, + 'help': self.help, + 'readonly': self.readonly, + 'selection': self.selection_field, + 'copied': self.copied, + 'is_employee_dynamic': True + }) + inherit_id = self.env.ref('hr.view_employee_form') + arch_base = _('' + '' + '' + '' + '' + '') % (self.position_field.name, self.position, self.name) + if self.widget: + arch_base = _('' + '' + '' + '' + '' + '') % (self.position_field.name, self.position, self.name, self.widget.name) + + self.env['ir.ui.view'].sudo().create({'name': 'employee.dynamic.fields', + 'type': 'form', + 'model': 'hr.employee', + 'mode': 'extension', + 'inherit_id': inherit_id.id, + 'arch_base': arch_base, + 'active': True}) + return { + 'type': 'ir.actions.client', + 'tag': 'reload', + } + + position_field = fields.Many2one('ir.model.fields', string='Field Name', + domain=set_domain, required=True) + position = fields.Selection([('before', 'Before'), + ('after', 'After')], string='Position', required=True) + model_id = fields.Many2one('ir.model', string='Model', required=True, index=True, ondelete='cascade', + help="The model this field belongs to", domain=_set_default) + ref_model_id = fields.Many2one('ir.model', string='Model', index=True) + # In odoo 13 the field 'selection' is deprecated, so adding a new field to get the selection values. + selection_field = fields.Char(string="Selection Options") + rel_field = fields.Many2one('ir.model.fields', string='Related Field') + field_type = fields.Selection(selection='get_possible_field_types', string='Field Type', required=True) + ttype = fields.Selection(string="Field Type", related='field_type') + widget = fields.Many2one('employee.field.widgets', string='Widget') + groups = fields.Many2many('res.groups', 'employee_dynamic_fields_group_rel', 'field_id', 'group_id') + extra_features = fields.Boolean(string="Show Extra Properties") + + @api.depends('field_type') + @api.onchange('field_type') + def onchange_field_type(self): + if self.field_type: + if self.field_type == 'binary': + return {'domain': {'widget': [('name', '=', 'image')]}} + elif self.field_type == 'many2many': + return {'domain': {'widget': [('name', 'in', ['many2many_tags', 'binary'])]}} + elif self.field_type == 'selection': + return {'domain': { + 'widget': [('name', 'in', ['radio', 'priority'])]}} + elif self.field_type == 'float': + return {'domain': {'widget': [('name', '=', 'monetary')]}} + elif self.field_type == 'many2one': + return {'domain': {'widget': [('name', '=', 'selection')]}} + else: + return {'domain': {'widget': [('id', '=', False)]}} + return {'domain': {'widget': [('id', '=', False)]}} + + +class Employee(models.Model): + _description = 'Employee' + _inherit = 'hr.employee' + + x_currency_id = fields.Many2one('res.currency', string='Currency') diff --git a/employee_dynamic_fields/wizard/employee_fields_view.xml b/employee_dynamic_fields/wizard/employee_fields_view.xml new file mode 100644 index 000000000..a54b3c17f --- /dev/null +++ b/employee_dynamic_fields/wizard/employee_fields_view.xml @@ -0,0 +1,74 @@ + + + + + employee.dynamic.fields.form + employee.dynamic.fields + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+ + + Create Custom Fields + employee.dynamic.fields + form + + new + + + + + +