Board_service : Corrected Random timesheet for My Department

bzr revid: jvo@tinyerp.com-20090310100432-hcdrp9ek95t407g6
This commit is contained in:
Jay (Open ERP) 2009-03-10 15:34:32 +05:30
parent 86c4375065
commit 3fe23e6532
2 changed files with 34 additions and 30 deletions

View File

@ -159,37 +159,44 @@ class report_random_timsheet(osv.osv):
_auto = False
_columns = {
'name': fields.char('Description', size=64, readonly=True),
'date': fields.date('Date', readonly=True),
'analytic_account_id' : fields.many2one('account.analytic.account','Analytic Account', readonly=True),
'name': fields.char('Description', size=64, readonly=True),
'quantity' : fields.float('Quantity', readonly=True),
'product_id' : fields.many2one('product.product','Product', readonly=True),
'amount' : fields.float('Amount', readonly=True),
'uom_id' : fields.many2one('product.uom','UOM', readonly=True)
}
'date': fields.date('Date', readonly=True),
'user_id' : fields.many2one('res.users', 'User', readonly=True)
}
_order = "date desc"
def init(self, cr):
def __init__(self, pool, cr):
super(report_random_timsheet, self).__init__(pool, cr)
self.called = False
def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False):
""" To call the init() method timely
"""
if not self.called:
self.init(cr, user)
self.called = True # To make sure that init doesn't get called multiple times
res = super(report_random_timsheet, self).fields_view_get(cr, user, view_id, view_type, context, toolbar)
return res
def init(self, cr, uid=1):
cr.execute("""create or replace view report_random_timesheet as (
select line.id as id, line.name as name, line.date as date,
act.id as analytic_account_id, line.unit_amount as quantity,
prod.id as product_id, line.amount as amount, uom_uom.id as uom_id
from account_analytic_line line
left join account_analytic_account act on (line.account_id = act.id)
left join hr_employee emp on (line.user_id = emp.id)
left join hr_department dept on (dept.manager_id = emp.parent_id)
left join hr_department_user_rel dept_user on (line.user_id = dept_user.user_id)
left join product_template prod on (line.product_id = prod.id)
left join product_uom uom_uom on (line.product_uom_id = uom_uom.id)
where (line.date < CURRENT_DATE AND line.date >= (CURRENT_DATE-3))
select
line.id as id, line.account_id as analytic_account_id, line.name as name,
line.unit_amount as quantity, line.date as date, line.user_id as user_id
from
account_analytic_line line, hr_department dept,hr_department_user_rel dept_user
where
(dept.id = dept_user.department_id AND dept_user.user_id=line.user_id AND line.user_id is not null)
AND (dept.manager_id = """ + str(uid) + """ )
AND (line.date < CURRENT_DATE AND line.date >= (CURRENT_DATE-3))
ORDER BY line.name LIMIT 10
)
""")
""" )
report_random_timsheet()

View File

@ -287,13 +287,10 @@
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Random Timesheets">
<field name="analytic_account_id" />
<field name="name" />
<field name="quantity" />
<field name="product_id" />
<field name="amount" />
<field name="uom_id" />
<field name="date" />
<field name="analytic_account_id" select="1"/>
<field name="name" select="1"/>
<field name="quantity" select="2" />
<field name="date" select="1"/>
</tree>
</field>
</record>