[IMP] add the possibility to set a visibility (public, portal or private) for employees
authorAntonin Bourguignon <abo@openerp.com>
Tue, 3 Jul 2012 16:04:58 +0000 (18:04 +0200)
committerAntonin Bourguignon <abo@openerp.com>
Tue, 3 Jul 2012 16:04:58 +0000 (18:04 +0200)
bzr revid: abo@openerp.com-20120703160458-zzdk2kymapokm4j5

addons/hr/hr_view.xml
addons/portal_crm/__init__.py
addons/portal_crm/__openerp__.py
addons/portal_crm/hr_employee.py [new file with mode: 0644]
addons/portal_crm/hr_employee_view.xml [new file with mode: 0644]

index 5e6953a..ee16027 100644 (file)
@@ -59,7 +59,7 @@
                                     <field name="work_email" widget="email"/>
                                     <field name="work_location"/>
                                 </group>
-                                <group string="Job Information">
+                                <group name="job_information" string="Job Information">
                                     <field name="job_id" domain="[('state','!=','old')]" context="{'form_view_ref': 'hr.view_hr_job_employee_form'}"/>
                                     <field name="coach_id"/>
                                 </group>
             <field name="view_mode">form</field>
             <field name="view_id" ref="view_employee_form"/>
             <field name="act_window_id" ref="open_view_employee_list_my"/>
-        </record> 
+        </record>
 
         <menuitem action="open_view_employee_list_my" id="menu_open_view_employee_list_my" sequence="3" parent="menu_hr_main"/>
 
                 <search string="Jobs">
                     <field name="name" string="Job"/>
                     <separator orientation="vertical"/>
-                    <filter icon="terp-camera_test"  
-                            domain="[('state','=','open')]" 
+                    <filter icon="terp-camera_test"
+                            domain="[('state','=','open')]"
                             string="In Position"
                             help="In Position"/>
                     <filter icon="terp-personal+"  domain="[('state','=','recruit')]" string="In Recruitment"
                 </search>
             </field>
         </record>
-        
+
         <record id="view_hr_job_employee_form" model="ir.ui.view">
             <field name="name">hr.job.employee.form</field>
             <field name="model">hr.job</field>
                 </form>
             </field>
         </record>
-        
+
         <record model="ir.actions.act_window" id="action_hr_job">
             <field name="name">Job Positions</field>
             <field name="res_model">hr.job</field>
index 6b791be..4ea069f 100644 (file)
@@ -20,3 +20,4 @@
 ##############################################################################
 
 import wizard
+import hr_employee
\ No newline at end of file
index 55320cb..3f4a24a 100644 (file)
@@ -32,6 +32,7 @@ portal are installed.
     'author': 'OpenERP SA',
     'depends': ['crm','portal'],
     'data': [
+        'hr_employee_view.xml',
         'security/ir.model.access.csv',
         'wizard/contact_view.xml',
     ],
diff --git a/addons/portal_crm/hr_employee.py b/addons/portal_crm/hr_employee.py
new file mode 100644 (file)
index 0000000..b4db10d
--- /dev/null
@@ -0,0 +1,42 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2011 OpenERP S.A (<http://www.openerp.com>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License 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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from osv import osv, fields
+
+
+
+class hr_employee(osv.osv):
+    _description = "Portal CRM Employee"
+    _inherit = 'hr.employee'
+
+    """
+    ``visibility``: defines if the employee appears on the portal's contact page
+                    - 'public' means the employee will appear for everyone (anonymous)
+                    - 'portal' means the employee will appear for portal users only
+                    - 'private' means the employee won't appear
+    """
+    _columns = {
+        'visibility': fields.selection([('public', 'Public'),('portal', 'Portal'),('private', 'Private')],
+            string='Visibility', help='Employee\'s visibility in the portal\'s contact page'),
+    }
+    _defaults = {
+        'visibility': 'private',
+    }
diff --git a/addons/portal_crm/hr_employee_view.xml b/addons/portal_crm/hr_employee_view.xml
new file mode 100644 (file)
index 0000000..0bfb862
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        <!-- add visibility field in employee form -->
+        <record id="view_employee_form" model="ir.ui.view">
+            <field name="name">res.portal.employee.form</field>
+            <field name="model">hr.employee</field>
+            <field name="type">form</field>
+            <field name="inherit_id" ref="hr.view_employee_form"/>
+            <field name="arch" type="xml">
+                <xpath expr="//group[@name='job_information']" position="after">
+                    <group string="Employee's visibility">
+                        <field name="visibility"/>
+                    </group>
+                </xpath>
+            </field>
+        </record>
+    </data>
+</openerp>