[FIX]: Fix default user timesheetline problem
[odoo/odoo.git] / addons / hr_timesheet_sheet / hr_timesheet_sheet_view.xml
1 <?xml version="1.0" encoding="utf-8"?>
2 <openerp>
3     <data>
4
5         <record id="hr_timesheet_account_form" model="ir.ui.view">
6             <field name="name">hr.timesheet.account.form</field>
7             <field name="model">hr_timesheet_sheet.sheet.account</field>
8             <field name="arch" type="xml">
9                 <form string="Timesheet by Accounts" version="7.0">
10                     <group col="4">
11                         <field name="sheet_id"/>
12                         <field name="name" groups="analytic.group_analytic_accounting"/>
13                         <field name="total" sum="Total"/>
14                         <field name="invoice_rate"/>
15                     </group>
16                 </form>
17             </field>
18         </record>
19         <record id="hr_timesheet_account_filter" model="ir.ui.view">
20             <field name="name">hr.timesheet.account.filter</field>
21             <field name="model">hr_timesheet_sheet.sheet.account</field>
22             <field name="arch" type="xml">
23                 <search string="Search Account">
24                     <field name="name" groups="analytic.group_analytic_accounting"/>
25                     <field name="invoice_rate"/>
26                     <field name="sheet_id" />
27                 </search>
28             </field>
29         </record>
30         <record id="hr_timesheet_account_tree" model="ir.ui.view">
31             <field name="name">hr.timesheet.account.tree</field>
32             <field name="model">hr_timesheet_sheet.sheet.account</field>
33             <field name="arch" type="xml">
34                 <tree string="Timesheet by Accounts">
35                     <field name="sheet_id"/>
36                     <field name="name" groups="analytic.group_analytic_accounting"/>
37                     <field name="total" sum="Total"/>
38                     <field name="invoice_rate"/>
39                 </tree>
40             </field>
41         </record>
42
43         <record id="hr_timesheet_sheet_form" model="ir.ui.view">
44             <field name="name">hr.timesheet.sheet.form</field>
45             <field name="model">hr_timesheet_sheet.sheet</field>
46             <field name="arch" type="xml">
47                 <form string="Timesheet" version="7.0">
48                 <header>
49                     <button name="button_confirm" states="draft" string="Submit to Manager" type="object" class="oe_highlight"/>
50                     <button name="done" states="confirm" string="Approve" type="workflow" groups="base.group_hr_user" class="oe_highlight"/>
51                     <button name="action_set_to_draft" states="done" string="Set to Draft" type="object" />
52                     <button name="cancel" states="confirm" string="Refuse" type="workflow" groups="base.group_hr_user" />
53                     <field name="state" widget="statusbar" statusbar_visible="new,confirm,done"/>
54                 </header>
55                 <sheet>
56                     <label for="employee_id" class="oe_edit_only"/>
57                     <h1><field name="employee_id" on_change="onchange_employee_id(employee_id)"/></h1>
58                     <label for="date_from" class="oe_edit_only" string="Timesheet Period"/>
59                     <h2>From <field name="date_from"/> to <field name="date_to"/></h2>
60                     <group>
61                         <group>
62                             <field name="name"/>
63                             <field name="department_id"/>
64                             <field name="company_id" groups="base.group_multi_company"/>
65                         </group>
66                         <group>
67                             <field name="total_attendance" widget="float_time" groups="base.group_hr_attendance"/>
68                             <field name="total_timesheet" widget="float_time"/>
69                             <field name="total_difference" widget="float_time" groups="base.group_hr_attendance"/>
70                             <field name="user_id" invisible="1"/>
71                         </group>
72                     </group>
73                     <notebook>
74                         <page string="Weekly">
75                             <widget type="weekly_timesheet">
76                             </widget>
77                         </page>
78                         <page string="Daily">
79                             <group colspan="4" col="3">
80                                 <field context="{'user_id':user_id}" name="attendances_ids" nolabel="1" groups="base.group_hr_attendance">
81                                     <tree string="Attendances" editable="bottom">
82                                         <field name="name"/>
83                                         <field name="action"/>
84                                         <field invisible="1" name="employee_id"/>
85                                     </tree>
86                                 </field>
87                                 <group>
88                                     <div align="right" groups="base.group_hr_manager,base.group_hr_attendance">
89                                         <button name="attendance_action_change" attrs="{'invisible': [('state_attendance', '=', 'present')]}" type="object" string="Sign In" groups="base.group_hr_attendance"/>
90                                         <button name="attendance_action_change" attrs="{'invisible': ['|', ('state_attendance','=',False), ('state_attendance', '=', 'absent')]}" type="object" string="Sign Out" groups="base.group_hr_attendance"/>
91                                     </div>
92                                 </group>
93                             </group>
94                             <group col="4">
95                                 <field name="state_attendance" groups="base.group_hr_attendance"/>
96                             </group>
97                             <field colspan="4" context="{'user_id':user_id}" name="timesheet_ids" nolabel="1">
98                                 <tree editable="top" string="Timesheet Lines">
99                                     <field name="date"/>
100                                     <field domain="[('type','in',['normal', 'contract']), ('state', '&lt;&gt;', 'close'),('use_timesheets','=',1)]" name="account_id" on_change="on_change_account_id(account_id, user_id)" context="{'default_use_timesheets': 1}"/>
101                                     <field name="name"/>
102                                     <field name="unit_amount" on_change="on_change_unit_amount(product_id, unit_amount, False, product_uom_id,journal_id)" widget="float_time"/>
103                                     <field name="to_invoice" widget="selection"/>
104                                     <field invisible="1" name="journal_id"/>
105                                     <field invisible="1" name="product_id" domain="[('type','=','service')]" on_change="on_change_unit_amount(product_id, unit_amount, False, product_uom_id,journal_id)"/>
106                                     <field invisible="1" name="product_uom_id" on_change="on_change_unit_amount(product_id, unit_amount, False, product_uom_id,journal_id)"/>
107                                     <field invisible="1" name="amount"/>
108                                     <field invisible="1" name="general_account_id"/>
109                                     <field  name="user_id" required="1" />
110                                 </tree>
111                                 <form string="Timesheet Lines" version="7.0">
112                                     <field name="date"/>
113                                     <field domain="[('type','=','normal'), ('state', '&lt;&gt;', 'close')]" name="account_id" on_change="on_change_account_id(account_id, user_id)"/>
114                                     <field name="name"/>
115                                     <field name="unit_amount" on_change="on_change_unit_amount(product_id, unit_amount, False, product_uom_id,journal_id)" widget="float_time"/>
116                                     <field name="to_invoice"/>
117                                     <field name="journal_id"/>
118                                     <field name="product_id" domain="[('type','=','service')]" on_change="on_change_unit_amount(product_id, unit_amount, False, product_uom_id,journal_id)"/>
119                                     <field name="product_uom_id" on_change="on_change_unit_amount(product_id, unit_amount, False, product_uom_id,journal_id)"/>
120                                     <field name="amount"/>
121                                     <field name="general_account_id"/>
122                                     <field name="user_id" required="1"/>
123                                 </form>
124                             </field>
125                         </page>
126                         <page string="Summary">
127                             <field colspan="4" name="period_ids" nolabel="1">
128                                 <tree colors="red:total_difference&lt;0.1;blue:total_difference&gt;=0.1" string="Period">
129                                     <field name="name"/>
130                                     <field name="total_attendance" widget="float_time" groups="base.group_hr_attendance"/>
131                                     <field name="total_timesheet" widget="float_time"/>
132                                     <field name="total_difference" widget="float_time" groups="base.group_hr_attendance"/>
133                                 </tree>
134                             </field>
135                         </page>
136                     </notebook>
137                 </sheet>
138                 <div class="oe_chatter">
139                     <field name="message_ids" colspan="4" widget="mail_thread" nolabel="1"/>
140                     <field name="message_follower_ids" widget="mail_followers"/>
141                 </div>
142                 </form>
143             </field>
144         </record>
145
146         <record id="view_hr_timesheet_sheet_filter" model="ir.ui.view">
147             <field name="name">hr_timesheet_sheet.sheet.filter</field>
148             <field name="model">hr_timesheet_sheet.sheet</field>
149             <field name="arch" type="xml">
150                 <search string="Search Timesheet">
151                     <field name="date_from"/>
152                     <filter icon="terp-document-new" string="In Draft" domain="[('state','in',('draft', 'new'))]" help="Unvalidated Timesheets"/>
153                     <filter icon="terp-camera_test" string="To Approve" domain="[('state','=','confirm')]" help="Confirmed Timesheets"/>
154                     <field name="employee_id"/>
155                     <field name="department_id"/>
156                     <group expand="0" string="Group By...">
157                         <filter string="Employees" icon="terp-personal" domain="[]" context="{'group_by':'employee_id'}"/>
158                         <filter string="Department" icon="terp-personal+" domain="[]" context="{'group_by':'department_id'}"/>
159                     </group>
160                 </search>
161             </field>
162         </record>
163
164         <record id="act_hr_timesheet_sheet_form" model="ir.actions.act_window">
165             <field name="name">Timesheets</field>
166             <field name="type">ir.actions.act_window</field>
167             <field name="res_model">hr_timesheet_sheet.sheet</field>
168             <field name="view_type">form</field>
169             <field name="view_id" eval="False"/>
170             <field name="context">{'search_default_my_timesheet':1}</field>
171             <field name="search_view_id" ref="view_hr_timesheet_sheet_filter"/>
172             <field name="help" type="html">
173               <p class="oe_view_nocontent_create">
174                 Click to go to your timesheet. 
175               </p><p>
176                 You must record timesheets every day and confirm at the end
177                 of the week. Once the timesheet is confirmed, it his sent to
178                 the manager for validation.
179               </p><p>
180                 Timesheets can also be invoiced to customers, depending on the
181                 configuration of the project.
182               </p>
183             </field>
184         </record>
185
186         <menuitem action="act_hr_timesheet_sheet_form" id="menu_act_hr_timesheet_sheet_form" parent="hr_attendance.menu_hr_time_tracking"
187              sequence="2" groups="base.group_hr_user"/>
188
189         <!--
190             Company inheritancy
191         -->
192
193         <record id="hr_timesheet_sheet_company" model="ir.ui.view">
194             <field name="name">res.company.sheet</field>
195             <field name="model">res.company</field>
196             <field name="inherit_id" ref="base.view_company_form"/>
197             <field name="arch" type="xml">
198                 <xpath expr="//group[@name='account_grp']" position="after">
199                     <group name="timesheets_grp" string="Timesheets">
200                         <field name="timesheet_range"/>
201                         <field name="timesheet_max_difference"/>
202                     </group>
203                 </xpath>
204             </field>
205         </record>
206
207         <!--
208             hr.analytic.timesheet inheritancy
209         -->
210
211         <record id="hr_timesheet_line_form" model="ir.ui.view">
212             <field name="name">hr.analytic.timesheet.form</field>
213             <field name="model">hr.analytic.timesheet</field>
214             <field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_form"/>
215             <field name="arch" type="xml">
216                 <field name="date" position="after">
217                     <field name="sheet_id" />
218                 </field>
219             </field>
220         </record>
221
222         <record id="hr_timesheet_line_search" model="ir.ui.view">
223             <field name="name">hr.analytic.timesheet.search</field>
224             <field name="model">hr.analytic.timesheet</field>
225             <field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_search"/>
226             <field name="arch" type="xml">
227                 <field name="date" position="before">
228                     <field name="sheet_id"/>
229                 </field>
230             </field>
231         </record>
232
233         <!--
234             hr.attendance inheritancy
235         -->
236
237         <record model="ir.ui.view" id="view_hr_attendance_filter">
238             <field name="name">view_hr_attendance_filter</field>
239             <field name="model">hr.attendance</field>
240             <field name="inherit_id" ref="hr_attendance.view_hr_attendance_filter" />
241             <field name="arch" type="xml">
242                 <field name="employee_id" position="after">
243                     <field name="sheet_id"/>
244                 </field>
245             </field>
246         </record>
247
248         <record id="view_attendance_form" model="ir.ui.view">
249             <field name="name">hr.attendance.form</field>
250             <field name="model">hr.attendance</field>
251             <field name="inherit_id" ref="hr_attendance.view_attendance_form"/>
252             <field name="arch" type="xml">
253                 <field name="action_desc" position="after">
254                     <field name="sheet_id"/>
255                 </field>
256             </field>
257         </record>
258         <record id="view_attendance_tree" model="ir.ui.view">
259             <field name="name">hr.attendance.tree</field>
260             <field name="model">hr.attendance</field>
261             <field name="inherit_id" ref="hr_attendance.view_attendance_tree"/>
262             <field name="arch" type="xml">
263                 <field name="action" position="after">
264                     <field name="sheet_id"/>
265                 </field>
266             </field>
267         </record>
268         <record id="view_attendance_tree_who" model="ir.ui.view">
269             <field name="name">hr.attendance.tree</field>
270             <field name="model">hr.attendance</field>
271             <field name="inherit_id" ref="hr_attendance.view_attendance_who"/>
272             <field name="arch" type="xml">
273                 <field name="action" position="after">
274                     <field name="sheet_id"/>
275                 </field>
276             </field>
277         </record>
278
279         <act_window
280         context="{'search_default_sheet_id': [active_id]}"
281         id="act_hr_timesheet_sheet_sheet_by_account"
282         name="Timesheet by Account"
283         res_model="hr_timesheet_sheet.sheet.account"
284         src_model="hr_timesheet_sheet.sheet"/>
285
286         <act_window
287         context="{'search_default_sheet_id': [active_id]}"
288         id="act_hr_timesheet_sheet_sheet_by_day"
289         name="Timesheet by Day"
290         res_model="hr_timesheet_sheet.sheet.day"
291         src_model="hr_timesheet_sheet.sheet"/>
292
293         <act_window
294         context="{'search_default_sheet_id': [active_id]}"
295         id="act_hr_timesheet_sheet_sheet_2_hr_analytic_timesheet"
296         name="Timesheet Lines"
297         res_model="hr.analytic.timesheet"
298         src_model="hr_timesheet_sheet.sheet"/>
299
300
301         <act_window
302         context="{'search_default_sheet_id': [active_id]}"
303         id="act_hr_timesheet_sheet_sheet_2_hr_attendance"
304         name="Attendances"
305         res_model="hr.attendance"
306         src_model="hr_timesheet_sheet.sheet"/>
307
308         <record id="hr_timesheet_sheet_tree_simplified" model="ir.ui.view">
309             <field name="name">hr.timesheet.sheet.tree</field>
310             <field name="model">hr_timesheet_sheet.sheet</field>
311             <field eval="10" name="priority"/>
312             <field name="arch" type="xml">
313                 <tree colors="blue:state == 'draft';black:state in ('confirm','new');gray:state == 'done'" string="Timesheets">
314                     <field name="employee_id"/>
315                     <field name="date_from"/>
316                     <field name="date_to"/>
317                     <field name="department_id"/>
318                     <field name="total_attendance" widget="float_time" groups="base.group_hr_attendance"/>
319                     <field name="total_timesheet" widget="float_time"/>
320                     <field name="total_difference" widget="float_time" groups="base.group_hr_attendance"/>
321                     <field name="state"/>
322                 </tree>
323             </field>
324         </record>
325
326         <record id="hr_timesheet_day_tree" model="ir.ui.view">
327             <field name="name">hr.timesheet.day.tree</field>
328             <field name="model">hr_timesheet_sheet.sheet.day</field>
329             <field name="arch" type="xml">
330                 <tree colors="blue:total_difference&lt;0.1;red:total_difference&gt;=0.1" string="Period">
331                     <field name="name"/>
332                     <field name="total_attendance" widget="float_time" sum="Total Attendances" groups="base.group_hr_attendance"/>
333                     <field name="total_timesheet" widget="float_time" sum="Total Timesheet"/>
334                     <field name="total_difference" widget="float_time" sum="Total Difference" groups="base.group_hr_attendance"/>
335                 </tree>
336             </field>
337         </record>
338
339   <!-- Timesheet Button on Employee Form -->
340            
341     <record id="act_hr_employee_2_hr_timesheet" model="ir.actions.act_window">
342         <field name="res_model">hr_timesheet_sheet.sheet</field>
343         <field name="view_type">form</field>
344         <field name="name">Timesheets</field>
345         <field name="view_mode">tree,form</field>
346         <field name="context">{'search_default_employee_id': [active_id], 'default_employee_id': active_id}</field>
347     </record>
348          
349       <record id="hr_timesheet_sheet_employee_extd_form" model="ir.ui.view">
350             <field name="name">hr.timesheet.sheet.employee.extd_form</field>
351             <field name="model">hr.employee</field>
352             <field name="inherit_id" ref="hr_timesheet.hr_timesheet_employee_extd_form"/>
353             <field name="arch" type="xml">
354                 <xpath expr="//div[@name='button_box']" position="inside">
355                     <button name="%(act_hr_employee_2_hr_timesheet)d" string="Timesheets" type="action" groups="base.group_hr_manager"/>
356                 </xpath>
357             </field>
358         </record>
359
360     </data>
361 </openerp>