diff --git a/employee_dynamic_fields/README.rst b/employee_dynamic_fields/README.rst new file mode 100644 index 000000000..8abef6854 --- /dev/null +++ b/employee_dynamic_fields/README.rst @@ -0,0 +1,45 @@ +Employee Dynamic Fields +======================= + +Employee Dynamic Fields + +Depends +======= +[base] addon Odoo +[hr] addon Odoo + +Tech +==== +* [Python] - Models +* [XML] - Odoo views + +Installation +============ +- www.odoo.com/documentation/11.0/setup/install.html +- Install our custom addon + +License +======= +GNU AFFERO GENERAL PUBLIC LICENSE, Version 3 (AGPLv3) +(http://www.gnu.org/licenses/agpl.html) + +Bug Tracker +=========== +Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. + +Credits +======= +* Cybrosys Techno Solutions + +Author +------ + +Developer: varghese, varghese@cybrosys.in +Developer: Jesni Banu, odoo@cybrosys.com + +Maintainer +---------- + +This module is maintained by Cybrosys Technologies. + +For support and more information, please visit https://www.cybrosys.com. diff --git a/employee_dynamic_fields/__init__.py b/employee_dynamic_fields/__init__.py new file mode 100644 index 000000000..cde864bae --- /dev/null +++ b/employee_dynamic_fields/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import models diff --git a/employee_dynamic_fields/__manifest__.py b/employee_dynamic_fields/__manifest__.py new file mode 100644 index 000000000..be4d02b31 --- /dev/null +++ b/employee_dynamic_fields/__manifest__.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +################################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2018-TODAY Cybrosys Technologies (). +# Author: Cybrosys Technologies () +# +# 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': '11.0.1.0.0', + 'summary': """Ability To Add Custom Fields From User Level""", + 'description': """Ability to add custom fields in employee master.""", + 'category': 'Generic Modules/Human Resources', + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': "https://www.cybrosys.com", + 'depends': ['base', 'hr'], + 'data': [ + 'security/ir.model.access.csv', + 'views/employee_fields_view.xml', + ], + 'demo': [], + 'images': ['static/description/banner.jpg'], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/employee_dynamic_fields/models/__init__.py b/employee_dynamic_fields/models/__init__.py new file mode 100644 index 000000000..8b9f7e153 --- /dev/null +++ b/employee_dynamic_fields/models/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- + +from . import employee_fields + + diff --git a/employee_dynamic_fields/models/employee_fields.py b/employee_dynamic_fields/models/employee_fields.py new file mode 100644 index 000000000..9952a9d02 --- /dev/null +++ b/employee_dynamic_fields/models/employee_fields.py @@ -0,0 +1,74 @@ +# -*- coding: utf-8 -*- + +import xml.etree.ElementTree as xee + +from odoo import api, models, fields, _ + + +class EmployeeDynamicFields(models.TransientModel): + _name = 'wizard.dynamic.fields' + _description = 'Dynamic Fields' + _inherit = 'ir.model.fields' + + @api.model + def get_field_types(self): + 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 + + @api.multi + def set_domain(self): + view_id = self.env.ref('hr.view_employee_form') + data1 = str(view_id.arch_base) + doc = xee.fromstring(data1) + 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)] + + @api.multi + def _set_default(self): + model_id = self.env['ir.model'].sudo().search([('model', '=', 'hr.employee')]) + return [('id', '=', model_id.id)] + + @api.multi + 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.ttype, + 'relation': self.ref_model_id.model, + 'required': self.required, + 'selection': self.selection, + 'copy': self.copy, + 'active': True}) + inherit_id = self.env.ref('hr.view_employee_form') + arch_base = _('' + '' + '' + '' + '' + '') % (self.position_field.name, self.position, self.name) + self.env['ir.ui.view'].sudo().create({'name': 'hr.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) + rel_field = fields.Many2one('ir.model.fields', string='Related Field') + ttype = fields.Selection(selection='get_field_types', string='Field Type', required=True) 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..37c7f2134 --- /dev/null +++ b/employee_dynamic_fields/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink +"access_wizard_dynamic_fields_hr_manager","wizard.dynamic.fields.hr_manager","model_wizard_dynamic_fields","hr.group_hr_manager",1,1,1,1 + diff --git a/employee_dynamic_fields/static/description/banner.jpg b/employee_dynamic_fields/static/description/banner.jpg new file mode 100644 index 000000000..80530826b Binary files /dev/null and b/employee_dynamic_fields/static/description/banner.jpg differ diff --git a/employee_dynamic_fields/static/description/cybro_logo.png b/employee_dynamic_fields/static/description/cybro_logo.png new file mode 100644 index 000000000..bb309114c Binary files /dev/null and b/employee_dynamic_fields/static/description/cybro_logo.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..dcec476e6 Binary files /dev/null and b/employee_dynamic_fields/static/description/icon.png differ diff --git a/employee_dynamic_fields/static/description/image1.png b/employee_dynamic_fields/static/description/image1.png new file mode 100644 index 000000000..6e4c6d908 Binary files /dev/null and b/employee_dynamic_fields/static/description/image1.png differ diff --git a/employee_dynamic_fields/static/description/image2.png b/employee_dynamic_fields/static/description/image2.png new file mode 100644 index 000000000..772d86cd1 Binary files /dev/null and b/employee_dynamic_fields/static/description/image2.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..6dfec21ef --- /dev/null +++ b/employee_dynamic_fields/static/description/index.html @@ -0,0 +1,83 @@ +
+
+

Employee Dynamic Fields

+

Ability To Add Custom Fields From User Level

+

Cybrosys Technologies

+
+
+

Features:

+
+ Ability to add custom fields in employee master.
+
+
+
+ +
+
+
+

Overview

+

+ The module allows the user to add dynamic fields to employee master form. + The user doesn't need any technical/programming skills, + just use the menu-driven approach and simply create and configure new fields. +

+
+
+
+ +
+
+
+

+

Dynamic Field Creation

+

+

+
+ Here you can fill the field information to create a new field of employee master. +
+ +
+
+
+
+ +
+
+

Employee Master

+
+ You can see your field is created in employee master. +
+ +
+
+
+
+ +
+

Need Any Help?

+ +
+ + + diff --git a/employee_dynamic_fields/views/employee_fields_view.xml b/employee_dynamic_fields/views/employee_fields_view.xml new file mode 100644 index 000000000..c09f21803 --- /dev/null +++ b/employee_dynamic_fields/views/employee_fields_view.xml @@ -0,0 +1,53 @@ + + + + wizard.dynamic.fields.form + wizard.dynamic.fields + +
+ + + + + + + + + + + + + + + + + + + +
+
+
+
+
+ + + Create Custom Fields + wizard.dynamic.fields + form + form + + new + + + +