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
1=== modified file 'hr/hr.py'
2--- hr/hr.py 2012-12-10 11:16:54 +0000
3+++ hr/hr.py 2012-12-19 13:32:09 +0000
4@@ -69,6 +69,17 @@
5
6 hr_employee_category()
7
8+class hr_employee_marital_status(osv.osv):
9+ _name = "hr.employee.marital.status"
10+ _description = "Employee Marital Status"
11+ _columns = {
12+ 'name': fields.char('Marital Status', size=32, required=True, translate=True),
13+ 'description': fields.text('Status Description'),
14+ 'is_married': fields.boolean('Married ?'),
15+ }
16+
17+hr_employee_marital_status()
18+
19 class hr_job(osv.osv):
20
21 def _no_of_employee(self, cr, uid, ids, name, args, context=None):
22@@ -166,7 +177,8 @@
23 'identification_id': fields.char('Identification No', size=32),
24 'otherid': fields.char('Other Id', size=64),
25 'gender': fields.selection([('male', 'Male'),('female', 'Female')], 'Gender'),
26- 'marital': fields.selection([('single', 'Single'), ('married', 'Married'), ('widower', 'Widower'), ('divorced', 'Divorced')], 'Marital Status'),
27+ 'marital': fields.many2one('hr.employee.marital.status', 'Marital Status'),
28+ 'is_married': fields.boolean('Married ?', help="It will be set based on the configuration of 'Married ?' field of 'Employee Marital Status' object"),
29 'department_id':fields.many2one('hr.department', 'Department'),
30 'address_id': fields.many2one('res.partner', 'Working Address'),
31 'address_home_id': fields.many2one('res.partner', 'Home Address'),
32@@ -226,6 +238,12 @@
33 resource_ids.append(employee.resource_id.id)
34 return self.pool.get('resource.resource').unlink(cr, uid, resource_ids, context=context)
35
36+ def onchange_marital_status(self, cr, uid, ids, marital_status, context=None):
37+ if marital_status:
38+ marital_status = self.pool.get('hr.employee.marital.status').browse(cr, uid, marital_status, context=context)
39+ return {'value': {'is_married': marital_status.is_married}}
40+ return {'value': {}}
41+
42 def onchange_address_id(self, cr, uid, ids, address, context=None):
43 if address:
44 address = self.pool.get('res.partner').browse(cr, uid, address, context=context)
45
46=== modified file 'hr/hr_data.xml'
47--- hr/hr_data.xml 2012-11-29 22:26:45 +0000
48+++ hr/hr_data.xml 2012-12-19 13:32:09 +0000
49@@ -1,6 +1,21 @@
50 <?xml version="1.0" encoding="utf-8"?>
51 <openerp>
52 <data noupdate="1">
53+ <!-- Employee Marital Statusses -->
54+ <record id="hr_employee_marital_status_single" model="hr.employee.marital.status">
55+ <field name="name">Single</field>
56+ </record>
57+ <record id="hr_employee_marital_status_married" model="hr.employee.marital.status">
58+ <field name="name">Married</field>
59+ <field eval="1" name="is_married"/>
60+ </record>
61+ <record id="hr_employee_marital_status_divorced" model="hr.employee.marital.status">
62+ <field name="name">Divorced</field>
63+ </record>
64+ <record id="hr_employee_marital_status_widower" model="hr.employee.marital.status">
65+ <field name="name">Widower</field>
66+ </record>
67+
68 <!-- notify all employees of module installation -->
69 <record model="mail.message" id="module_install_notification">
70 <field name="model">mail.group</field>
71
72=== modified file 'hr/hr_view.xml'
73--- hr/hr_view.xml 2012-12-08 10:33:38 +0000
74+++ hr/hr_view.xml 2012-12-19 13:32:09 +0000
75@@ -68,7 +68,8 @@
76 </group>
77 <group string="Status">
78 <field name="gender"/>
79- <field name="marital"/>
80+ <field name="marital" widget="selection" on_change="onchange_marital_status(marital)"/>
81+ <field name="is_married" invisible="1"/>
82 </group>
83 <group string="Birth">
84 <field name="birthday"/>
85@@ -212,6 +213,41 @@
86 <field name="res_id" ref="hr.menu_open_view_employee_list_my"/>
87 </record>
88
89+ <!-- Employee marital status -->
90+ <record id="hr_hr_employee_marital_status_tree" model="ir.ui.view">
91+ <field name="name">hr.hr.employee.marital.status.tree</field>
92+ <field name="model">hr.employee.marital.status</field>
93+ <field name="arch" type="xml">
94+ <tree string="Marital Status">
95+ <field name="name" />
96+ </tree>
97+ </field>
98+ </record>
99+
100+ <record id="hr_hr_employee_marital_status_form" model="ir.ui.view">
101+ <field name="name">hr.hr.employee.marital.status</field>
102+ <field name="model">hr.employee.marital.status</field>
103+ <field name="arch" type="xml">
104+ <form string="Marital Status">
105+ <field name="name"/>
106+ <field name="is_married"/>
107+ <separator colspan="4" string="Description"/>
108+ <field colspan="4" name="description" nolabel="1"/>
109+ </form>
110+ </field>
111+ </record>
112+
113+ <record id="action_hr_marital_status" model="ir.actions.act_window">
114+ <field name="name">Marital Status</field>
115+ <field name="res_model">hr.employee.marital.status</field>
116+ <field name="view_type">form</field>
117+ <field name="view_mode">tree,form</field>
118+ <field name="view_id" ref="hr_hr_employee_marital_status_tree"/>
119+ </record>
120+
121+ <menuitem action="action_hr_marital_status" id="hr_menu_marital_status"
122+ parent="hr.menu_hr_configuration" sequence="3" groups="base.group_hr_manager"/>
123+
124 <!-- Employee architecture -->
125 <record id="view_partner_tree2" model="ir.ui.view">
126 <field name="name">hr.employee.tree</field>
127
128=== modified file 'hr/security/ir.model.access.csv'
129--- hr/security/ir.model.access.csv 2012-11-29 22:26:45 +0000
130+++ hr/security/ir.model.access.csv 2012-12-19 13:32:09 +0000
131@@ -7,4 +7,5 @@
132 access_hr_department_user,hr.department.user,model_hr_department,base.group_hr_user,1,1,1,1
133 access_hr_department_employee,hr.department.employee,model_hr_department,base.group_user,1,0,0,0
134 access_hr_job_user,hr.job user,model_hr_job,base.group_hr_user,1,1,1,1
135+access_hr_employee_marital_status_manager,hr.employee.marital.status.manager,model_hr_employee_marital_status,base.group_hr_manager,1,1,1,1
136 access_ir_property_hr_user,ir_property hr_user,base.model_ir_property,base.group_hr_user,1,1,1,0
137
138=== modified file 'hr_contract/test/test_hr_contract.yml'
139--- hr_contract/test/test_hr_contract.yml 2012-02-13 15:27:55 +0000
140+++ hr_contract/test/test_hr_contract.yml 2012-12-19 13:32:09 +0000
141@@ -10,7 +10,7 @@
142 gender: male
143 name: Mark Johnson
144 children: 2
145- marital: 'married'
146+ marital: hr.hr_employee_marital_status_married
147 place_of_birth: Belgium
148 vehicle: 'No'
149 vehicle_distance: 12
150
151=== modified file 'hr_payroll_account/test/hr_payroll_account.yml'
152--- hr_payroll_account/test/hr_payroll_account.yml 2012-11-29 22:26:45 +0000
153+++ hr_payroll_account/test/hr_payroll_account.yml 2012-12-19 13:32:09 +0000
154@@ -19,7 +19,7 @@
155 country_id: base.in
156 department_id: hr.dep_rd
157 gender: male
158- marital: single
159+ marital: hr.hr_employee_marital_status_single
160 name: John
161 bank_account_id: res_partner_bank_0
162 vehicle_distance: 0.0
163
164=== modified file 'l10n_be_hr_payroll/l10n_be_hr_payroll_data.xml'
165--- l10n_be_hr_payroll/l10n_be_hr_payroll_data.xml 2012-11-29 22:26:45 +0000
166+++ l10n_be_hr_payroll/l10n_be_hr_payroll_data.xml 2012-12-19 13:32:09 +0000
167@@ -113,7 +113,7 @@
168 <field name="sequence">120</field>
169 <field name="condition_select">python</field>
170 <field name="appears_on_payslip" eval="False"/>
171- <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>
172+ <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>
173 </record>
174 <record id="hr_payroll_rules_baremeII" model="hr.salary.rule">
175 <field name="category_id" ref="hr_payroll_head_pp"/>
176@@ -124,7 +124,7 @@
177 <field name="sequence">120</field>
178 <field name="condition_select">python</field>
179 <field name="appears_on_payslip" eval="False"/>
180- <field name="condition_python">result = ((employee.marital=='married' and employee.spouse_fiscal_status=='without income') and (employee.resident_bool!=True))</field>
181+ <field name="condition_python">result = ((employee.marital.is_married==True and employee.spouse_fiscal_status=='without income') and (employee.resident_bool!=True))</field>
182 </record>
183 <record id="hr_payroll_rules_baremeIII" model="hr.salary.rule">
184 <field name="category_id" ref="hr_payroll_head_pp"/>
185
186=== modified file 'l10n_be_hr_payroll/l10n_be_hr_payroll_demo.xml'
187--- l10n_be_hr_payroll/l10n_be_hr_payroll_demo.xml 2012-11-29 22:26:45 +0000
188+++ l10n_be_hr_payroll/l10n_be_hr_payroll_demo.xml 2012-12-19 13:32:09 +0000
189@@ -16,7 +16,7 @@
190 </record>
191
192 <record id="hr_payroll.hr_employee_payroll" model="hr.employee">
193- <field name="marital">single</field>
194+ <field name="marital" ref="hr.hr_employee_marital_status_single"/>
195 </record>
196
197 </data>
198
199=== modified file 'l10n_be_hr_payroll/l10n_be_hr_payroll_view.xml'
200--- l10n_be_hr_payroll/l10n_be_hr_payroll_view.xml 2012-11-29 22:26:45 +0000
201+++ l10n_be_hr_payroll/l10n_be_hr_payroll_view.xml 2012-12-19 13:32:09 +0000
202@@ -46,8 +46,8 @@
203 <field name="resident_bool" eval="False"/>
204 </xpath>
205 <xpath expr="//field[@name='marital']" position="after">
206- <field name="spouse_fiscal_status" attrs="{'invisible':[('marital','!=','married')],'required':[('marital','=','married')]}" colspan="1" help="if spouse has professionnel income or not"/>
207- <field name="disabled_spouse_bool" attrs="{'invisible':[('marital','!=','married')]}" colspan="1"/>
208+ <field name="spouse_fiscal_status" attrs="{'invisible':[('is_married','!=',True)],'required':[('is_married','=',True)]}" colspan="1" help="if spouse has professionnel income or not"/>
209+ <field name="disabled_spouse_bool" attrs="{'invisible':[('is_married','!=',True)]}" colspan="1"/>
210 </xpath>
211 <xpath expr="//field[@name='children']" position="after">
212 <field name="disabled_children_bool"/>

Subscribers

People subscribed via source and target branches

to all changes: