diff --git a/employee_dynamic_fields/__init__.py b/employee_dynamic_fields/__init__.py new file mode 100644 index 000000000..bb896a7d9 --- /dev/null +++ b/employee_dynamic_fields/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Jesni Banu() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +from . import models diff --git a/employee_dynamic_fields/__manifest__.py b/employee_dynamic_fields/__manifest__.py new file mode 100644 index 000000000..a3b51557a --- /dev/null +++ b/employee_dynamic_fields/__manifest__.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Jesni Banu() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +{ + 'name': 'Employee Dynamic Fields', + 'version': '10.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..8f4a4c563 --- /dev/null +++ b/employee_dynamic_fields/models/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Jesni Banu() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +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..424c7a560 --- /dev/null +++ b/employee_dynamic_fields/models/employee_fields.py @@ -0,0 +1,96 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Jesni Banu() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## + +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')) + field_list.remove(('serialized', 'serialized')) + 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 + + + +