diff --git a/addons/hr_timesheet/hr_timesheet_report.xml b/addons/hr_timesheet/hr_timesheet_report.xml index eae167002a4..06dcd5d6d55 100644 --- a/addons/hr_timesheet/hr_timesheet_report.xml +++ b/addons/hr_timesheet/hr_timesheet_report.xml @@ -4,15 +4,15 @@ - + - + - + - + diff --git a/addons/hr_timesheet_invoice/hr_timesheet_invoice_report.xml b/addons/hr_timesheet_invoice/hr_timesheet_invoice_report.xml index 794c38abc06..5063362bb1b 100644 --- a/addons/hr_timesheet_invoice/hr_timesheet_invoice_report.xml +++ b/addons/hr_timesheet_invoice/hr_timesheet_invoice_report.xml @@ -20,7 +20,7 @@ menu="False" model="account.analytic.line" name="account.analytic.profit" - string="Timesheet profit" + string="Timesheet Profit" groups="account.group_account_manager"/> diff --git a/addons/hr_timesheet_invoice/wizard/account_analytic_profit.py b/addons/hr_timesheet_invoice/wizard/account_analytic_profit.py index ecf318d234f..9d1ac817baf 100644 --- a/addons/hr_timesheet_invoice/wizard/account_analytic_profit.py +++ b/addons/hr_timesheet_invoice/wizard/account_analytic_profit.py @@ -22,6 +22,7 @@ import wizard import datetime +import pooler form='''
@@ -34,8 +35,26 @@ form=''' class wizard_report(wizard.interface): def _date_from(*a): return datetime.datetime.today().strftime('%Y-%m-1') + def _date_to(*a): return datetime.datetime.today().strftime('%Y-%m-%d') + + def _check(self, cr, uid, data, context): + pool = pooler.get_pool(cr.dbname) + line_obj = pool.get('account.analytic.line') + product_obj = pool.get('product.product') + price_obj = pool.get('product.pricelist') + ids = line_obj.search(cr, uid, [ + ('date', '>=', data['form']['date_from']), + ('date', '<=', data['form']['date_to']), + ('journal_id', 'in', data['form']['journal_ids'][0][2]), + ('user_id', 'in', data['form']['employee_ids'][0][2]), + ]) + if not ids: + raise wizard.except_wizard(_('Data Insufficient!'), _('No Records Found for Report!')) + + return data['form'] + fields={ 'date_from':{ @@ -70,7 +89,7 @@ class wizard_report(wizard.interface): 'result':{'type':'form', 'arch':form, 'fields':fields, 'state':[('end', 'Cancel'), ('report', 'Print')]} }, 'report':{ - 'actions':[], + 'actions':[_check], 'result':{'type':'print', 'report':'account.analytic.profit', 'state':'end'} } }