Merge lp:~openerp-dev/openobject-addons/trunk-opw-582890-rgo into lp:openobject-addons

Proposed by Ravi Gohil (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-opw-582890-rgo
Merge into: lp:openobject-addons
Diff against target: 212 lines (+79/-9)
9 files modified
hr/hr.py (+19/-1)
hr/hr_data.xml (+15/-0)
hr/hr_view.xml (+37/-1)
hr/security/ir.model.access.csv (+1/-0)
hr_contract/test/test_hr_contract.yml (+1/-1)
hr_payroll_account/test/hr_payroll_account.yml (+1/-1)
l10n_be_hr_payroll/l10n_be_hr_payroll_data.xml (+2/-2)
l10n_be_hr_payroll/l10n_be_hr_payroll_demo.xml (+1/-1)
l10n_be_hr_payroll/l10n_be_hr_payroll_view.xml (+2/-2)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-opw-582890-rgo
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+140667@code.launchpad.net

Description of the change

Hello,

This fix is against OPW Ref: 582890 where client faced a problem if he migrate from V6.0 to newer version where some of his data will be lost for "Marital Status" field of hr.employee object.

In V6.0, the marital status field is a m2o field, so user can create possible legal marital status as per the country rules.

In newer versions, this field changed to simple selection field with fixed values(Single, Married, Widower, Divorced), but there can be other legal marital status as per the country rules which a user expect in this list.

So, if customer want to migrate from V6.0 to V7.0, the status other than above four will be lost. hence, I changed the selection field to m2o field and made test cases adaptive to this change.

Kindly review the fix.

Thanks.

To post a comment you must log in.

Unmerged revisions

8407. By Ravi Gohil (OpenERP)

[FIX] hr: added hr.employee.marital.status object to be used as m2o in hr.employee to handle data lose in migrated from older version : (Maintenance Case : 582890)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hr/hr.py'
--- hr/hr.py 2012-12-10 11:16:54 +0000
+++ hr/hr.py 2012-12-19 13:32:09 +0000
@@ -69,6 +69,17 @@
6969
70hr_employee_category()70hr_employee_category()
7171
72class hr_employee_marital_status(osv.osv):
73 _name = "hr.employee.marital.status"
74 _description = "Employee Marital Status"
75 _columns = {
76 'name': fields.char('Marital Status', size=32, required=True, translate=True),
77 'description': fields.text('Status Description'),
78 'is_married': fields.boolean('Married ?'),
79 }
80
81hr_employee_marital_status()
82
72class hr_job(osv.osv):83class hr_job(osv.osv):
7384
74 def _no_of_employee(self, cr, uid, ids, name, args, context=None):85 def _no_of_employee(self, cr, uid, ids, name, args, context=None):
@@ -166,7 +177,8 @@
166 'identification_id': fields.char('Identification No', size=32),177 'identification_id': fields.char('Identification No', size=32),
167 'otherid': fields.char('Other Id', size=64),178 'otherid': fields.char('Other Id', size=64),
168 'gender': fields.selection([('male', 'Male'),('female', 'Female')], 'Gender'),179 'gender': fields.selection([('male', 'Male'),('female', 'Female')], 'Gender'),
169 'marital': fields.selection([('single', 'Single'), ('married', 'Married'), ('widower', 'Widower'), ('divorced', 'Divorced')], 'Marital Status'),180 'marital': fields.many2one('hr.employee.marital.status', 'Marital Status'),
181 'is_married': fields.boolean('Married ?', help="It will be set based on the configuration of 'Married ?' field of 'Employee Marital Status' object"),
170 'department_id':fields.many2one('hr.department', 'Department'),182 'department_id':fields.many2one('hr.department', 'Department'),
171 'address_id': fields.many2one('res.partner', 'Working Address'),183 'address_id': fields.many2one('res.partner', 'Working Address'),
172 'address_home_id': fields.many2one('res.partner', 'Home Address'),184 'address_home_id': fields.many2one('res.partner', 'Home Address'),
@@ -226,6 +238,12 @@
226 resource_ids.append(employee.resource_id.id)238 resource_ids.append(employee.resource_id.id)
227 return self.pool.get('resource.resource').unlink(cr, uid, resource_ids, context=context)239 return self.pool.get('resource.resource').unlink(cr, uid, resource_ids, context=context)
228240
241 def onchange_marital_status(self, cr, uid, ids, marital_status, context=None):
242 if marital_status:
243 marital_status = self.pool.get('hr.employee.marital.status').browse(cr, uid, marital_status, context=context)
244 return {'value': {'is_married': marital_status.is_married}}
245 return {'value': {}}
246
229 def onchange_address_id(self, cr, uid, ids, address, context=None):247 def onchange_address_id(self, cr, uid, ids, address, context=None):
230 if address:248 if address:
231 address = self.pool.get('res.partner').browse(cr, uid, address, context=context)249 address = self.pool.get('res.partner').browse(cr, uid, address, context=context)
232250
=== modified file 'hr/hr_data.xml'
--- hr/hr_data.xml 2012-11-29 22:26:45 +0000
+++ hr/hr_data.xml 2012-12-19 13:32:09 +0000
@@ -1,6 +1,21 @@
1<?xml version="1.0" encoding="utf-8"?>1<?xml version="1.0" encoding="utf-8"?>
2<openerp>2<openerp>
3 <data noupdate="1">3 <data noupdate="1">
4 <!-- Employee Marital Statusses -->
5 <record id="hr_employee_marital_status_single" model="hr.employee.marital.status">
6 <field name="name">Single</field>
7 </record>
8 <record id="hr_employee_marital_status_married" model="hr.employee.marital.status">
9 <field name="name">Married</field>
10 <field eval="1" name="is_married"/>
11 </record>
12 <record id="hr_employee_marital_status_divorced" model="hr.employee.marital.status">
13 <field name="name">Divorced</field>
14 </record>
15 <record id="hr_employee_marital_status_widower" model="hr.employee.marital.status">
16 <field name="name">Widower</field>
17 </record>
18
4 <!-- notify all employees of module installation -->19 <!-- notify all employees of module installation -->
5 <record model="mail.message" id="module_install_notification">20 <record model="mail.message" id="module_install_notification">
6 <field name="model">mail.group</field>21 <field name="model">mail.group</field>
722
=== modified file 'hr/hr_view.xml'
--- hr/hr_view.xml 2012-12-08 10:33:38 +0000
+++ hr/hr_view.xml 2012-12-19 13:32:09 +0000
@@ -68,7 +68,8 @@
68 </group>68 </group>
69 <group string="Status">69 <group string="Status">
70 <field name="gender"/>70 <field name="gender"/>
71 <field name="marital"/>71 <field name="marital" widget="selection" on_change="onchange_marital_status(marital)"/>
72 <field name="is_married" invisible="1"/>
72 </group>73 </group>
73 <group string="Birth">74 <group string="Birth">
74 <field name="birthday"/>75 <field name="birthday"/>
@@ -212,6 +213,41 @@
212 <field name="res_id" ref="hr.menu_open_view_employee_list_my"/>213 <field name="res_id" ref="hr.menu_open_view_employee_list_my"/>
213 </record>214 </record>
214215
216 <!-- Employee marital status -->
217 <record id="hr_hr_employee_marital_status_tree" model="ir.ui.view">
218 <field name="name">hr.hr.employee.marital.status.tree</field>
219 <field name="model">hr.employee.marital.status</field>
220 <field name="arch" type="xml">
221 <tree string="Marital Status">
222 <field name="name" />
223 </tree>
224 </field>
225 </record>
226
227 <record id="hr_hr_employee_marital_status_form" model="ir.ui.view">
228 <field name="name">hr.hr.employee.marital.status</field>
229 <field name="model">hr.employee.marital.status</field>
230 <field name="arch" type="xml">
231 <form string="Marital Status">
232 <field name="name"/>
233 <field name="is_married"/>
234 <separator colspan="4" string="Description"/>
235 <field colspan="4" name="description" nolabel="1"/>
236 </form>
237 </field>
238 </record>
239
240 <record id="action_hr_marital_status" model="ir.actions.act_window">
241 <field name="name">Marital Status</field>
242 <field name="res_model">hr.employee.marital.status</field>
243 <field name="view_type">form</field>
244 <field name="view_mode">tree,form</field>
245 <field name="view_id" ref="hr_hr_employee_marital_status_tree"/>
246 </record>
247
248 <menuitem action="action_hr_marital_status" id="hr_menu_marital_status"
249 parent="hr.menu_hr_configuration" sequence="3" groups="base.group_hr_manager"/>
250
215 <!-- Employee architecture -->251 <!-- Employee architecture -->
216 <record id="view_partner_tree2" model="ir.ui.view">252 <record id="view_partner_tree2" model="ir.ui.view">
217 <field name="name">hr.employee.tree</field>253 <field name="name">hr.employee.tree</field>
218254
=== modified file 'hr/security/ir.model.access.csv'
--- hr/security/ir.model.access.csv 2012-11-29 22:26:45 +0000
+++ hr/security/ir.model.access.csv 2012-12-19 13:32:09 +0000
@@ -7,4 +7,5 @@
7access_hr_department_user,hr.department.user,model_hr_department,base.group_hr_user,1,1,1,17access_hr_department_user,hr.department.user,model_hr_department,base.group_hr_user,1,1,1,1
8access_hr_department_employee,hr.department.employee,model_hr_department,base.group_user,1,0,0,08access_hr_department_employee,hr.department.employee,model_hr_department,base.group_user,1,0,0,0
9access_hr_job_user,hr.job user,model_hr_job,base.group_hr_user,1,1,1,19access_hr_job_user,hr.job user,model_hr_job,base.group_hr_user,1,1,1,1
10access_hr_employee_marital_status_manager,hr.employee.marital.status.manager,model_hr_employee_marital_status,base.group_hr_manager,1,1,1,1
10access_ir_property_hr_user,ir_property hr_user,base.model_ir_property,base.group_hr_user,1,1,1,011access_ir_property_hr_user,ir_property hr_user,base.model_ir_property,base.group_hr_user,1,1,1,0
1112
=== modified file 'hr_contract/test/test_hr_contract.yml'
--- hr_contract/test/test_hr_contract.yml 2012-02-13 15:27:55 +0000
+++ hr_contract/test/test_hr_contract.yml 2012-12-19 13:32:09 +0000
@@ -10,7 +10,7 @@
10 gender: male10 gender: male
11 name: Mark Johnson11 name: Mark Johnson
12 children: 212 children: 2
13 marital: 'married'13 marital: hr.hr_employee_marital_status_married
14 place_of_birth: Belgium14 place_of_birth: Belgium
15 vehicle: 'No'15 vehicle: 'No'
16 vehicle_distance: 1216 vehicle_distance: 12
1717
=== modified file 'hr_payroll_account/test/hr_payroll_account.yml'
--- hr_payroll_account/test/hr_payroll_account.yml 2012-11-29 22:26:45 +0000
+++ hr_payroll_account/test/hr_payroll_account.yml 2012-12-19 13:32:09 +0000
@@ -19,7 +19,7 @@
19 country_id: base.in19 country_id: base.in
20 department_id: hr.dep_rd20 department_id: hr.dep_rd
21 gender: male21 gender: male
22 marital: single22 marital: hr.hr_employee_marital_status_single
23 name: John23 name: John
24 bank_account_id: res_partner_bank_024 bank_account_id: res_partner_bank_0
25 vehicle_distance: 0.025 vehicle_distance: 0.0
2626
=== modified file 'l10n_be_hr_payroll/l10n_be_hr_payroll_data.xml'
--- l10n_be_hr_payroll/l10n_be_hr_payroll_data.xml 2012-11-29 22:26:45 +0000
+++ l10n_be_hr_payroll/l10n_be_hr_payroll_data.xml 2012-12-19 13:32:09 +0000
@@ -113,7 +113,7 @@
113 <field name="sequence">120</field>113 <field name="sequence">120</field>
114 <field name="condition_select">python</field>114 <field name="condition_select">python</field>
115 <field name="appears_on_payslip" eval="False"/>115 <field name="appears_on_payslip" eval="False"/>
116 <field name="condition_python">result = (((employee.marital=='single') or (employee.marital=='married' and employee.spouse_fiscal_status=='with income')) and (employee.resident_bool!=True))</field>116 <field name="condition_python">result = (((employee.marital.is_married==False) or (employee.marital.is_married==True and employee.spouse_fiscal_status=='with income')) and (employee.resident_bool!=True))</field>
117 </record>117 </record>
118 <record id="hr_payroll_rules_baremeII" model="hr.salary.rule">118 <record id="hr_payroll_rules_baremeII" model="hr.salary.rule">
119 <field name="category_id" ref="hr_payroll_head_pp"/>119 <field name="category_id" ref="hr_payroll_head_pp"/>
@@ -124,7 +124,7 @@
124 <field name="sequence">120</field>124 <field name="sequence">120</field>
125 <field name="condition_select">python</field>125 <field name="condition_select">python</field>
126 <field name="appears_on_payslip" eval="False"/>126 <field name="appears_on_payslip" eval="False"/>
127 <field name="condition_python">result = ((employee.marital=='married' and employee.spouse_fiscal_status=='without income') and (employee.resident_bool!=True))</field>127 <field name="condition_python">result = ((employee.marital.is_married==True and employee.spouse_fiscal_status=='without income') and (employee.resident_bool!=True))</field>
128 </record>128 </record>
129 <record id="hr_payroll_rules_baremeIII" model="hr.salary.rule">129 <record id="hr_payroll_rules_baremeIII" model="hr.salary.rule">
130 <field name="category_id" ref="hr_payroll_head_pp"/>130 <field name="category_id" ref="hr_payroll_head_pp"/>
131131
=== modified file 'l10n_be_hr_payroll/l10n_be_hr_payroll_demo.xml'
--- l10n_be_hr_payroll/l10n_be_hr_payroll_demo.xml 2012-11-29 22:26:45 +0000
+++ l10n_be_hr_payroll/l10n_be_hr_payroll_demo.xml 2012-12-19 13:32:09 +0000
@@ -16,7 +16,7 @@
16 </record>16 </record>
1717
18 <record id="hr_payroll.hr_employee_payroll" model="hr.employee">18 <record id="hr_payroll.hr_employee_payroll" model="hr.employee">
19 <field name="marital">single</field>19 <field name="marital" ref="hr.hr_employee_marital_status_single"/>
20 </record>20 </record>
2121
22 </data>22 </data>
2323
=== modified file 'l10n_be_hr_payroll/l10n_be_hr_payroll_view.xml'
--- l10n_be_hr_payroll/l10n_be_hr_payroll_view.xml 2012-11-29 22:26:45 +0000
+++ l10n_be_hr_payroll/l10n_be_hr_payroll_view.xml 2012-12-19 13:32:09 +0000
@@ -46,8 +46,8 @@
46 <field name="resident_bool" eval="False"/> 46 <field name="resident_bool" eval="False"/>
47 </xpath>47 </xpath>
48 <xpath expr="//field[@name='marital']" position="after">48 <xpath expr="//field[@name='marital']" position="after">
49 <field name="spouse_fiscal_status" attrs="{'invisible':[('marital','!=','married')],'required':[('marital','=','married')]}" colspan="1" help="if spouse has professionnel income or not"/> 49 <field name="spouse_fiscal_status" attrs="{'invisible':[('is_married','!=',True)],'required':[('is_married','=',True)]}" colspan="1" help="if spouse has professionnel income or not"/>
50 <field name="disabled_spouse_bool" attrs="{'invisible':[('marital','!=','married')]}" colspan="1"/>50 <field name="disabled_spouse_bool" attrs="{'invisible':[('is_married','!=',True)]}" colspan="1"/>
51 </xpath>51 </xpath>
52 <xpath expr="//field[@name='children']" position="after">52 <xpath expr="//field[@name='children']" position="after">
53 <field name="disabled_children_bool"/>53 <field name="disabled_children_bool"/>

Subscribers

People subscribed via source and target branches

to all changes: