Merge lp:~openerp-groupes/hrself-addons/clean-onchange-leave-request into lp:hrself-addons
- clean-onchange-leave-request
- Merge into 6.0
Proposed by
tfr (Openerp)
Status: | Needs review |
---|---|
Proposed branch: | lp:~openerp-groupes/hrself-addons/clean-onchange-leave-request |
Merge into: | lp:hrself-addons |
Diff against target: |
279 lines (+82/-113) 2 files modified
hrself_holidays/hrself_holidays.py (+73/-104) hrself_holidays/view/hrself_holidays_view.xml (+9/-9) |
To merge this branch: | bzr merge lp:~openerp-groupes/hrself-addons/clean-onchange-leave-request |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
OpenERP Groupe S | Pending | ||
Review via email: mp+83417@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Unmerged revisions
- 624. By tfr (Openerp)
-
[CLEAN] refactor onchanges and constraints in leave request form view for details
See : http://pad.openerp. com/groupes- spec
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'hrself_holidays/hrself_holidays.py' | |||
2 | --- hrself_holidays/hrself_holidays.py 2011-11-25 10:02:29 +0000 | |||
3 | +++ hrself_holidays/hrself_holidays.py 2011-11-25 16:57:23 +0000 | |||
4 | @@ -721,12 +721,19 @@ | |||
5 | 721 | if not self._disable_checks(cr, uid, leave_request.type_id.id, activity_context_id) and not (leave_request.duration > 0): | 721 | if not self._disable_checks(cr, uid, leave_request.type_id.id, activity_context_id) and not (leave_request.duration > 0): |
6 | 722 | return False | 722 | return False |
7 | 723 | return True | 723 | return True |
8 | 724 | |||
9 | 725 | def _check_am_pm(self, cr, uid, ids, context=None): | ||
10 | 726 | for leave in self.browse(cr, uid, ids, context=context): | ||
11 | 727 | if leave.date_to != leave.date_from and leave.am_pm != AM_PM_ALL_DAY: | ||
12 | 728 | return False | ||
13 | 729 | return True | ||
14 | 724 | 730 | ||
15 | 725 | _constraints = [ | 731 | _constraints = [ |
16 | 726 | (_check_duration, _('Duration must be greater than 0 !'), ['duration']), | 732 | (_check_duration, _('Duration must be greater than 0 !'), ['duration']), |
18 | 727 | (_check_mandatory_reason, _('Type of holiday requires a reason'), ['reason']), | 733 | (_check_am_pm, _('The leave last more then one day, you should select all day'), ['am_pm']), |
19 | 728 | (_check_limit_date, _check_limit_date_message, ['date_to']), | 734 | (_check_limit_date, _check_limit_date_message, ['date_to']), |
20 | 729 | (_check_minimum_date, _check_minimum_date_message, ['date_from']), | 735 | (_check_minimum_date, _check_minimum_date_message, ['date_from']), |
21 | 736 | (_check_mandatory_reason, _('Type of holiday requires a reason'), ['reason']), | ||
22 | 730 | (_check_type_activity_context, _('This type is not compatible with activity context of employee'), ['type']), | 737 | (_check_type_activity_context, _('This type is not compatible with activity context of employee'), ['type']), |
23 | 731 | ] | 738 | ] |
24 | 732 | 739 | ||
25 | @@ -752,7 +759,7 @@ | |||
26 | 752 | old_date_to = hrself_datetime.to_date(leave.date_to) | 759 | old_date_to = hrself_datetime.to_date(leave.date_to) |
27 | 753 | new_date_to = _to_date(values.get('date_to'), old_date_to) | 760 | new_date_to = _to_date(values.get('date_to'), old_date_to) |
28 | 754 | if (new_date_from != old_date_from) or (new_date_to != old_date_to): | 761 | if (new_date_from != old_date_from) or (new_date_to != old_date_to): |
30 | 755 | on_change = self._onchange_date_type(cr, uid, [leave.id], leave.employee_id.id, new_date_from, new_date_to, leave.type_id.id, leave.am_pm, context) | 762 | on_change = self.onchange_date_type(cr, uid, [leave.id], leave.employee_id.id, new_date_from, new_date_to, leave.type_id.id, leave.am_pm, context) |
31 | 756 | warning = on_change.get('warning') | 763 | warning = on_change.get('warning') |
32 | 757 | if warning: | 764 | if warning: |
33 | 758 | logger.warning(warning['message']) | 765 | logger.warning(warning['message']) |
34 | @@ -764,106 +771,58 @@ | |||
35 | 764 | write_ids.append(leave.id) | 771 | write_ids.append(leave.id) |
36 | 765 | return super(hrself_holidays_request_leave, self).write(cr, uid, write_ids, values, context=context) | 772 | return super(hrself_holidays_request_leave, self).write(cr, uid, write_ids, values, context=context) |
37 | 766 | 773 | ||
47 | 767 | def onchange_employee_id(self, cr, uid, ids, employee_id, date_from, date_to, type_id, am_pm, context): | 774 | def onchange_date(self, cr, uid, ids, employee_id, date_from, date_to, type_id, am_pm, context=None): |
39 | 768 | """Action to execute when the user changes employee_id.""" | ||
40 | 769 | return self._onchange_date_type(cr, uid, ids, employee_id, date_from, date_to, type_id, am_pm, context) | ||
41 | 770 | |||
42 | 771 | def onchange_date_from(self, cr, uid, ids, employee_id, date_from, date_to, type_id, am_pm, context): | ||
43 | 772 | """Action to execute when the user changes date_from.""" | ||
44 | 773 | return self._onchange_dates_am_pm(cr, uid, ids, employee_id, date_from, date_to, type_id, am_pm, context) | ||
45 | 774 | |||
46 | 775 | def onchange_date_to(self, cr, uid, ids, employee_id, date_to, date_from, type_id, am_pm, context): | ||
48 | 776 | """Action to execute when the user changes date_to.""" | 775 | """Action to execute when the user changes date_to.""" |
54 | 777 | return self._onchange_dates_am_pm(cr, uid, ids, employee_id, date_from, date_to, type_id, am_pm, context) | 776 | print 'on_change_date' |
55 | 778 | 777 | if not date_from or not date_to: | |
56 | 779 | def onchange_type(self, cr, uid, ids, employee_id, date_from, date_to, type_id, am_pm, context): | 778 | print "return empty" |
57 | 780 | """Action to execute when the user changes the type.""" | 779 | return {} |
58 | 781 | return self._onchange_date_type(cr, uid, ids, employee_id, date_from, date_to, type_id, am_pm, context) | 780 | |
59 | 781 | if date_from > date_to: | ||
60 | 782 | message = _('The start date (%s) must be smaller or equal to the end date (%s)!') % (date_from, date_to) | ||
61 | 783 | return {'warning' : {'title': _('Invalid dates'), 'message': message}} | ||
62 | 784 | print 'onchange type finaly' | ||
63 | 785 | return self.onchange_date_type(cr, uid, ids, employee_id, date_from, date_to, type_id, am_pm, context) | ||
64 | 782 | 786 | ||
65 | 783 | def _disable_checks(self, cr, uid, type_id, activity_context_id): | 787 | def _disable_checks(self, cr, uid, type_id, activity_context_id): |
66 | 784 | """Disable checks?""" | 788 | """Disable checks?""" |
126 | 785 | result = False | 789 | if not type_id or not activity_context_id: |
127 | 786 | if type_id and activity_context_id: | 790 | return False |
128 | 787 | precision_id = self.pool.get('hrself.holidays.type').browse(cr, uid, type_id).precision_id_for_context(activity_context_id) | 791 | |
129 | 788 | if precision_id: | 792 | precision_id = self.pool.get('hrself.holidays.type').browse(cr, uid, type_id).precision_id_for_context(activity_context_id) |
130 | 789 | prestation_code = self.pool.get('hrself.holidays.type.precision').browse(cr, uid, precision_id).prestation_code_id | 793 | if precision_id: |
131 | 790 | if prestation_code and prestation_code.gross_leave: | 794 | prestation_code = self.pool.get('hrself.holidays.type.precision').browse(cr, uid, precision_id).prestation_code_id |
132 | 791 | result = True | 795 | if prestation_code and prestation_code.gross_leave: |
133 | 792 | return result | 796 | result = True |
134 | 793 | 797 | ||
135 | 794 | def onchange_duration(self, cr, uid, ids, employee_id, date_from, date_to, type_id, duration, unit, am_pm, context=None): | 798 | return False |
136 | 795 | """Action to execute when the user changes the duration.""" | 799 | |
137 | 796 | result = {} | 800 | def onchange_date_type(self, cr, uid, ids, employee_id, date_from, date_to, type_id, am_pm, context=None): |
79 | 797 | if employee_id and date_from and date_to: | ||
80 | 798 | services = self.pool.get('hrself.services').hrself_holidays_service(cr, uid, context=context) | ||
81 | 799 | activities = services.get_theoretical_activities(cr, uid, employee_id, date_from, date_to, context=context) | ||
82 | 800 | if not self._disable_checks(cr, uid, type_id, activities and activities[0] and activities[0]['activity_context']): | ||
83 | 801 | allowed_duration = self._duration(cr, uid, type_id, am_pm, activities)['value']['duration'] | ||
84 | 802 | if unit == hrself.TIME_UNIT_HOUR and date_from == date_to: | ||
85 | 803 | if duration > allowed_duration: | ||
86 | 804 | result['warning'] = { | ||
87 | 805 | 'title': _('Warning'), | ||
88 | 806 | 'message': _('The leave request duration is greater than allowed. \n You have %d %s(s) left.') % | ||
89 | 807 | (allowed_duration, hrself.TIME_UNITS_DICT[unit]) | ||
90 | 808 | } | ||
91 | 809 | result['value'] = {'duration': allowed_duration} | ||
92 | 810 | elif duration <> allowed_duration: | ||
93 | 811 | result['warning'] = {'title': _('Warning'), 'message': _('You cannot change the duration.')} | ||
94 | 812 | result['value'] = {'duration': allowed_duration} | ||
95 | 813 | return result | ||
96 | 814 | |||
97 | 815 | def onchange_unit(self, cr, uid, ids, employee_id, date_from, date_to, type_id, unit, am_pm, context=None): | ||
98 | 816 | """Action to execute when the user changes the unit.""" | ||
99 | 817 | result = {} | ||
100 | 818 | date_from = date_from or fields.date.today() | ||
101 | 819 | date_to = date_to or fields.date.today() | ||
102 | 820 | if employee_id: | ||
103 | 821 | services = self.pool.get('hrself.services').hrself_holidays_service(cr, uid, context=context) | ||
104 | 822 | activities = services.get_theoretical_activities(cr, uid, employee_id, date_from, date_to, context=context) | ||
105 | 823 | allowed_unit = self._duration(cr, uid, type_id, am_pm, activities)['value']['unit'] | ||
106 | 824 | if unit <> allowed_unit: | ||
107 | 825 | result['warning'] = {'title': _('Warning'), 'message': _('You cannot change the unit.')} | ||
108 | 826 | result['value'] = {'unit': allowed_unit} | ||
109 | 827 | return result | ||
110 | 828 | |||
111 | 829 | def _onchange_dates_am_pm(self, cr, uid, ids, employee_id, date_from, date_to, type_id, am_pm, context): | ||
112 | 830 | """Action to execute when the user changes dates (from or to) or the AM PM indicator.""" | ||
113 | 831 | result = {} | ||
114 | 832 | if am_pm != AM_PM_ALL_DAY and date_from != date_to: | ||
115 | 833 | am_pm = AM_PM_ALL_DAY | ||
116 | 834 | result['warning'] = {'title': _('Warning'), 'message': _('You cannot set AM or PM when start date is not equal to end date.')} | ||
117 | 835 | result.update(self._onchange_date_type(cr, uid, ids, employee_id, date_from, date_to, type_id, am_pm, context)) | ||
118 | 836 | result['value']['am_pm'] = am_pm | ||
119 | 837 | return result | ||
120 | 838 | |||
121 | 839 | def onchange_am_pm(self, cr, uid, ids, employee_id, date_from, date_to, type_id, am_pm, context): | ||
122 | 840 | """Action to execute when the user changes the AM PM indicator.""" | ||
123 | 841 | return self._onchange_dates_am_pm(cr, uid, ids, employee_id, date_from, date_to, type_id, am_pm, context) | ||
124 | 842 | |||
125 | 843 | def _onchange_date_type(self, cr, uid, ids, employee_id, date_from, date_to, type_id, am_pm, context): | ||
138 | 844 | """Action to execute when the user changes a date (from or to) or the type.""" | 801 | """Action to execute when the user changes a date (from or to) or the type.""" |
139 | 802 | print "on change type", employee_id, date_from, date_to, type_id, am_pm | ||
140 | 803 | |||
141 | 845 | result = {} | 804 | result = {} |
142 | 846 | activities = None | 805 | activities = None |
146 | 847 | if date_from and date_to: | 806 | if not (date_from and date_to and type_id and employee_id): |
147 | 848 | if date_from > date_to: | 807 | return result |
148 | 849 | message = _('The start date (%s) must be smaller or equal to the end date (%s)!') % (date_from, date_to) | 808 | |
149 | 809 | |||
150 | 810 | services = self.pool.get('hrself.services').hrself_holidays_service(cr, uid, context=context) | ||
151 | 811 | activities = services.get_theoretical_activities(cr, uid, employee_id, date_from, date_to, context=context) | ||
152 | 812 | if not self._disable_checks(cr, uid, type_id, activities and activities[0] and activities[0]['activity_context']): | ||
153 | 813 | present = False | ||
154 | 814 | absence_days = set() | ||
155 | 815 | for activity in activities: | ||
156 | 816 | if activity['presence_absence'] == 'A': | ||
157 | 817 | date = hrself_datetime.to_string(hrself_datetime.to_date(activity['date'])) | ||
158 | 818 | absence_days.add(date) | ||
159 | 819 | elif activity['presence_absence'] == 'P': | ||
160 | 820 | present = True | ||
161 | 821 | if not present: | ||
162 | 822 | message = _('You cannot take leave on absence days: ') + ', '.join(absence_days) | ||
163 | 850 | result['warning'] = {'title': _('Invalid dates'), 'message': message} | 823 | result['warning'] = {'title': _('Invalid dates'), 'message': message} |
180 | 851 | elif employee_id and type_id: | 824 | |
181 | 852 | services = self.pool.get('hrself.services').hrself_holidays_service(cr, uid, context=context) | 825 | result.update(self._duration(cr, uid, type_id, am_pm, activities)) |
166 | 853 | activities = services.get_theoretical_activities(cr, uid, employee_id, date_from, date_to, context=context) | ||
167 | 854 | if not self._disable_checks(cr, uid, type_id, activities and activities[0] and activities[0]['activity_context']): | ||
168 | 855 | presence_days = [] | ||
169 | 856 | absence_days = [] | ||
170 | 857 | for activity in activities: | ||
171 | 858 | date = hrself_datetime.to_string(hrself_datetime.to_date(activity['date'])) | ||
172 | 859 | if activity['presence_absence'] == 'A' and date not in absence_days: | ||
173 | 860 | absence_days.append(date) | ||
174 | 861 | elif activity['presence_absence'] == 'P' and date not in presence_days: | ||
175 | 862 | presence_days.append(date) | ||
176 | 863 | if not presence_days: | ||
177 | 864 | message = _('You cannot take leave on absence days: ') + ', '.join(absence_days) | ||
178 | 865 | result['warning'] = {'title': _('Invalid dates'), 'message': message} | ||
179 | 866 | result.update(self._duration(cr, uid, type_id, am_pm, activities)) | ||
182 | 867 | return result | 826 | return result |
183 | 868 | 827 | ||
184 | 869 | def _duration(self, cr, uid, type_id, am_pm, activities): | 828 | def _duration(self, cr, uid, type_id, am_pm, activities): |
185 | @@ -893,7 +852,7 @@ | |||
186 | 893 | duration = duration_in_hour | 852 | duration = duration_in_hour |
187 | 894 | else: | 853 | else: |
188 | 895 | type = self.pool.get('hrself.holidays.type').browse (cr, uid, type_id) | 854 | type = self.pool.get('hrself.holidays.type').browse (cr, uid, type_id) |
190 | 896 | message = _('No precision defined for the holidays type named %s identified by %d') % (type.name , type.id) | 855 | message = _('No precision defined for the holidays type named %s identified by %d, please contact your administrator') % (type.name , type.id) |
191 | 897 | result['warning'] = {'title': _('No precision'), 'message': message} | 856 | result['warning'] = {'title': _('No precision'), 'message': message} |
192 | 898 | result['value'] = { | 857 | result['value'] = { |
193 | 899 | 'duration': duration, | 858 | 'duration': duration, |
194 | @@ -943,16 +902,21 @@ | |||
195 | 943 | return None | 902 | return None |
196 | 944 | 903 | ||
197 | 945 | def _check_allowed_duration(self, cr, uid, ids, context=None): | 904 | def _check_allowed_duration(self, cr, uid, ids, context=None): |
203 | 946 | """Check that the leave request duration is not greater than allowed. | 905 | """ |
204 | 947 | For the moment, only takes into account leaves | 906 | Check that the leave request duration is not greater than allowed. |
205 | 948 | where date from is equal to date to. | 907 | For the moment, only takes into account leaves |
206 | 949 | :return: (allowed duration, unit) | 908 | where date from is equal to date to. |
207 | 950 | :rtype: (int, str)""" | 909 | :return: (allowed duration, unit) |
208 | 910 | :rtype: (int, str) | ||
209 | 911 | """ | ||
210 | 951 | for leave in self.browse(cr, uid, ids, context=context): | 912 | for leave in self.browse(cr, uid, ids, context=context): |
211 | 952 | date_from = leave.date_from | 913 | date_from = leave.date_from |
212 | 953 | date_to = leave.date_to | 914 | date_to = leave.date_to |
213 | 915 | employee_id = leave.employee_id.id | ||
214 | 916 | services = self.pool.get('hrself.services').hrself_holidays_service(cr, uid, context=context) | ||
215 | 917 | activities = services.get_theoretical_activities(cr, uid, employee_id, date_from, date_to, context=context) | ||
216 | 954 | if date_from == date_to: | 918 | if date_from == date_to: |
218 | 955 | employee_id = leave.employee_id.id | 919 | |
219 | 956 | search_ids = self.search(cr, uid, [ | 920 | search_ids = self.search(cr, uid, [ |
220 | 957 | ('employee_id', '=', employee_id), | 921 | ('employee_id', '=', employee_id), |
221 | 958 | '|', ('state', '=', STATE_APPROVED), ('state', '=', STATE_CONFIRMED), | 922 | '|', ('state', '=', STATE_APPROVED), ('state', '=', STATE_CONFIRMED), |
222 | @@ -972,12 +936,17 @@ | |||
223 | 972 | already_taken += search_leave.duration | 936 | already_taken += search_leave.duration |
224 | 973 | else: | 937 | else: |
225 | 974 | already_taken += search_leave.duration_in_hour | 938 | already_taken += search_leave.duration_in_hour |
228 | 975 | services = self.pool.get('hrself.services').hrself_holidays_service(cr, uid, context=context) | 939 | |
227 | 976 | activities = services.get_theoretical_activities(cr, uid, employee_id, date_from, date_to, context=context) | ||
229 | 977 | max_duration = self._duration(cr, uid, leave.type_id.id, AM_PM_ALL_DAY, activities)['value']['duration_in_hour'] | 940 | max_duration = self._duration(cr, uid, leave.type_id.id, AM_PM_ALL_DAY, activities)['value']['duration_in_hour'] |
230 | 978 | allowed_duration = max(round(max_duration - already_taken, 2), 0.0) | 941 | allowed_duration = max(round(max_duration - already_taken, 2), 0.0) |
231 | 979 | if leave.duration > allowed_duration: | 942 | if leave.duration > allowed_duration: |
232 | 980 | return (allowed_duration, hrself.TIME_UNIT_HOUR_LABEL) | 943 | return (allowed_duration, hrself.TIME_UNIT_HOUR_LABEL) |
233 | 944 | elif leave.unit != hrself.TIME_UNIT_HOUR: | ||
234 | 945 | compute_duration = self._duration(cr, uid, leave.type_id.id, leave.am_pm, activities).get('value', {}).get('duration', -1) | ||
235 | 946 | disable_check = self._disable_checks(cr, uid, leave.type_id.id, leave.activity_context_id.id) | ||
236 | 947 | if leave.duration != compute_duration and not disable_check: | ||
237 | 948 | return (compute_duration, hrself.TIME_UNIT_DAY_LABEL) | ||
238 | 949 | |||
239 | 981 | return False | 950 | return False |
240 | 982 | 951 | ||
241 | 983 | def _check_priority(self, cr, uid, ids, context=None): | 952 | def _check_priority(self, cr, uid, ids, context=None): |
242 | @@ -1068,7 +1037,7 @@ | |||
243 | 1068 | 1037 | ||
244 | 1069 | allowed = self._check_allowed_duration(cr, uid, ids, context=context) | 1038 | allowed = self._check_allowed_duration(cr, uid, ids, context=context) |
245 | 1070 | if allowed : | 1039 | if allowed : |
247 | 1071 | raise osv.except_osv(_('Warning!'), _('The leave request duration is greater than allowed. \n You have %.2f %s(s) left.') % allowed) | 1040 | raise osv.except_osv(_('Warning!'), _('The leave request duration is different than allowed. \n %.2f %s(s) is allowed.') % allowed) |
248 | 1072 | 1041 | ||
249 | 1073 | for leave_request in self.browse(cr, uid, ids, context=context): | 1042 | for leave_request in self.browse(cr, uid, ids, context=context): |
250 | 1074 | type_name = self._check_priority(cr, uid, ids, context) | 1043 | type_name = self._check_priority(cr, uid, ids, context) |
251 | 1075 | 1044 | ||
252 | === modified file 'hrself_holidays/view/hrself_holidays_view.xml' | |||
253 | --- hrself_holidays/view/hrself_holidays_view.xml 2011-11-24 10:12:14 +0000 | |||
254 | +++ hrself_holidays/view/hrself_holidays_view.xml 2011-11-25 16:57:23 +0000 | |||
255 | @@ -204,15 +204,15 @@ | |||
256 | 204 | <field name="arch" type="xml"> | 204 | <field name="arch" type="xml"> |
257 | 205 | <form string="Leave Request"> | 205 | <form string="Leave Request"> |
258 | 206 | <group col="6" colspan="4"> | 206 | <group col="6" colspan="4"> |
268 | 207 | <field name="employee_id" on_change="onchange_employee_id(employee_id,date_from,date_to,type_id,am_pm,context)"/> | 207 | <field name="employee_id" on_change="onchange_date_type(employee_id,date_from,date_to,type_id,am_pm, context)" /> |
269 | 208 | <field name="date_from" on_change="onchange_date_from(employee_id,date_from,date_to,type_id,am_pm,context)"/> | 208 | <field name="date_from" on_change="onchange_date(employee_id,date_from,date_to,type_id,am_pm, context)" /> |
270 | 209 | <field name="date_to" required="1" on_change="onchange_date_to(employee_id,date_to,date_from,type_id,am_pm,context)"/> | 209 | <field name="date_to" required="1" on_change="onchange_date(employee_id,date_from,date_to,type_id,am_pm, context)" /> |
271 | 210 | <field name="type_id" default_focus="1" on_change="onchange_type(employee_id,date_from,date_to,type_id,am_pm,context)" context="{'employee_id': employee_id, 'date_from': date_from, 'date_to': date_to}" attrs="{'readonly': ['|', ('date_from', '=', False), ('employee_id', '=', False)]}"/> | 210 | <field name="type_id" default_focus="1" on_change="onchange_date_type(employee_id,date_from,date_to,type_id,am_pm, context)" context="{'employee_id': employee_id, 'date_from': date_from, 'date_to': date_to}" attrs="{'readonly': [('employee_id', '=', False)]}" /> |
272 | 211 | <field name="duration" on_change="onchange_duration(employee_id,date_from,date_to,type_id,duration,unit,am_pm,context)"/> | 211 | <field name="duration"/> |
273 | 212 | <field name="unit" on_change="onchange_unit(employee_id,date_from,date_to,type_id,unit,am_pm,context)"/> | 212 | <field name="unit" /> |
274 | 213 | <field name="reason_id" domain="[('type_id', '=', type_id)]"/> | 213 | <field name="reason_id" domain="[('type_id', '=', type_id)]" /> |
275 | 214 | <field name="name"/> | 214 | <field name="name" /> |
276 | 215 | <field name="am_pm" on_change="onchange_am_pm(employee_id,date_from,date_to,type_id,am_pm,context)"/> | 215 | <field name="am_pm" on_change="onchange_date_type(employee_id,date_from,date_to,type_id,am_pm, context)"/> |
277 | 216 | <!-- Duration (in hour) is visible when the unit is day. | 216 | <!-- Duration (in hour) is visible when the unit is day. |
278 | 217 | So the opposite is: duration (in hour) is invisible when the unit is not day. --> | 217 | So the opposite is: duration (in hour) is invisible when the unit is not day. --> |
279 | 218 | <field name="duration_in_hour" attrs="{'invisible': [('unit', '!=', 1)]}"/> | 218 | <field name="duration_in_hour" attrs="{'invisible': [('unit', '!=', 1)]}"/> |