Fix view for new field function sheet_id and improve fields_mod

bzr revid: ced-34cb68b361cc596c935667c947d5fe6f529226e7
This commit is contained in:
ced 2007-09-21 06:31:47 +00:00
parent 4f5388ebba
commit 79f8455aad
2 changed files with 35 additions and 19 deletions

View File

@ -59,7 +59,7 @@ class one2many_mod2(fields.one2many):
for r in obj.pool.get(self._obj)._read_flat(cr, user, ids2,
[self._fields_id], context=context, load='_classic_write'):
if r[self._fields_id]:
res[r[self._fields_id][0]].append(r['id'])
res.setdefault(r[self._fields_id][0], []).append(r['id'])
return res
@ -86,7 +86,7 @@ class one2many_mod(fields.one2many):
for r in obj.pool.get(self._obj)._read_flat(cr, user, ids2,
[self._fields_id], context=context, load='_classic_write'):
if r[self._fields_id]:
res[r[self._fields_id][0]].append(r['id'])
res.setdefault(r[self._fields_id][0], []).append(r['id'])
return res
@ -466,24 +466,35 @@ class hr_timesheet_sheet_sheet_day(osv.osv):
select
min(hrt.id) as id,
l.date::date as name,
hrt.sheet_id as sheet_id,
s.id as sheet_id,
sum(l.unit_amount) as total_timesheet,
0.0 as total_attendance
from
hr_analytic_timesheet hrt
left join account_analytic_line l on (l.id = hrt.line_id)
group by l.date::date, hrt.sheet_id
left join (account_analytic_line l
LEFT JOIN hr_timesheet_sheet_sheet s
ON (s.date_to >= l.date
AND s.date_from <= l.date
AND s.user_id = l.user_id))
on (l.id = hrt.line_id)
group by l.date::date, s.id
) union (
select
-min(a.id) as id,
a.name::date as name,
a.sheet_id as sheet_id,
s.id as sheet_id,
0.0 as total_timesheet,
SUM(((EXTRACT(hour FROM a.name) * 60) + EXTRACT(minute FROM a.name)) * (CASE WHEN a.action = 'sign_in' THEN -1 ELSE 1 END)) as total_attendance
from
hr_attendance a
LEFT JOIN (hr_timesheet_sheet_sheet s
LEFT JOIN hr_employee e
ON (s.user_id = e.user_id))
ON (a.employee_id = e.id
AND s.date_to >= a.name
AND s.date_from <= a.name)
WHERE action in ('sign_in', 'sign_out')
group by a.name::date, a.sheet_id
group by a.name::date, s.id
)) AS foo
GROUP BY name, sheet_id
)) AS bar""")
@ -508,13 +519,18 @@ class hr_timesheet_sheet_sheet_account(osv.osv):
select
min(hrt.id) as id,
l.account_id as name,
hrt.sheet_id as sheet_id,
s.id as sheet_id,
sum(l.unit_amount) as total,
l.to_invoice as invoice_rate
from
hr_analytic_timesheet hrt
left join account_analytic_line l on (l.id = hrt.line_id)
group by l.account_id, hrt.sheet_id, l.to_invoice
left join (account_analytic_line l
LEFT JOIN hr_timesheet_sheet_sheet s
ON (s.date_to >= l.date
AND s.date_from <= l.date
AND s.user_id = l.user_id))
on (l.id = hrt.line_id)
group by l.account_id, s.id, l.to_invoice
)""")
hr_timesheet_sheet_sheet_account()

View File

@ -62,7 +62,7 @@
<tree string="Attendances">
<field name="name"/>
<field name="action"/>
<field name="employee_id" invisible="True"/>
<field name="employee_id" invisible="1"/>
</tree>
</field>
<group col="1" colspan="1">
@ -75,18 +75,18 @@
<field name="total_attendance_day" widget="float_time"/>
<field name="timesheet_ids" colspan="4" nolabel="1" domain="[('name','=',date_current)]" context="date=date_current,user_id=user_id">
<tree string="Timesheet" editable="top">
<field name="date" readonly="True"/>
<field name="date" readonly="1"/>
<field name="account_id" on_change="on_change_account_id(account_id)" domain="[('type','=','normal'), ('state', '&lt;&gt;', 'close')]"/>
<field name="name" />
<field name="unit_amount" on_change="on_change_unit_amount(product_id, unit_amount, product_uom_id)" widget="float_time"/>
<field name="to_invoice"/>
<field name="journal_id" invisible="True"/>
<field name="product_id" invisible="True"/>
<field name="product_uom_id" invisible="True" on_change="on_change_unit_amount(product_id, unit_amount, product_uom_id)" />
<field name="amount" invisible="True"/>
<field name="general_account_id" invisible="True"/>
<field name="journal_id" invisible="True"/>
<field name="user_id" required="1" invisible="True"/>
<field name="journal_id" invisible="1"/>
<field name="product_id" invisible="1"/>
<field name="product_uom_id" invisible="1" on_change="on_change_unit_amount(product_id, unit_amount, product_uom_id)" />
<field name="amount" invisible="1"/>
<field name="general_account_id" invisible="1"/>
<field name="journal_id" invisible="1"/>
<field name="user_id" required="1" invisible="1"/>
</tree>
</field>
<field name="total_difference_day" widget="float_time"/>