13 changed files with 309 additions and 0 deletions
@ -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 <https://www.cybrosys.com> |
||||
|
|
||||
|
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. |
@ -0,0 +1,3 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
|
||||
|
from . import models |
@ -0,0 +1,43 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
################################################################################### |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# Copyright (C) 2018-TODAY Cybrosys Technologies (<https://www.cybrosys.com>). |
||||
|
# Author: Cybrosys Technologies (<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# 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 <https://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
################################################################################### |
||||
|
{ |
||||
|
'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, |
||||
|
} |
@ -0,0 +1,5 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
|
||||
|
from . import employee_fields |
||||
|
|
||||
|
|
@ -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 = _('<?xml version="1.0"?>' |
||||
|
'<data>' |
||||
|
'<field name="%s" position="%s">' |
||||
|
'<field name="%s"/>' |
||||
|
'</field>' |
||||
|
'</data>') % (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) |
|
After Width: | Height: | Size: 94 KiB |
After Width: | Height: | Size: 50 KiB |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 106 KiB |
After Width: | Height: | Size: 82 KiB |
@ -0,0 +1,83 @@ |
|||||
|
<section class="oe_container"> |
||||
|
<div class="oe_row oe_spaced"> |
||||
|
<h2 class="oe_slogan">Employee Dynamic Fields</h2> |
||||
|
<h3 class="oe_slogan">Ability To Add Custom Fields From User Level</h3> |
||||
|
<h4 class="oe_slogan"><a href="https://www.cybrosys.com">Cybrosys Technologies</a> </h4> |
||||
|
</div> |
||||
|
<div class="oe_row oe_spaced" style="padding-left:65px;"> |
||||
|
<h4>Features:</h4> |
||||
|
<div> |
||||
|
<span style="color:green;"> ☑ </span> Ability to add custom fields in employee master.<br/> |
||||
|
</div> |
||||
|
</div> |
||||
|
</section> |
||||
|
|
||||
|
<section class="oe_container oe_dark"> |
||||
|
<div class="oe_row oe_spaced"> |
||||
|
<div class="oe_picture"> |
||||
|
<h3 class="oe_slogan">Overview</h3> |
||||
|
<p class="oe_mt32" style="text-align: justify;"> |
||||
|
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. |
||||
|
</p> |
||||
|
</div> |
||||
|
</div> |
||||
|
</section> |
||||
|
|
||||
|
<section class="oe_container"> |
||||
|
<div class="oe_row oe_spaced"> |
||||
|
<div style="text-align: center"> |
||||
|
<p> |
||||
|
<h4>Dynamic Field Creation</h4> |
||||
|
<p> |
||||
|
</div> |
||||
|
<div style="text-align: center"> |
||||
|
<span>Here you can fill the field information to create a new field of employee master.</span> |
||||
|
<div class="oe_demo oe_picture oe_screenshot"> |
||||
|
<img style="border:10px solid white;height: 400px;" src="image1.png"> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</section> |
||||
|
|
||||
|
<section class="oe_container"> |
||||
|
<div class="oe_row oe_spaced"> |
||||
|
<h3 class="oe_slogan">Employee Master</h3> |
||||
|
<div style="text-align: center"> |
||||
|
<span>You can see your field is created in employee master.</span> |
||||
|
<div class="oe_demo oe_picture oe_screenshot"> |
||||
|
<img style="border:10px solid white;height: 400px;" src="image2.png"> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</section> |
||||
|
|
||||
|
<section class="oe_container"> |
||||
|
<h2 class="oe_slogan" style="margin-top:20px;" >Need Any Help?</h2> |
||||
|
<div class="oe_slogan" style="margin-top:10px !important;"> |
||||
|
<div> |
||||
|
<a class="btn btn-primary btn-lg mt8" |
||||
|
style="color: #FFFFFF !important;border-radius: 0;" href="https://www.cybrosys.com"><i |
||||
|
class="fa fa-envelope"></i> Email </a> <a |
||||
|
class="btn btn-primary btn-lg mt8" style="color: #FFFFFF !important;border-radius: 0;" |
||||
|
href="https://www.cybrosys.com/contact/"><i |
||||
|
class="fa fa-phone"></i> Contact Us </a> <a |
||||
|
class="btn btn-primary btn-lg mt8" style="color: #FFFFFF !important;border-radius: 0;" |
||||
|
href="https://www.cybrosys.com/odoo-customization-and-installation/"><i |
||||
|
class="fa fa-check-square"></i> Request Customization </a> |
||||
|
</div> |
||||
|
<br> |
||||
|
<img src="cybro_logo.png" style="width: 190px; margin-bottom: 20px;" class="center-block"> |
||||
|
<div> |
||||
|
<a href="https://twitter.com/cybrosys" target="_blank"><i class="fa fa-2x fa-twitter" style="color:white;background: #00a0d1;width:35px;"></i></a></td> |
||||
|
<a href="https://www.linkedin.com/company/cybrosys-technologies-pvt-ltd" target="_blank"><i class="fa fa-2x fa-linkedin" style="color:white;background: #31a3d6;width:35px;padding-left: 3px;"></i></a></td> |
||||
|
<a href="https://www.facebook.com/cybrosystechnologies" target="_blank"><i class="fa fa-2x fa-facebook" style="color:white;background: #3b5998;width:35px;padding-left: 8px;"></i></a></td> |
||||
|
<a href="https://plus.google.com/106641282743045431892/about" target="_blank"><i class="fa fa-2x fa-google-plus" style="color:white;background: #c53c2c;width:35px;padding-left: 3px;"></i></a></td> |
||||
|
<a href="https://in.pinterest.com/cybrosys" target="_blank"><i class="fa fa-2x fa-pinterest" style="color:white;background: #ac0f18;width:35px;padding-left: 3px;"></i></a></td> |
||||
|
</div> |
||||
|
</div> |
||||
|
</section> |
||||
|
|
||||
|
|
||||
|
|
@ -0,0 +1,53 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
<record model='ir.ui.view' id='wizard_dynamic_fields_form'> |
||||
|
<field name="name">wizard.dynamic.fields.form</field> |
||||
|
<field name="model">wizard.dynamic.fields</field> |
||||
|
<field name="arch" type="xml"> |
||||
|
<form string="Dynamic Fields"> |
||||
|
<sheet> |
||||
|
<group> |
||||
|
<group string="Field Info"> |
||||
|
<field name="name"/> |
||||
|
<field name="field_description"/> |
||||
|
<field name="state" readonly="1" groups="base.group_no_one"/> |
||||
|
<field name="model_id" options='{"no_open": True, "no_create": True}'/> |
||||
|
<field name="ttype"/> |
||||
|
<field name="selection" placeholder="[('blue', 'Blue'),('yellow', 'Yellow')]" |
||||
|
attrs="{'required': [('ttype','in',['selection','reference'])], |
||||
|
'readonly': [('ttype','not in',['selection','reference'])], |
||||
|
'invisible': [('ttype','not in',['selection','reference'])]}"/> |
||||
|
<field name="ref_model_id" options='{"no_open": True, "no_create": True}' attrs="{'required': [('ttype','in',['many2one','many2many'])], |
||||
|
'readonly': [('ttype','not in',['many2one','many2many'])], |
||||
|
'invisible': [('ttype','not in',['many2one','many2many'])]}"/> |
||||
|
<field name="required"/> |
||||
|
<field name="copy"/> |
||||
|
</group> |
||||
|
<group string="Position"> |
||||
|
<field name="position_field" options='{"no_open": True, "no_create": True}'/> |
||||
|
<field name="position"/> |
||||
|
</group> |
||||
|
</group> |
||||
|
</sheet> |
||||
|
<footer> |
||||
|
<button name="create_fields" string="Create Fields" type="object" class="oe_highlight"/> |
||||
|
or |
||||
|
<button string="Cancel" class="oe_link" special="cancel" /> |
||||
|
</footer> |
||||
|
</form> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
<record model='ir.actions.act_window' id='wizard_dynamic_fields'> |
||||
|
<field name="name">Create Custom Fields</field> |
||||
|
<field name="res_model">wizard.dynamic.fields</field> |
||||
|
<field name="view_type">form</field> |
||||
|
<field name="view_mode">form</field> |
||||
|
<field name="view_id" ref="wizard_dynamic_fields_form"/> |
||||
|
<field name="target">new</field> |
||||
|
</record> |
||||
|
|
||||
|
<menuitem id="employee_dynamic_fields_menu" name="Create Dynamic Fields" |
||||
|
parent="hr.menu_human_resources_configuration" groups="hr.group_hr_manager" sequence="3" |
||||
|
action="wizard_dynamic_fields"/> |
||||
|
</odoo> |
Loading…
Reference in new issue