diff --git a/addons/account/account.py b/addons/account/account.py
index 23635b298ac..449a58f136d 100644
--- a/addons/account/account.py
+++ b/addons/account/account.py
@@ -470,7 +470,7 @@ class account_journal(osv.osv):
'user_id': lambda self,cr,uid,context: uid,
}
def create(self, cr, uid, vals, context={}):
- journal_id = super(osv.osv, self).create(cr, uid, vals, context)
+ journal_id = super(account_journal, self).create(cr, uid, vals, context)
# journal_name = self.browse(cr, uid, [journal_id])[0].code
# periods = self.pool.get('account.period')
# ids = periods.search(cr, uid, [('date_stop','>=',time.strftime('%Y-%m-%d'))])
@@ -481,6 +481,7 @@ class account_journal(osv.osv):
# 'period_id': period.id
# })
return journal_id
+
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80):
if not args:
args=[]
diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py
index 084185a6462..354f721db5a 100644
--- a/addons/account/account_move_line.py
+++ b/addons/account/account_move_line.py
@@ -40,16 +40,22 @@ class account_move_line(osv.osv):
else:
fiscalyear_clause = '%s' % context['fiscalyear']
state=context.get('state',False)
- where_move_state=''
+ where_move_state = ''
+ where_move_lines_by_date = ''
+
+ if context.get('date_from', False) and context.get('date_to', False):
+ where_move_lines_by_date = " AND " +obj+".move_id in ( select id from account_move where date >= '" +context['date_from']+"' AND date <= '"+context['date_to']+"')"
+
if state:
if state.lower() not in ['all']:
where_move_state= " AND "+obj+".move_id in (select id from account_move where account_move.state = '"+state+"')"
-
+
+
if context.get('periods', False):
ids = ','.join([str(x) for x in context['periods']])
- return obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) AND id in (%s)) %s" % (fiscalyear_clause, ids,where_move_state)
+ return obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) AND id in (%s)) %s %s" % (fiscalyear_clause, ids,where_move_state,where_move_lines_by_date)
else:
- return obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) %s)" % (fiscalyear_clause,where_move_state)
+ return obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) %s %s)" % (fiscalyear_clause,where_move_state,where_move_lines_by_date)
def default_get(self, cr, uid, fields, context={}):
data = self._default_get(cr, uid, fields, context)
diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml
index cdc0786c6eb..1d0ab433abe 100644
--- a/addons/account/account_view.xml
+++ b/addons/account/account_view.xml
@@ -324,7 +324,7 @@
+ string="Import Invoice" type="action" attrs="{'invisible':[('state','=','confirm')]}"/>
diff --git a/addons/account/invoice.py b/addons/account/invoice.py
index d64ba93c089..9ce5f2ac40b 100644
--- a/addons/account/invoice.py
+++ b/addons/account/invoice.py
@@ -511,7 +511,6 @@ class account_invoice(osv.osv):
company_currency = inv.company_id.currency_id.id
# create the analytical lines
line_ids = self.read(cr, uid, [inv.id], ['invoice_line'])[0]['invoice_line']
- ils = self.pool.get('account.invoice.line').read(cr, uid, line_ids)
# one move line per invoice line
iml = self._get_analytic_lines(cr, uid, inv.id)
# check if taxes are all computed
diff --git a/addons/account/project/report/analytic_journal.rml b/addons/account/project/report/analytic_journal.rml
index 96383420a1f..d7570aa8943 100644
--- a/addons/account/project/report/analytic_journal.rml
+++ b/addons/account/project/report/analytic_journal.rml
@@ -98,8 +98,8 @@
[[ move.name ]]
[[ move.account_id.code ]] - [[ move.account_id.name ]]
-
[[ formatLang(move.debit-move.credit) ]]
+
diff --git a/addons/account/report/account_balance.py b/addons/account/report/account_balance.py
index 64db67efea5..e74ad786365 100644
--- a/addons/account/report/account_balance.py
+++ b/addons/account/report/account_balance.py
@@ -127,6 +127,8 @@ class account_balance(report_sxw.rml_parse):
ctx['fiscalyear'] = form['fiscalyear']
ctx['periods'] = form['periods'][0][2]
elif form['state']== 'bydate':
+ ctx['date_from'] = form['date_from']
+ ctx['date_to'] = form['date_to']
self.transform_date_into_date_array(form)
elif form['state'] == 'all' :
self.transform_both_into_date_array(form)
diff --git a/addons/account/wizard/wizard_fiscalyear_close.py b/addons/account/wizard/wizard_fiscalyear_close.py
index 7cd560e7b44..68e69941b5c 100644
--- a/addons/account/wizard/wizard_fiscalyear_close.py
+++ b/addons/account/wizard/wizard_fiscalyear_close.py
@@ -178,7 +178,8 @@ def _data_save(self, cr, uid, data, context):
'WHERE account_id = %s ' \
'AND ' + query_line + ' ' \
'ORDER BY id ' \
- 'LIMIT %s OFFSET %s', (account.id,fy_id, limit, offset))
+ 'LIMIT %s OFFSET %s', (account.id, limit, offset))
+
result = cr.dictfetchall()
if not result:
break
diff --git a/addons/account/wizard/wizard_refund.py b/addons/account/wizard/wizard_refund.py
index 90a9ce76c11..c4f340d595e 100644
--- a/addons/account/wizard/wizard_refund.py
+++ b/addons/account/wizard/wizard_refund.py
@@ -68,35 +68,31 @@ class wiz_refund(wizard.interface):
if form['period'] :
period = form['period']
else:
- period = inv.period_id.id
+ period = inv.period_id and inv.period_id.id or False
if form['date'] :
date = form['date']
if not form['period'] :
- try :
- #we try in multy company mode
+ cr.execute("select name from ir_model_fields where model='account.period' and name='company_id'")
+ result_query = cr.fetchone()
+ if result_query:
+ #in multi company mode
cr.execute("""SELECT id
from account_period where date('%s')
between date_start AND date_stop and company_id = %s limit 1 """%(
form['date'],
pool.get('res.users').browse(cr,uid,uid).company_id.id
- )
-
- )
- except :
- #we try in mono company mode
+ ))
+ else:
+ #in mono company mode
cr.execute("""SELECT id
from account_period where date('%s')
between date_start AND date_stop limit 1 """%(
form['date'],
- )
-
- )
+ ))
res = cr.fetchone()
if res:
period = res[0]
-
-
else:
date = inv.date_invoice
@@ -104,6 +100,10 @@ class wiz_refund(wizard.interface):
description = form['description']
else:
description = inv.name
+
+ if not period:
+ raise wizard.except_wizard(_('Data Insufficient !'), _('No Period found on Invoice!'))
+
refund_id = pool.get('account.invoice').refund(cr, uid, [inv.id],date, period, description)
refund = pool.get('account.invoice').browse(cr, uid, refund_id[0])
# we compute due date
diff --git a/addons/crm/crm.py b/addons/crm/crm.py
index 1801ab65bbc..0d82951eb7d 100644
--- a/addons/crm/crm.py
+++ b/addons/crm/crm.py
@@ -58,6 +58,7 @@ class crm_case_section(osv.osv):
'name': fields.char('Case Section',size=64, required=True, translate=True),
'code': fields.char('Section Code',size=8),
'active': fields.boolean('Active'),
+ 'allow_unlink': fields.boolean('Allow Delete', help="Allows to delete non draft cases"),
'sequence': fields.integer('Sequence'),
'user_id': fields.many2one('res.users', 'Responsible User'),
'reply_to': fields.char('Reply-To', size=64, help="The email address put in the 'Reply-To' of all emails sent by Open ERP about cases in this section"),
@@ -66,6 +67,7 @@ class crm_case_section(osv.osv):
}
_defaults = {
'active': lambda *a: 1,
+ 'allow_unlink': lambda *a: 1,
}
_sql_constraints = [
('code_uniq', 'unique (code)', 'The code of the section must be unique !')
@@ -388,12 +390,13 @@ class crm_case(osv.osv):
'email_from': _get_default_email,
'state': lambda *a: 'open',
'priority': lambda *a: AVAILABLE_PRIORITIES[2][0],
+ 'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
}
_order = 'priority, date_deadline desc, date desc,id desc'
def unlink(self, cr, uid, ids, context={}):
for case in self.browse(cr, uid, ids, context):
- if case.state <> 'draft':
+ if (not case.section_id.allow_unlink) and (case.state <> 'draft'):
raise osv.except_osv(_('Warning !'),
_('You can not delete this case. You should better cancel it.'))
return super(crm_case, self).unlink(cr, uid, ids, context)
diff --git a/addons/crm/crm_view.xml b/addons/crm/crm_view.xml
index 103682624b9..327f861c314 100644
--- a/addons/crm/crm_view.xml
+++ b/addons/crm/crm_view.xml
@@ -35,6 +35,7 @@
+
diff --git a/addons/crm_configuration/crm_lead_menu.xml b/addons/crm_configuration/crm_lead_menu.xml
index 92960db3552..b84646bad20 100644
--- a/addons/crm_configuration/crm_lead_menu.xml
+++ b/addons/crm_configuration/crm_lead_menu.xml
@@ -260,7 +260,7 @@
graph,tree
-
+
report.crm.case.section.stage
@@ -284,7 +284,7 @@
tree
-
+
diff --git a/addons/crm_configuration/crm_opportunity_menu.xml b/addons/crm_configuration/crm_opportunity_menu.xml
index 8b3b6557a15..f312da8e072 100644
--- a/addons/crm_configuration/crm_opportunity_menu.xml
+++ b/addons/crm_configuration/crm_opportunity_menu.xml
@@ -255,7 +255,7 @@
graph,tree
-
+
report.crm.case.section.stage
@@ -271,7 +271,7 @@
tree
-
+
report.crm.case.section.categ.categ2
@@ -279,7 +279,7 @@
tree
-
+
diff --git a/addons/crm_configuration/crm_report_view.xml b/addons/crm_configuration/crm_report_view.xml
index 567bfcbfd4d..bd6c39d552e 100644
--- a/addons/crm_configuration/crm_report_view.xml
+++ b/addons/crm_configuration/crm_report_view.xml
@@ -6,11 +6,11 @@
#
- CRM Report - Sections and Category2(Tree)
+ CRM Report - Sections and Type(Tree)
report.crm.case.section.categ2
tree
-
+
@@ -24,7 +24,7 @@
- CRM Report - Sections and Category2(Form)
+ CRM Report - Sections and Type(Form)
report.crm.case.section.categ2
form
@@ -42,11 +42,11 @@
- CRM Report - Sections and Category2(Graph)
+ CRM Report - Sections and Type(Graph)
report.crm.case.section.categ2
graph
-
+
@@ -60,14 +60,14 @@
graph,tree
[('name','=',time.strftime('%Y-%m-01'))]
-
+
report.crm.case.section.categ2
form
graph,tree
-
+
#
# Cases by section and stage
@@ -192,11 +192,11 @@
#
- CRM Report - Section, Category and Category2(Tree)
+ CRM Report - Section, Category and Type(Tree)
report.crm.case.section.categ.categ2
tree
-
+
@@ -210,11 +210,11 @@
- CRM Report - Section, Category and Category2(Form)
+ CRM Report - Section, Category and Type(Form)
report.crm.case.section.categ.categ2
form
-
-
+
report.crm.case.section.categ.categ2
form
tree
-
+
diff --git a/addons/hr_holidays/hr.py b/addons/hr_holidays/hr.py
index 7e2b7592d18..08eb7f476e0 100644
--- a/addons/hr_holidays/hr.py
+++ b/addons/hr_holidays/hr.py
@@ -62,13 +62,55 @@ class hr_holidays_status(osv.osv):
}
hr_holidays_status()
+class hr_holidays_per_user(osv.osv):
+ _name = "hr.holidays.per.user"
+ _description = "Holidays Per User"
+ _rec_name = "user_id"
+
+ def _get_remaining_leaves(self, cr, uid, ids, field_name, arg=None, context={}):
+ obj_holiday = self.pool.get('hr.holidays')
+ result = {}
+ for holiday_user in self.browse(cr, uid, ids):
+ days = 0.0
+ ids_request = obj_holiday.search(cr, uid, [('employee_id', '=', holiday_user.employee_id.id),('state', '=', 'validate'),('holiday_status', '=', holiday_user.holiday_status.id)])
+ if ids_request:
+ holidays = obj_holiday.browse(cr, uid, ids_request)
+ for holiday in holidays:
+ days += holiday.number_of_days
+ days = holiday_user.max_leaves - days
+ result[holiday_user.id] = days
+ return result
+
+ _columns = {
+ 'employee_id': fields.many2one('hr.employee', 'Employee',required=True),
+ 'user_id' : fields.many2one('res.users','User'),
+ 'holiday_status' : fields.many2one("hr.holidays.status", "Holiday's Status", required=True),
+ 'max_leaves' : fields.float('Maximum Leaves Allowed',required=True),
+ 'leaves_taken' : fields.float('Leaves Already Taken',readonly=True),
+ 'active' : fields.boolean('Active'),
+ 'notes' : fields.text('Notes'),
+ 'remaining_leaves': fields.function(_get_remaining_leaves, method=True, string='Remaining Leaves', type='float'),
+ 'holiday_ids': fields.one2many('hr.holidays', 'holiday_user_id', 'Holidays')
+ }
+ _defaults = {
+ 'active' : lambda *a: True,
+ }
+
+ def create(self, cr, uid, vals, *args, **kwargs):
+ if vals['employee_id']:
+ obj_emp=self.pool.get('hr.employee').browse(cr,uid,vals['employee_id'])
+ vals.update({'user_id': obj_emp.user_id.id})
+ return super(osv.osv,self).create(cr, uid, vals, *args, **kwargs)
+
+hr_holidays_per_user()
+
class hr_holidays(osv.osv):
_name = "hr.holidays"
_description = "Holidays"
_columns = {
'name' : fields.char('Description', required=True, readonly=True, size=64, states={'draft':[('readonly',False)]}),
- 'state': fields.selection([('draft', 'draft'), ('confirm', 'Waiting Validation'), ('refuse', 'Refused'), ('validated', 'Validate'), ('cancel', 'Cancel')], 'Status', readonly=True),
+ 'state': fields.selection([('draft', 'draft'), ('confirm', 'Waiting Validation'), ('refuse', 'Refused'), ('validate', 'Validate'), ('cancel', 'Cancel')], 'Status', readonly=True),
'date_from' : fields.datetime('Vacation start day', required=True, readonly=True, states={'draft':[('readonly',False)]}),
'date_to' : fields.datetime('Vacation end day',required=True,readonly=True, states={'draft':[('readonly',False)]}),
'holiday_status' : fields.many2one("hr.holidays.status", "Holiday's Status", required=True,readonly=True, states={'draft':[('readonly',False)]}),
@@ -76,8 +118,9 @@ class hr_holidays(osv.osv):
'user_id':fields.many2one('res.users', 'Employee_id', states={'draft':[('readonly',False)]}, select=True, readonly=True),
'manager_id' : fields.many2one('hr.employee', 'Holiday manager', invisible=False, readonly=True),
'notes' : fields.text('Notes',readonly=True, states={'draft':[('readonly',False)]}),
- 'number_of_days': fields.float('Number of Days in this Holiday Request',required=True),
- 'case_id':fields.many2one('crm.case', 'Case'),
+ 'number_of_days': fields.float('Number of Days in this Holiday Request', required=True, readonly=True, states={'draft': [('readonly', False)]}),
+ 'case_id': fields.many2one('crm.case', 'Case'),
+ 'holiday_user_id': fields.many2one('hr.holidays.per.user', 'Holiday per user')
}
_defaults = {
@@ -87,29 +130,31 @@ class hr_holidays(osv.osv):
}
_order = 'date_from desc'
+ def _check_date(self, cr, uid, ids):
+ if ids:
+ cr.execute('select number_of_days from hr_holidays where id in ('+','.join(map(str, ids))+')')
+ res = cr.fetchall()
+ if res and res[0][0] < 0:
+ return False
+ return True
+
+ _constraints = [(_check_date, 'Start date should not be larger than end date! ', ['number_of_days'])]
+
def create(self, cr, uid, vals, *args, **kwargs):
id_holiday = super(hr_holidays, self).create(cr, uid, vals, *args, **kwargs)
- self._create_log(cr, uid, [id_holiday])
+ self._create_holiday(cr, uid, [id_holiday])
return id_holiday
- def _create_log(self, cr, uid, ids):
+ def _create_holiday(self, cr, uid, ids):
holidays_user_obj = self.pool.get('hr.holidays.per.user')
- list_request = []
holidays_data = self.browse(cr, uid, ids[0])
- datas = {
- 'employee_id' : holidays_data.employee_id.id,
- 'name' : holidays_data.state,
- 'holiday_status' : holidays_data.holiday_status.id,
- 'holiday_req_id' : holidays_data.id,
- 'nb_holidays' : holidays_data.number_of_days
- }
- ids_log = self.pool.get('hr.holidays.log').create(cr, uid, datas)
+ list_holiday = []
ids_user_hdays = holidays_user_obj.search(cr, uid, [('employee_id', '=', holidays_data.employee_id.id),('holiday_status', '=', holidays_data.holiday_status.id)])
for hdays in holidays_user_obj.browse(cr, uid, ids_user_hdays):
- for req in hdays.history:
- list_request.append(req.id)
- list_request.append(ids_log)
- holidays_user_obj.write(cr, uid, ids_user_hdays, {'history' : [(6,0,list_request)]})
+ for req in hdays.holiday_ids:
+ list_holiday.append(req.id)
+ list_holiday.append(ids[0])
+ holidays_user_obj.write(cr, uid, ids_user_hdays, {'holiday_ids': [(6, 0, list_holiday)]})
return True
def onchange_date_to(self, cr, uid, ids, date_from, date_to):
@@ -133,7 +178,7 @@ class hr_holidays(osv.osv):
'state':'draft',
'manager_id': False
})
- self._create_log(cr, uid, ids)
+ self._create_holiday(cr, uid, ids)
return True
def holidays_validate(self, cr, uid, ids, *args):
@@ -145,7 +190,7 @@ class hr_holidays(osv.osv):
if ids2:
vals['manager_id'] = ids2[0]
self.write(cr, uid, ids, vals)
- self._create_log(cr, uid, ids)
+ self._create_holiday(cr, uid, ids)
return True
def holidays_confirm(self, cr, uid, ids, *args):
@@ -157,7 +202,7 @@ class hr_holidays(osv.osv):
'state':'confirm',
'user_id': user,
})
- self._create_log(cr, uid, ids)
+ self._create_holiday(cr, uid, ids)
return True
def holidays_refuse(self, cr, uid, ids, *args):
@@ -166,7 +211,7 @@ class hr_holidays(osv.osv):
'state':'refuse',
'manager_id':ids2[0]
})
- self._create_log(cr, uid, ids)
+ self._create_holiday(cr, uid, ids)
return True
def holidays_cancel(self, cr, uid, ids, *args):
@@ -185,14 +230,14 @@ class hr_holidays(osv.osv):
self.write(cr, uid, ids, {
'state':'cancel'
})
- self._create_log(cr, uid, ids)
+ self._create_holiday(cr, uid, ids)
return True
def holidays_draft(self, cr, uid, ids, *args):
self.write(cr, uid, ids, {
'state':'draft'
})
- self._create_log(cr, uid, ids)
+ self._create_holiday(cr, uid, ids)
return True
def check_holidays(self,cr,uid,ids):
@@ -238,65 +283,4 @@ class hr_holidays(osv.osv):
return True
hr_holidays()
-
-class hr_holidays_per_user(osv.osv):
- _name = "hr.holidays.per.user"
- _description = "Holidays Per User"
-
- def _get_remaining_leaves(self, cr, uid, ids, field_name, arg=None, context={}):
- obj_holiday = self.pool.get('hr.holidays')
- days = 0.0
- result = {}
- for holiday_user in self.browse(cr, uid, ids):
- ids_request = obj_holiday.search(cr, uid, [('employee_id', '=', holiday_user.employee_id.id),('state', '=', 'validate'),('holiday_status', '=', holiday_user.holiday_status.id)])
- if ids_request:
- holidays = obj_holiday.browse(cr, uid, ids_request)
- for holiday in holidays:
- days += holiday.number_of_days
- days = holiday_user.max_leaves - days
- result[holiday_user.id] = days
- return result
-
- _columns = {
- 'employee_id' : fields.many2one('hr.employee', 'Employee',required=True),
- 'user_id' : fields.many2one('res.users','User'),
- 'holiday_status' : fields.many2one("hr.holidays.status", "Holiday's Status", required=True),
- 'max_leaves' : fields.float('Maximum Leaves Allowed',required=True),
- 'leaves_taken' : fields.float('Leaves Already Taken',readonly=True),
- 'active' : fields.boolean('Active'),
- 'notes' : fields.text('Notes'),
- 'remaining_leaves': fields.function(_get_remaining_leaves, method=True, string='Remaining Leaves', type='float'),
- 'history' : fields.one2many('hr.holidays.log', 'holiday_user_id', 'History')
- }
- _defaults = {
- 'active' : lambda *a: True,
- }
-
- def create(self, cr, uid, vals, *args, **kwargs):
- if vals['employee_id']:
- obj_emp=self.pool.get('hr.employee').browse(cr,uid,vals['employee_id'])
- vals.update({'user_id': obj_emp.user_id.id})
- return super(osv.osv,self).create(cr, uid, vals, *args, **kwargs)
-
-hr_holidays_per_user()
-
-class holiday_user_log(osv.osv):
- _name = 'hr.holidays.log'
- _description = 'hr.holidays.log'
- _order = "holiday_req_id desc"
- _columns = {
- 'name' : fields.char('Action', size=64, readonly=True),
- 'holiday_req_id' : fields.char('Holiday Request ID', size=64),
- 'nb_holidays' : fields.float('Number of Holidays Requested'),
- 'employee_id' : fields.many2one('hr.employee', 'Employee', readonly=True),
- 'holiday_status' : fields.many2one("hr.holidays.status", "Holiday's Status", readonly=True),
- 'holiday_user_id' : fields.many2one('hr.holidays.per.user', 'Holidays user'),
- 'date': fields.datetime('Date'),
- }
- _defaults = {
- 'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
- }
-holiday_user_log()
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/hr_holidays/hr_view.xml b/addons/hr_holidays/hr_view.xml
index 7bb00565d26..acbdc5aad2e 100644
--- a/addons/hr_holidays/hr_view.xml
+++ b/addons/hr_holidays/hr_view.xml
@@ -51,36 +51,6 @@
-
-
- hr.holidays.log.form
- hr.holidays.log
- form
-
-
-
-
-
- >hr.holidays.log.tree
- hr.holidays.log
- tree
-
-
-
-
-
-
-
-
-
-
-
-
-
hr.holidays.status.form
@@ -129,21 +99,21 @@
form
diff --git a/addons/hr_holidays/report/holidays_summary_report.py b/addons/hr_holidays/report/holidays_summary_report.py
index 3cedf2b4faf..589f97f2631 100644
--- a/addons/hr_holidays/report/holidays_summary_report.py
+++ b/addons/hr_holidays/report/holidays_summary_report.py
@@ -32,7 +32,6 @@ def emp_create_xml(self,cr,uid,dept,holiday_type,row_id,empid,name,som,eom):
current=som+datetime.timedelta(diff)
for item in ids_date:
- # print current,"from",item['date_from'],"to",item['date_to']
if current >= strToDate(item['date_from']) and current <= strToDate(item['date_to']):
if item['state'] in holiday_type:
display[index]=item['holiday_status'][0]
@@ -150,7 +149,6 @@ class report_custom(report_rml):
width_dict[j]=x
day_diff1=day_diff1-x
-# print "now day_diff1 is..frst.",day_diff1
else:
years=year+1
year=years
@@ -175,7 +173,6 @@ class report_custom(report_rml):
width_dict[j]=x
day_diff1=day_diff1-x
-# print "now day_diff1 is..scnd.",day_diff1
date_xml.append('')
date_xml.append('3.5cm%s,0.4cm \n' % (',0.4cm' * (60)))
diff --git a/addons/hr_holidays/security/ir.model.access.csv b/addons/hr_holidays/security/ir.model.access.csv
index 5af36ab580e..b095b8bf50d 100644
--- a/addons/hr_holidays/security/ir.model.access.csv
+++ b/addons/hr_holidays/security/ir.model.access.csv
@@ -1,5 +1,4 @@
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
-"access_hr_holidays_log","hr.holidays.log","model_hr_holidays_log","hr.group_hr_user",1,1,1,1
"access_hr_holidays_per_user","hr.holidays.per.user","model_hr_holidays_per_user","hr.group_hr_user",1,1,1,1
"access_hr_holydays_status_user","hr.holidays.status user","model_hr_holidays_status","hr.group_hr_user",1,1,1,1
"access_hr_holidays_user","hr holidays user","model_hr_holidays","hr.group_hr_user",1,1,1,1
diff --git a/addons/hr_timesheet/wizard/sign_in_out.py b/addons/hr_timesheet/wizard/sign_in_out.py
index 400f9f7f242..538a55f75ac 100644
--- a/addons/hr_timesheet/wizard/sign_in_out.py
+++ b/addons/hr_timesheet/wizard/sign_in_out.py
@@ -141,7 +141,7 @@ def _state_check(self, cr, uid, data, context):
class wiz_si_so(wizard.interface):
states = {
'init' : {
- 'actions' : [],
+ 'actions' : [_get_empid],
'result' : {'type' : 'choice', 'next_state': _state_check}
},
'sign_out' : { # this means sign_in...
diff --git a/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py b/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py
index 5b19583070c..7ff1967c63a 100644
--- a/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py
+++ b/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py
@@ -51,12 +51,12 @@ class invoice_create(wizard.interface):
for account in analytic_account_obj.browse(cr, uid, account_ids, context):
partner = account.partner_id
if (not partner) or not (account.pricelist_id):
- raise wizard.except_wizard(_('Analytic account incomplete'),
- _('Please fill in the partner and pricelist field in the analytic account:\n%s') % (account.name,))
+ raise wizard.except_wizard(_('Analytic Account incomplete'),
+ _('Please fill in the Associate Partner and Sale Pricelist fields in the Analytic Account:\n%s') % (account.name,))
if not partner.address:
raise wizard.except_wizard(_('Partner incomplete'),
- _('Please fill in the address field in the partner: %s.') % (partner.name,))
+ _('Please fill in the Address field in the Partner: %s.') % (partner.name,))
date_due = False
if partner.property_payment_term:
diff --git a/addons/membership/membership.py b/addons/membership/membership.py
index 507a6722961..a0d45169278 100644
--- a/addons/membership/membership.py
+++ b/addons/membership/membership.py
@@ -362,7 +362,7 @@ class Partner(osv.osv):
selection = STATE ,store = {
'account.invoice':(_get_invoice_partner,['state'], 10),
'membership.membership_line':(_get_partner_id,['state'], 10),
- 'res.partner':(_get_partners, ['free_member','membership_state'], 10)
+ 'res.partner':(_get_partners, ['free_member', 'membership_state'], 10)
}
),
'membership_start': fields.function(
@@ -756,5 +756,4 @@ class account_invoice_line(osv.osv):
return result
account_invoice_line()
-
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/membership/wizard/invoice_membership.py b/addons/membership/wizard/invoice_membership.py
index 9767c27f9f4..30d8bc6e6bf 100644
--- a/addons/membership/wizard/invoice_membership.py
+++ b/addons/membership/wizard/invoice_membership.py
@@ -28,7 +28,6 @@ def _invoice_membership(self, cr, uid, data, context):
partner_ids = data['ids']
product_id = data['form']['product']
pool = pooler.get_pool(cr.dbname)
-
cr.execute('''
SELECT partner_id, id, type
FROM res_partner_address
@@ -43,7 +42,6 @@ def _invoice_membership(self, cr, uid, data, context):
pid = fetchal[x][0]
id = fetchal[x][1]
type = fetchal[x][2]
-
if partner_address_ids.has_key(pid) and partner_address_ids[pid]['type'] == 'invoice':
continue
partner_address_ids[pid] = {'id': id, 'type': type}
@@ -95,7 +93,6 @@ def _invoice_membership(self, cr, uid, data, context):
'res_model': 'account.invoice',
'type': 'ir.actions.act_window',
}
-
return value
wizard_arch= """
@@ -110,7 +107,6 @@ wizard_arch= """
class wizard_invoice_membership(wizard.interface):
states = {
-
'init' : {
'actions' : [],
'result' : {
diff --git a/addons/product/pricelist.py b/addons/product/pricelist.py
index eb993ecf825..a6d84a9be60 100644
--- a/addons/product/pricelist.py
+++ b/addons/product/pricelist.py
@@ -268,6 +268,8 @@ class product_pricelist_version(osv.osv):
#
def _check_date(self, cursor, user, ids):
for pricelist_version in self.browse(cursor, user, ids):
+ if not pricelist_version.active:
+ continue
if not pricelist_version.active:
continue
cursor.execute('SELECT id ' \
diff --git a/addons/project/project.py b/addons/project/project.py
index ecbb98635ba..cd980ab2738 100644
--- a/addons/project/project.py
+++ b/addons/project/project.py
@@ -24,6 +24,7 @@ from lxml import etree
from mx import DateTime
from mx.DateTime import now
import time
+from tools.translate import _
from osv import fields, osv
@@ -335,7 +336,7 @@ class task(osv.osv):
if project:
if project.warn_manager and project.manager and (project.manager.id != uid):
request.create(cr, uid, {
- 'name': "Task '%s' closed" % task.name,
+ 'name': _("Task '%s' closed") % task.name,
'state': 'waiting',
'act_from': uid,
'act_to': project.manager.id,
@@ -345,7 +346,12 @@ class task(osv.osv):
})
self.write(cr, uid, [task.id], {'state': 'done', 'date_close':time.strftime('%Y-%m-%d %H:%M:%S'), 'remaining_hours': 0.0})
if task.parent_id and task.parent_id.state in ('pending','draft'):
- self.do_reopen(cr, uid, [task.parent_id.id])
+ reopen = True
+ for child in task.parent_id.child_ids:
+ if child.id != task.id and child.state not in ('done','cancelled'):
+ reopen = False
+ if reopen:
+ self.do_reopen(cr, uid, [task.parent_id.id])
return True
def do_reopen(self, cr, uid, ids, *args):
@@ -355,7 +361,7 @@ class task(osv.osv):
project = task.project_id
if project and project.warn_manager and project.manager.id and (project.manager.id != uid):
request.create(cr, uid, {
- 'name': "Task '%s' set in progress" % task.name,
+ 'name': _("Task '%s' set in progress") % task.name,
'state': 'waiting',
'act_from': uid,
'act_to': project.manager.id,
@@ -374,7 +380,7 @@ class task(osv.osv):
project = task.project_id
if project.warn_manager and project.manager and (project.manager.id != uid):
request.create(cr, uid, {
- 'name': "Task '%s' cancelled" % task.name,
+ 'name': _("Task '%s' cancelled") % task.name,
'state': 'waiting',
'act_from': uid,
'act_to': project.manager.id,
diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml
index 98fb9b1b993..61dbe6d9f4d 100644
--- a/addons/project/project_view.xml
+++ b/addons/project/project_view.xml
@@ -33,7 +33,7 @@
-
+
@@ -310,10 +310,11 @@
-
-
-
+
+
+
+
diff --git a/addons/project/wizard/task_delegate.py b/addons/project/wizard/task_delegate.py
index aafed9c3a95..d2919dcb54e 100644
--- a/addons/project/wizard/task_delegate.py
+++ b/addons/project/wizard/task_delegate.py
@@ -23,6 +23,7 @@
import wizard
from tools import email_send as email
import pooler
+from tools.translate import _
ask_form = """
+
+
+
+
+ report.invoice.created.tree
+ report.invoice.created
+ tree
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Invoices Created Within Past 15 Days
+ report.invoice.created
+ form
+ tree,form
+
+
diff --git a/addons/report_crm/report_crm.py b/addons/report_crm/report_crm.py
index 467b888bec2..cc5cf55a4de 100644
--- a/addons/report_crm/report_crm.py
+++ b/addons/report_crm/report_crm.py
@@ -106,5 +106,109 @@ class report_crm_case_categ(osv.osv):
)""")
report_crm_case_categ()
+
+class report_crm_case_section(osv.osv):
+ _name = "report.crm.case.section"
+ _description = "Cases by Section"
+ _auto = False
+
+ def _get_data(self, cr, uid, ids, field_name, arg, context={}):
+ res = {}
+ state_perc = 0.0
+ avg_ans = 0.0
+
+ for case in self.browse(cr, uid, ids, context):
+ if field_name != 'avg_answers':
+ state = field_name[5:]
+ cr.execute("select count(*) from crm_case where section_id =%s and state='%s'"%(case.section_id.id,state))
+ state_cases = cr.fetchone()[0]
+ perc_state = (state_cases / float(case.nbr_cases) ) * 100
+
+ res[case.id] = perc_state
+ else:
+ cr.execute('select count(*) from crm_case_log l where l.section_id=%s'%(case.section_id.id))
+ logs = cr.fetchone()[0]
+
+ avg_ans = logs / case.nbr_cases
+ res[case.id] = avg_ans
+
+ return res
+
+ _columns = {
+ 'name': fields.date('Month', readonly=True),
+# 'user_id':fields.many2one('res.users', 'User', readonly=True),
+ 'section_id':fields.many2one('crm.case.section', 'Section', readonly=True),
+ 'nbr_cases': fields.integer('# of Cases', readonly=True),
+ 'avg_answers': fields.function(_get_data,string='Avg. Answers', method=True,type="integer"),
+ 'perc_done': fields.function(_get_data,string='%Done', method=True,type="float"),
+ 'perc_cancel': fields.function(_get_data,string='%Cancel', method=True,type="float"),
+ 'delay_close': fields.char('Delay to close', size=20, readonly=True),
+ }
+ _order = 'name desc, section_id'
+ def init(self, cr):
+ cr.execute("""
+ create or replace view report_crm_case_section as (
+ select
+ min(c.id) as id,
+ to_char(c.create_date, 'YYYY-MM-01') as name,
+ c.section_id as section_id,
+ count(*) as nbr_cases,
+ 0 as avg_answers,
+ 0.0 as perc_done,
+ 0.0 as perc_cancel,
+ to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
+ from
+ crm_case c
+ group by to_char(c.create_date, 'YYYY-MM-01'),c.section_id
+ )""")
+report_crm_case_section()
+
+class report_crm_case_service_dashboard(osv.osv):
+ _name = "report.crm.case.service.dashboard"
+ _description = "Report of Closed and Open CRM Cases within past 15 days"
+ _auto = False
+ _columns = {
+ 'date': fields.datetime('Date', readonly=True),
+ 'date_deadline': fields.datetime('Deadline', readonly=True),
+ 'name': fields.char('Description', size=64, readonly=True),
+ 'partner_id': fields.many2one('res.partner', 'Partner', readonly=True),
+ 'user_id': fields.many2one('res.users', 'Responsible', readonly=True),
+ 'priority': fields.char('Priority', size=64, readonly=True),
+ 'planned_revenue': fields.float('Planned Revenue', readonly=True),
+ 'planned_cost': fields.float('Planned Costs', readonly=True),
+ 'state': fields.selection(AVAILABLE_STATES, 'Status', size=16, readonly=True),
+ 'date_closed' : fields.datetime('Date Closed', readonly=True),
+ 'create_date' : fields.datetime('Create Date', readonly=True)
+ }
+ _order = 'date_closed, create_date'
+
+ def init(self, cr):
+ cr.execute("""create or replace view report_crm_case_service_dashboard as (
+ select
+ cse.id as id, cse.date as date, cse.date_deadline as date_deadline,
+ cse.name as name, cse.partner_id as partner_id, cse.user_id as user_id,
+ cse.priority as priority, cse.planned_revenue as planned_revenue,
+ cse.planned_cost as planned_cost, cse.state as state,
+ cse.date_closed as date_closed, cse.create_date as create_date
+ from
+ crm_case cse
+ where
+ ((to_date(to_char(cse.date_closed, 'YYYY-MM-dd'),'YYYY-MM-dd') < CURRENT_DATE)
+ AND
+ (to_date(to_char(cse.date_closed, 'YYYY-MM-dd'),'YYYY-MM-dd') >= (CURRENT_DATE-15))
+ AND
+ cse.state='done')
+
+ OR
+
+ ((to_date(to_char(cse.create_date, 'YYYY-MM-dd'),'YYYY-MM-dd') < CURRENT_DATE)
+ AND
+ (to_date(to_char(cse.create_date, 'YYYY-MM-dd'),'YYYY-MM-dd') >= (CURRENT_DATE-15))
+ AND
+ cse.state='open')
+ )""")
+report_crm_case_service_dashboard()
+
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/report_crm/report_crm_view.xml b/addons/report_crm/report_crm_view.xml
index 056f8eb2dcf..86ad6e80ea3 100644
--- a/addons/report_crm/report_crm_view.xml
+++ b/addons/report_crm/report_crm_view.xml
@@ -155,5 +155,104 @@
+
+
+
+
+ report.crm.case.section.tree
+ report.crm.case.section
+ tree
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ report.crm.case.section.graph
+ report.crm.case.section
+ graph
+
+
+
+
+
+
+
+
+
+ Cases by Section
+ report.crm.case.section
+ form
+ tree,graph
+
+
+
+
+
+ report.crm.case.dashboard.tree
+ report.crm.case.dashboard
+ tree
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ report.crm.case.dashboard.tree
+ report.crm.case.dashboard
+ tree
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Closed CRM Cases Wtihin Past 15 Days
+ report.crm.case.service.dashboard
+ form
+ tree,form
+
+ [('state','=','done')]
+
+
+
+ Open CRM Cases Wtihin Past 15 Days
+ report.crm.case.service.dashboard
+ form
+ tree,form
+
+ [('state','=','open')]
+
+
diff --git a/addons/report_sale/report_sale.py b/addons/report_sale/report_sale.py
index 4ea8325afdd..5407d8df57c 100644
--- a/addons/report_sale/report_sale.py
+++ b/addons/report_sale/report_sale.py
@@ -110,5 +110,67 @@ class report_sale_order_category(osv.osv):
""")
report_sale_order_category()
+class report_turnover_per_month(osv.osv):
+ _name = "report.turnover.per.month"
+ _description = "Turnover Per Month"
+ _auto = False
+ _columns = {
+ 'name': fields.date('Month', readonly=True),
+ 'turnover': fields.float('Total Turnover', readonly=True),
+ }
+
+ def init(self, cr):
+ cr.execute("""
+ create or replace view report_turnover_per_month as (
+ select min(am.id) as id, sum(credit) as turnover,to_char(am.date, 'YYYY-MM-01') as name from account_move_line am
+ where am.account_id in (select distinct(account_id) from account_invoice_line)
+ and
+ am.move_id in(select distinct(aw.move_id) from account_invoice aw,account_invoice_line l where l.invoice_id=aw.id)
+ group by to_char(am.date, 'YYYY-MM-01')
+ )
+ """)
+report_turnover_per_month()
+
+class report_sale_order_created(osv.osv):
+ _name = "report.sale.order.created"
+ _description = "Report of Creaed Sale Order"
+ _auto = False
+ _columns = {
+ 'date_order':fields.date('Date Ordered', readonly=True),
+ 'name': fields.char('Order Reference', size=64, readonly=True),
+ 'partner_id':fields.many2one('res.partner', 'Customer', readonly=True),
+ 'partner_shipping_id':fields.many2one('res.partner.address', 'Shipping Address', readonly=True),
+ 'amount_untaxed': fields.float('Untaxed Amount', readonly=True),
+ 'state': fields.selection([
+ ('draft','Quotation'),
+ ('waiting_date','Waiting Schedule'),
+ ('manual','Manual In Progress'),
+ ('progress','In Progress'),
+ ('shipping_except','Shipping Exception'),
+ ('invoice_except','Invoice Exception'),
+ ('done','Done'),
+ ('cancel','Cancel')
+ ], 'Order State', readonly=True),
+ 'create_date' : fields.datetime('Create Date', readolnly=True)
+ }
+ _order = 'create_date'
+
+ def init(self, cr):
+ cr.execute("""create or replace view report_sale_order_created as (
+ select
+ sale.id as id, sale.date_order as date_order, sale.name as name,
+ sale.partner_id as partner_id,
+ sale.partner_shipping_id as partner_shipping_id,
+ sale.amount_untaxed as amount_untaxed, sale.state as state,
+ sale.create_date as create_date
+ from
+ sale_order sale
+ where
+ (to_date(to_char(sale.create_date, 'YYYY-MM-dd'),'YYYY-MM-dd') < CURRENT_DATE)
+ AND
+ (to_date(to_char(sale.create_date, 'YYYY-MM-dd'),'YYYY-MM-dd') >= (CURRENT_DATE-15))
+ )""")
+report_sale_order_created()
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/report_sale/report_sale_view.xml b/addons/report_sale/report_sale_view.xml
index 1cfb0509ae1..84cb8e92c4c 100644
--- a/addons/report_sale/report_sale_view.xml
+++ b/addons/report_sale/report_sale_view.xml
@@ -171,6 +171,64 @@
[('state','<>','done')]
-
+
+ report.turnover.per.month.tree
+ report.turnover.per.month
+ tree
+
+
+
+
+
+
+
+
+
+ report.turnover.per.month.graph
+ report.turnover.per.month
+ graph
+
+
+
+
+
+
+
+
+
+ ir.actions.act_window
+ Turnover Per Month
+ report.turnover.per.month
+ form
+ tree,graph
+
+
+
+
+
+
+ report.sale.order.created.tree
+ report.sale.order.created
+ tree
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Created Sale Orders
+ report.sale.order.created
+ form
+ tree,form
+
+
diff --git a/addons/report_task/report_task.py b/addons/report_task/report_task.py
index 92272468c9b..0e68cd14866 100644
--- a/addons/report_task/report_task.py
+++ b/addons/report_task/report_task.py
@@ -58,7 +58,81 @@ class report_task_user_pipeline_open (osv.osv):
''')
report_task_user_pipeline_open()
+class report_closed_task(osv.osv):
+ _name = "report.closed.task"
+ _description = "Closed Task Report"
+ _auto = False
+ _columns = {
+ 'sequence': fields.integer('Sequence', readonly=True),
+ 'name': fields.char('Task summary', size=128, readonly=True),
+ 'project_id': fields.many2one('project.project', 'Project', readonly=True),
+ 'user_id': fields.many2one('res.users', 'Assigned to', readonly=True),
+ 'date_deadline': fields.datetime('Deadline', readonly=True),
+ 'planned_hours': fields.float('Planned Hours', readonly=True),
+ 'delay_hours': fields.float('Delay Hours', readonly=True),
+ 'progress': fields.float('Progress (%)', readonly=True),
+ 'priority' : fields.selection([('4','Very Low'), ('3','Low'), ('2','Medium'), ('1','Urgent'), ('0','Very urgent')], 'Importance', readonly=True),
+ 'state': fields.selection([('draft', 'Draft'),('open', 'In Progress'),('pending', 'Pending'), ('cancelled', 'Cancelled'), ('done', 'Done')], 'Status', readonly=True),
+ 'remaining_hours': fields.float('Remaining Hours', readonly=True),
+ 'date_close' : fields.datetime('Date Closed', readonly=True)
+ }
+ def init(self, cr):
+ cr.execute('''
+ create or replace view report_closed_task as (
+ select
+ tsk.id as id, tsk.sequence as sequence, tsk.name as name,
+ tsk.project_id as project_id, tsk.user_id as user_id,
+ tsk.date_deadline as date_deadline, tsk.planned_hours as planned_hours,
+ tsk.delay_hours as delay_hours, tsk.progress as progress,
+ tsk.priority as priority, tsk.state as state,
+ tsk.remaining_hours as remaining_hours, tsk.date_close as date_close
+ from
+ project_task tsk
+ where
+ (tsk.date_close < CURRENT_DATE AND tsk.date_close >= (CURRENT_DATE-15))
+ )
+ ''')
+report_closed_task()
+
+#class report_timesheet_task(osv.osv):
+# _name = "report.timesheet.task"
+# _description = "Report on Timesheets and Tasks per User Per Month"
+# _auto = False
+#
+# def get_hrs_timesheet(self, cr, uid, ids, name,args,context):
+# result = {}
+#
+# for record in self.browse(cr, uid, ids, context):
+# last_date = mx.DateTime.strptime(record.month, '%Y-%m-%d') + mx.DateTime.RelativeDateTime(months=1) - 1
+# obj=self.pool.get('hr_timesheet_sheet.sheet')
+# sheet_ids = obj.search(cr,uid,[('user_id','=',record.user_id.id),('date_current','>=',record.month),('date_current','<=',last_date.strftime('%Y-%m-%d'))])
+# data_days = obj.read(cr,uid,sheet_ids,['total_attendance_day','date_current','user_id'])
+# total = 0.0
+# for day_attendance in data_days:
+# total += day_attendance['total_attendance_day']
+# result[record.id] = total
+#
+# return result
+#
+# _columns = {
+# 'month': fields.date('Month', required=True,readonly=True),
+# 'user_id': fields.many2one('res.users', 'User' ,readonly=True, required=True),
+# 'timesheet_hrs': fields.function(get_hrs_timesheet,method=True, string="Timesheet Hrs" ),
+# 'task_hrs': fields.float('Task Hrs', readonly=True, required=True),
+# }
+#
+#
+# def init(self, cr):
+# cr.execute("""create or replace view report_timesheet_task as (
+# select min(p.id) as id, to_char(p.date, 'YYYY-MM-01') as month, min(r.id) as user_id, sum(p.hours) as task_hrs,0.0 as timesheet_hrs
+# from project_task_work p,res_users r
+# where (r.id=p.user_id)
+# group by to_char(p.date, 'YYYY-MM-01'))""")
+#
+#
+#
+#report_timesheet_task()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/report_task/report_task_view.xml b/addons/report_task/report_task_view.xml
index 60a2a0a7894..c45685a0d8d 100644
--- a/addons/report_task/report_task_view.xml
+++ b/addons/report_task/report_task_view.xml
@@ -58,5 +58,37 @@
+
+
+
+ report.closed.task.tree
+ report.closed.task
+ tree
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Task Closed Within Past 15 Days
+ report.closed.task
+ form
+ tree,form
+
+
+
diff --git a/addons/report_timesheet/report_timesheet.py b/addons/report_timesheet/report_timesheet.py
index 0c901d43f0f..70674b91640 100644
--- a/addons/report_timesheet/report_timesheet.py
+++ b/addons/report_timesheet/report_timesheet.py
@@ -113,7 +113,6 @@ class report_timesheet_account_date(osv.osv):
report_timesheet_account_date()
-
class report_timesheet_invoice(osv.osv):
_name = "report_timesheet.invoice"
_description = "Costs to invoice"
@@ -159,40 +158,83 @@ 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()
+class random_timesheet_lines(osv.osv):
+ _name = "random.timesheet.lines"
+ _description = "Random Timesheet Lines"
+ _auto = False
+
+ _columns = {
+ 'date': fields.date('Date', readonly=True),
+ 'name': fields.char('Description', size=64, readonly=True),
+ 'user_id' : fields.many2one('res.users', 'User', readonly=True),
+ 'quantity' : fields.float('Quantity', readonly=True),
+ 'product_id' : fields.many2one('product.product', 'Product', readonly=True),
+ 'analytic_account_id' : fields.many2one('account.analytic.account','Analytic Account', readonly=True),
+ 'uom_id' : fields.many2one('product.uom', 'UoM', readonly=True),
+ 'amount' : fields.float('Amount', readonly=True),
+ 'to_invoice': fields.many2one('hr_timesheet_invoice.factor', 'Invoicing', readonly=True),
+ 'general_account_id' : fields.many2one('account.account', 'General Account', readonly=True)
+ }
+
+ _order = "date desc"
+
+ def init(self, cr):
+
+ cr.execute("""create or replace view random_timesheet_lines as (
+ select
+ line.id as id, line.date as date, line.name as name, line.unit_amount as quantity,
+ line.product_id as product_id, line.account_id as analytic_account_id,
+ line.product_uom_id as uom_id, line.amount as amount, line.to_invoice as to_invoice,
+ line.general_account_id as general_account_id, line.user_id as user_id
+ from
+ account_analytic_line line
+ where
+ (line.date < CURRENT_DATE AND line.date >= (CURRENT_DATE-15))
+ )
+ """ )
+
+random_timesheet_lines()
# 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 4c611562808..624b75945c8 100644
--- a/addons/report_timesheet/report_timesheet_view.xml
+++ b/addons/report_timesheet/report_timesheet_view.xml
@@ -287,13 +287,10 @@
tree
-
-
-
-
-
-
-
+
+
+
+
@@ -306,5 +303,37 @@
tree,form
+
+
+
+
+ random.timesheet.lines.tree
+ random.timesheet.lines
+ tree
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ir.actions.act_window
+ Random Timesheet Lines
+ random.timesheet.lines
+ form
+ tree,form
+
+
+
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 9285143c69e..25b721613a3 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -757,6 +757,14 @@ stock_picking()
class stock_production_lot(osv.osv):
+ def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
+ if context is None:
+ context = {}
+ res = super(stock_production_lot, self).search(cr, uid, args, offset, limit, order, context=context, count=count)
+ if res:
+ return [k for k,v in self._get_stock(cr, uid, res, 'stock_available', None, context).items() if v]
+ return res
+
def name_get(self, cr, uid, ids, context={}):
if not ids:
return []