diff --git a/addons/account/account_wizard.xml b/addons/account/account_wizard.xml
index 07a6ac6eecc..4e44a44e6b8 100644
--- a/addons/account/account_wizard.xml
+++ b/addons/account/account_wizard.xml
@@ -109,10 +109,10 @@
-
+
-
+
diff --git a/addons/account/wizard/wizard_central_journal.py b/addons/account/wizard/wizard_central_journal.py
index de57c821d31..1b8c4ba525a 100644
--- a/addons/account/wizard/wizard_central_journal.py
+++ b/addons/account/wizard/wizard_central_journal.py
@@ -35,6 +35,26 @@ fields = {
}
+def _check_data(self, cr, uid, data, *args):
+ period_id = data['form']['period_id'][0][2]
+ journal_id=data['form']['journal_id'][0][2]
+
+ if type(period_id)==type([]):
+
+ ids_final = []
+
+ for journal in journal_id:
+ for period in period_id:
+ ids_journal_period = pooler.get_pool(cr.dbname).get('account.journal.period').search(cr,uid, [('journal_id','=',journal),('period_id','=',period)])
+
+ if ids_journal_period:
+ ids_final.append(ids_journal_period)
+
+ if not ids_final:
+ raise wizard.except_wizard(_('No Data Available'), _('No records found for your selection!'))
+ return data['form']
+
+
class wizard_print_journal(wizard.interface):
states = {
'init': {
@@ -42,7 +62,7 @@ class wizard_print_journal(wizard.interface):
'result': {'type': 'form', 'arch': form, 'fields': fields, 'state': (('end', 'Cancel'), ('print', 'Print'))},
},
'print': {
- 'actions': [],
+ 'actions': [_check_data],
'result': {'type':'print', 'report':'account.central.journal.wiz', 'state':'end'},
},
}
diff --git a/addons/account/wizard/wizard_general_journal.py b/addons/account/wizard/wizard_general_journal.py
index 9722fb84918..fe9c1d1141f 100644
--- a/addons/account/wizard/wizard_general_journal.py
+++ b/addons/account/wizard/wizard_general_journal.py
@@ -34,6 +34,24 @@ fields = {
'period_id': {'string': 'Period', 'type': 'many2many', 'relation': 'account.period', 'required': True},
}
+def _check_data(self, cr, uid, data, *args):
+ period_id = data['form']['period_id'][0][2]
+ journal_id=data['form']['journal_id'][0][2]
+
+ if type(period_id)==type([]):
+
+ ids_final = []
+
+ for journal in journal_id:
+ for period in period_id:
+ ids_journal_period = pooler.get_pool(cr.dbname).get('account.journal.period').search(cr,uid, [('journal_id','=',journal),('period_id','=',period)])
+
+ if ids_journal_period:
+ ids_final.append(ids_journal_period)
+
+ if not ids_final:
+ raise wizard.except_wizard(_('No Data Available'), _('No records found for your selection!'))
+ return data['form']
class wizard_print_journal(wizard.interface):
states = {
@@ -42,7 +60,7 @@ class wizard_print_journal(wizard.interface):
'result': {'type': 'form', 'arch': form, 'fields': fields, 'state': (('end', 'Cancel'), ('print', 'Print'))},
},
'print': {
- 'actions': [],
+ 'actions': [_check_data],
'result': {'type':'print', 'report':'account.general.journal.wiz', 'state':'end'},
},
}
diff --git a/addons/account/wizard/wizard_print_journal.py b/addons/account/wizard/wizard_print_journal.py
index ab48c879d96..6b2ea42d66c 100644
--- a/addons/account/wizard/wizard_print_journal.py
+++ b/addons/account/wizard/wizard_print_journal.py
@@ -43,6 +43,25 @@ fields = {
}
+def _check_data(self, cr, uid, data, *args):
+ period_id = data['form']['period_id'][0][2]
+ journal_id=data['form']['journal_id'][0][2]
+
+ if type(period_id)==type([]):
+
+ ids_final = []
+
+ for journal in journal_id:
+ for period in period_id:
+ ids_journal_period = pooler.get_pool(cr.dbname).get('account.journal.period').search(cr,uid, [('journal_id','=',journal),('period_id','=',period)])
+
+ if ids_journal_period:
+ ids_final.append(ids_journal_period)
+
+ if not ids_final:
+ raise wizard.except_wizard(_('No Data Available'), _('No records found for your selection!'))
+ return data['form']
+
class wizard_print_journal(wizard.interface):
states = {
'init': {
@@ -50,7 +69,7 @@ class wizard_print_journal(wizard.interface):
'result': {'type': 'form', 'arch': form, 'fields': fields, 'state': (('end', 'Cancel'), ('print', 'Print'))},
},
'print': {
- 'actions': [],
+ 'actions': [_check_data],
'result': {'type':'print', 'report':'account.journal.period.print.wiz', 'state':'end'},
},
}
diff --git a/addons/crm/crm.py b/addons/crm/crm.py
index 97e8bb187dd..c76e733eb00 100644
--- a/addons/crm/crm.py
+++ b/addons/crm/crm.py
@@ -327,7 +327,7 @@ class crm_case(osv.osv):
_columns = {
'id': fields.integer('ID', readonly=True),
- 'name': fields.char('Description',size=64, required=True),
+ 'name': fields.char('Description',size=64),
'priority': fields.selection(AVAILABLE_PRIORITIES, 'Priority'),
'active': fields.boolean('Active'),
'description': fields.text('Your action'),
diff --git a/addons/report_account/report_receivable.py b/addons/report_account/report_receivable.py
index 5d7a12df86b..59c7b2ec334 100644
--- a/addons/report_account/report_receivable.py
+++ b/addons/report_account/report_receivable.py
@@ -20,8 +20,14 @@
#
##############################################################################
+import time
+import datetime
+import mx.DateTime
+
+import pooler
from osv import fields,osv
+
def _code_get(self, cr, uid, context={}):
acc_type_obj = self.pool.get('account.account.type')
ids = acc_type_obj.search(cr, uid, [])
@@ -41,6 +47,7 @@ class report_account_receivable(osv.osv):
'credit':fields.float('Credit', readonly=True),
}
_order = 'name desc'
+
def init(self, cr):
cr.execute("""
create or replace view report_account_receivable as (
@@ -63,7 +70,85 @@ class report_account_receivable(osv.osv):
report_account_receivable()
#a.type in ('receivable','payable')
-
+class temp_range(osv.osv):
+ _name = 'temp.range'
+ _description = 'A Temporary table used for Dashboard view'
+
+ _columns = {
+ 'name' : fields.char('Range',size=64)
+ }
+
+temp_range()
+
+class report_aged_receivable(osv.osv):
+ _name = "report.aged.receivable"
+ _description = "Aged Receivable Till Today"
+ _auto = False
+
+ def __init__(self, pool, cr):
+ super(report_aged_receivable, 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_aged_receivable, self).fields_view_get(cr, user, view_id, view_type, context, toolbar)
+ return res
+
+ def _calc_bal(self, cr, uid, ids, name, args, context):
+ res = {}
+ for period in self.read(cr,uid,ids,['name']):
+ date1,date2 = period['name'].split(' to ')
+ se = "SELECT SUM(credit-debit) FROM account_move_line AS line, account_account as ac \
+ WHERE (line.account_id=ac.id) AND ac.type='receivable' \
+ AND (COALESCE(line.date,date) BETWEEN '%s' AND '%s') \
+ AND (reconcile_id IS NULL) AND ac.active"%(str(date2),str(date1))
+ cr.execute(se)
+ amount = cr.fetchone()
+ amount = amount[0] or 0.00
+ res[period['id']] = amount
+
+ return res
+
+ _columns = {
+ 'name': fields.char('Month Range', size=7, readonly=True),
+ 'balance': fields.function(_calc_bal, method=True, string='Balance', readonly=True),
+ }
+
+ def init(self, cr, uid=1):
+ """ This view will be used in dashboard
+ """
+# ranges = _get_ranges(cr) # Gets the ranges for the x axis of the graph (name column values)
+ pool_obj_fy = pooler.get_pool(cr.dbname).get('account.fiscalyear')
+ today = mx.DateTime.strptime(time.strftime('%Y-%m-%d'), '%Y-%m-%d') - mx.DateTime.RelativeDateTime(days=1)
+ today = today.strftime('%Y-%m-%d')
+ fy_id = pool_obj_fy.find(cr,uid)
+ LIST_RANGES = []
+ if fy_id:
+ fy_start_date = pool_obj_fy.read(cr, uid, fy_id, ['date_start'])['date_start']
+ fy_start_date = mx.DateTime.strptime(fy_start_date, '%Y-%m-%d')
+ last_month = mx.DateTime.strptime(today, '%Y-%m-%d') - mx.DateTime.RelativeDateTime(months=1)
+
+ while (last_month > fy_start_date):
+ LIST_RANGES.append(today + " to " + last_month.strftime('%Y-%m-%d'))
+ today = last_month.strftime('%Y-%m-%d')
+ last_month = mx.DateTime.strptime(today, '%Y-%m-%d') - mx.DateTime.RelativeDateTime(months=1)
+
+ LIST_RANGES.append(today +" to " + fy_start_date.strftime('%Y-%m-%d'))
+ cr.execute('delete from temp_range')
+ for range in LIST_RANGES:
+ pooler.get_pool(cr.dbname).get('temp.range').create(cr, uid, {'name':range})
+
+ cr.execute("""
+ create or replace view report_aged_receivable as (
+ select id,name from temp_range
+ )""")
+
+report_aged_receivable()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/report_account/report_receivable_view.xml b/addons/report_account/report_receivable_view.xml
index dd6c93f3492..74e1155fb1d 100644
--- a/addons/report_account/report_receivable_view.xml
+++ b/addons/report_account/report_receivable_view.xml
@@ -49,5 +49,37 @@
+
+
+
+ report.aged.receivable.graph
+ report.aged.receivable
+ graph
+
+
+
+
+
+
+
+
+
+ report.aged.receivable.tree
+ report.aged.receivable
+ tree
+
+
+
+
+
+
+
+
+
+ Aged Receivable
+ report.aged.receivable
+ form
+ graph,tree
+
diff --git a/addons/report_timesheet/report_timesheet.py b/addons/report_timesheet/report_timesheet.py
index b2ee26babbe..0c901d43f0f 100644
--- a/addons/report_timesheet/report_timesheet.py
+++ b/addons/report_timesheet/report_timesheet.py
@@ -94,6 +94,7 @@ class report_timesheet_account_date(osv.osv):
'quantity': fields.float('Quantity', readonly=True),
}
_order = 'name desc,account_id desc,user_id desc'
+
def init(self, cr):
cr.execute("""
create or replace view report_timesheet_account_date as (
@@ -152,5 +153,46 @@ class report_timesheet_invoice(osv.osv):
""")
report_timesheet_invoice()
+class report_random_timsheet(osv.osv):
+ _name = "report.random.timesheet"
+ _description = "Random Timesheet Report"
+ _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),
+ '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)
+ }
+ _order = "date desc"
+
+ def init(self, cr):
+ 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))
+
+ ORDER BY line.name LIMIT 10
+ )
+ """)
+
+report_random_timsheet()
+
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/report_timesheet/report_timesheet_view.xml b/addons/report_timesheet/report_timesheet_view.xml
index 659be98b8f2..4c611562808 100644
--- a/addons/report_timesheet/report_timesheet_view.xml
+++ b/addons/report_timesheet/report_timesheet_view.xml
@@ -278,5 +278,33 @@
+
+
+
+
+ report.random.timesheet.tree
+ report.random.timesheet
+ tree
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ir.actions.act_window
+ Random Timesheet
+ report.random.timesheet
+ form
+ tree,form
+
+