[MERGE] merge with trunk addons

bzr revid: mra@mra-laptop-20100802123026-cdi1bxscpqych6ck
This commit is contained in:
Mustufa Rangwala
2010-08-02 18:00:26 +05:30
12 changed files with 130 additions and 45 deletions
+1 -1
View File
@@ -137,7 +137,7 @@ module named account_vouchers
'test/chart_of_account.yml',
'test/account_period_close.yml',
'test/account_fiscalyear_close_state.yml',
'test/account_invoice_state.yml',
#'test/account_invoice_state.yml',
'test/account_use_model.yml',
'test/account_validate_account_move.yml',
'test/account_fiscalyear_close.yml',
@@ -92,3 +92,5 @@
"access_account_account_report_manager","account.account.report","model_account_account_report","account.group_account_manager",1,0,0,0
"access_account_entries_report_manager","account.entries.report","model_account_entries_report","account.group_account_manager",1,0,0,0
"access_analytic_entries_report_manager","analytic.entries.report","model_analytic_entries_report","account.group_account_manager",1,0,0,0
"access_account_cashbox_line","account.cashbox.line","model_account_cashbox_line","account.group_account_manager",1,1,1,1
"access_account_cashbox_line","account.cashbox.line","model_account_cashbox_line","account.group_account_user",1,0,0,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
92 access_account_account_report_manager account.account.report model_account_account_report account.group_account_manager 1 0 0 0
93 access_account_entries_report_manager account.entries.report model_account_entries_report account.group_account_manager 1 0 0 0
94 access_analytic_entries_report_manager analytic.entries.report model_analytic_entries_report account.group_account_manager 1 0 0 0
95 access_account_cashbox_line account.cashbox.line model_account_cashbox_line account.group_account_manager 1 1 1 1
96 access_account_cashbox_line account.cashbox.line model_account_cashbox_line account.group_account_user 1 0 0 0
@@ -34,21 +34,23 @@ class account_statement_from_invoice_lines(osv.osv_memory):
}
def populate_statement(self, cr, uid, ids, context=None):
statement_id = context.get('statement_id', False)
if not statement_id:
return {}
data = self.read(cr, uid, ids, context=context)[0]
line_ids = data['line_ids']
if not line_ids:
return {}
line_obj = self.pool.get('account.move.line')
statement_obj = self.pool.get('account.bank.statement')
statement_line_obj = self.pool.get('account.bank.statement.line')
currency_obj = self.pool.get('res.currency')
statement_reconcile_obj = self.pool.get('account.bank.statement.reconcile')
data = self.read(cr, uid, ids, context=context)[0]
line_ids = data['line_ids']
line_date = time.strftime('%Y-%m-%d')
if not line_ids:
return {}
statement_id = 'statement_id' in context and context['statement_id']
statement = statement_obj.browse(cr, uid, statement_id, context=context)
# for each selected move lines
for line in line_obj.browse(cr, uid, line_ids, context=context):
ctx = context.copy()
@@ -54,6 +54,7 @@
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_account_statement_from_invoice_lines"/>
<field name="target">new</field>
<field name="context">{'statement_id': active_id}</field>
</record>
+1 -1
View File
@@ -90,7 +90,7 @@ class hr_holidays_status(osv.osv):
if employee_id:
res = self.get_days(cr, uid, ids, employee_id, return_false, context=context)
else:
res = dict.fromkeys(ids, {name: 0})
res = dict.fromkeys(ids, {'leaves_taken': 0, 'remaining_leaves': 0, 'max_leaves': 0})
return res
# To do: we can add remaining_leaves_category field to display remaining leaves for particular type
+61 -1
View File
@@ -19,6 +19,9 @@
#
##############################################################################
import time
from datetime import datetime, timedelta
from osv import fields, osv
from crm import crm
import tools
@@ -77,6 +80,43 @@ class hr_applicant(osv.osv, crm.crm_case):
_description = "Applicant"
_order = "id desc"
_inherit = ['mailgate.thread']
def _compute_day(self, cr, uid, ids, fields, args, context=None):
if context is None:
context = {}
"""
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of Openday’s IDs
@return: difference between current date and log date
@param context: A standard dictionary for contextual values
"""
res = {}
for issue in self.browse(cr, uid, ids, context=context):
for field in fields:
res[issue.id] = {}
duration = 0
ans = False
hours = 0
if field in ['day_open']:
if issue.date_open:
date_create = datetime.strptime(issue.create_date, "%Y-%m-%d %H:%M:%S")
date_open = datetime.strptime(issue.date_open, "%Y-%m-%d %H:%M:%S")
ans = date_open - date_create
date_until = issue.date_open
elif field in ['day_close']:
if issue.date_closed:
date_create = datetime.strptime(issue.create_date, "%Y-%m-%d %H:%M:%S")
date_close = datetime.strptime(issue.date_closed, "%Y-%m-%d %H:%M:%S")
date_until = issue.date_closed
ans = date_close - date_create
if ans:
duration = float(ans.days)
res[issue.id][field] = abs(float(duration))
return res
_columns = {
'name': fields.char('Name', size=128, required=True),
'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('model','=',_name)]),
@@ -100,6 +140,7 @@ class hr_applicant(osv.osv, crm.crm_case):
'user_id': fields.many2one('res.users', 'Responsible'),
# Applicant Columns
'date_closed': fields.datetime('Closed', readonly=True),
'date_open': fields.datetime('Opened', readonly=True),
'date': fields.datetime('Date'),
'date_action': fields.date('Next Action Date'),
'title_action': fields.char('Next Action', size=64),
@@ -117,6 +158,10 @@ class hr_applicant(osv.osv, crm.crm_case):
'survey' : fields.related('job_id', 'survey_id', type='many2one', relation='survey', string='Survey'),
'response' : fields.integer("Response"),
'reference': fields.char('Reference', size=128),
'day_open': fields.function(_compute_day, string='Days to Open', \
method=True, multi='day_open', type="float", store=True),
'day_close': fields.function(_compute_day, string='Days to Close', \
method=True, multi='day_close', type="float", store=True),
}
def _get_stage(self, cr, uid, context=None):
@@ -343,7 +388,6 @@ class hr_applicant(osv.osv, crm.crm_case):
return res
def msg_send(self, cr, uid, id, *args, **argv):
""" Send The Message
@param self: The object pointer
@param cr: the current row, from the database cursor,
@@ -363,6 +407,9 @@ class hr_applicant(osv.osv, crm.crm_case):
@param *args: Give Tuple Value
"""
res = super(hr_applicant, self).case_open(cr, uid, ids, *args)
date = self.read(cr, uid, ids, ['date_open'])[0]
if not date['date_open']:
self.write(cr, uid, ids, {'date_open': time.strftime('%Y-%m-%d %H:%M:%S'),})
for (id, name) in self.name_get(cr, uid, ids):
message = _('Job request for') + " '" + name + "' "+ _("is Open.")
self.log(cr, uid, id, message)
@@ -382,6 +429,19 @@ class hr_applicant(osv.osv, crm.crm_case):
self.log(cr, uid, id, message)
return res
def case_reset(self, cr, uid, ids, *args):
"""Resets case as draft
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of case Ids
@param *args: Tuple Value for additional Params
"""
res = super(hr_applicant, self).case_reset(cr, uid, ids, *args)
self.write(cr, uid, ids, {'date_open': False, 'date_closed':False})
return res
hr_applicant()
class hr_job(osv.osv):
@@ -131,6 +131,7 @@
<field name="create_date"/>
<field name="write_date"/>
<field name="date_closed"/>
<field name="date_open"/>
</group>
<separator colspan="4" string="Status"/>
<group col="8" colspan="4">
@@ -93,6 +93,7 @@ class hr_recruitment_report(osv.osv):
('10','October'), ('11','November'), ('12','December')], 'Month',readonly=True),
'day': fields.char('Day', size=128, readonly=True),
'date': fields.date('Date', readonly=True),
'opening_date': fields.date('Date of Opening', readonly=True),
'date_closed': fields.date('Closed', readonly=True),
'job_id': fields.many2one('hr.job', 'Applied Job',readonly=True),
'stage_id': fields.many2one ('hr.recruitment.stage', 'Stage'),
@@ -103,7 +104,11 @@ class hr_recruitment_report(osv.osv):
'salary_exp' : fields.float("Salary Expected"),
'partner_id': fields.many2one('res.partner', 'Partner',readonly=True),
'partner_address_id': fields.many2one('res.partner.address', 'Partner Contact Name',readonly=True),
'available' : fields.float("Availability")
'available' : fields.float("Availability"),
'delay_open': fields.float('Avg. Delay to Open', digits=(16,2), readonly=True, group_operator="avg",
help="Number of Days to close the project issue"),
'delay_close': fields.float('Avg. Delay to Close', digits=(16,2), readonly=True, group_operator="avg",
help="Number of Days to close the project issue"),
}
_order = 'date desc'
@@ -131,6 +136,8 @@ class hr_recruitment_report(osv.osv):
s.stage_id,
sum(salary_proposed) as salary_prop,
sum(salary_expected) as salary_exp,
extract('epoch' from (s.date_open-s.create_date))/(3600*24) as delay_open,
extract('epoch' from (s.date_closed-s.create_date))/(3600*24) as delay_close,
count(*) as nbr
from hr_applicant s
group by
@@ -139,6 +146,9 @@ class hr_recruitment_report(osv.osv):
to_char(s.create_date, 'YYYY-MM-DD') ,
date_trunc('day',s.create_date),
date_trunc('day',s.date_closed),
s.date_open,
s.create_date,
s.date_closed,
s.state,
s.partner_id,
s.partner_address_id,
@@ -23,6 +23,8 @@
<field name="nbr" sum="# Cases"/>
<field name="salary_prop" sum="Salary Proposed" />
<field name="salary_exp" sum="Salary Expected"/>
<field name="delay_open" avg='Avg Opening Delay'/>
<field name="delay_close" avg='Avg Closing Delay'/>
<field name="available" sum="Available"/>
</tree>
</field>
@@ -1,3 +1,5 @@
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
"access_hr_applicant","hr.applicant","model_hr_applicant","hr.group_hr_user",1,1,1,1
"access_hr_recruitment_report","hr.recruitment.report","model_hr_recruitment_report","hr.group_hr_manager",1,0,0,0
"access_hr_recruitment_stage","hr.recruitment.stage","model_hr_recruitment_stage","hr.group_hr_user",1,1,1,1
"access_hr_recruitment_degree","hr.recruitment.degree","model_hr_recruitment_degree","hr.group_hr_user",1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_hr_applicant hr.applicant model_hr_applicant hr.group_hr_user 1 1 1 1
3 access_hr_recruitment_report hr.recruitment.report model_hr_recruitment_report hr.group_hr_manager 1 0 0 0
4 access_hr_recruitment_stage hr.recruitment.stage model_hr_recruitment_stage hr.group_hr_user 1 1 1 1
5 access_hr_recruitment_degree hr.recruitment.degree model_hr_recruitment_degree hr.group_hr_user 1 1 1 1
-1
View File
@@ -176,7 +176,6 @@ class project_issue(osv.osv, crm.crm_case):
'project_id':fields.many2one('project.project', 'Project'),
'duration': fields.float('Duration'),
'task_id': fields.many2one('project.task', 'Task', domain="[('project_id','=',project_id)]"),
'date_open': fields.datetime('Opened', readonly=True),
'day_open': fields.function(_compute_day, string='Days to Open', \
method=True, multi='day_open', type="float", store=True),
'day_close': fields.function(_compute_day, string='Days to Close', \
+38 -32
View File
@@ -62,6 +62,7 @@ class project_work(osv.osv):
obj_timesheet = self.pool.get('hr.analytic.timesheet')
task_obj = self.pool.get('project.task')
vals_line = {}
context = kwargs.get('context', {})
obj_task = task_obj.browse(cr, uid, vals['task_id'])
result = self.get_user_related_details(cr, uid, vals.get('user_id', uid))
vals_line['name'] = '%s: %s' % (tools.ustr(obj_task.name), tools.ustr(vals['name']) or '/')
@@ -76,71 +77,76 @@ class project_work(osv.osv):
vals_line.update(res['value'])
vals_line['general_account_id'] = result['general_account_id']
vals_line['journal_id'] = result['journal_id']
vals_line['amount'] = 00.0
vals_line['amount'] = 0.0
vals_line['product_uom_id'] = result['product_uom_id']
amount = vals_line['unit_amount']
prod_id = vals_line['product_id']
unit = False
timeline_id = obj_timesheet.create(cr, uid, vals=vals_line, context=kwargs['context'])
timeline_id = obj_timesheet.create(cr, uid, vals=vals_line, context=context)
# Compute based on pricetype
amount_unit = obj_timesheet.on_change_unit_amount(cr, uid, timeline_id,
prod_id, amount, unit, context=kwargs['context'])
if amount_unit:
vals_line['amount'] = (-1) * vals['hours']* (amount_unit.get('value',{}).get('amount',0.0) or 0.0)
obj_timesheet.write(cr, uid, [timeline_id], vals_line, {})
prod_id, amount, unit, context=context)
if amount_unit and 'amount' in amount_unit.get('value',{}):
updv = { 'amount': amount_unit['value']['amount'] * (-1.0) }
obj_timesheet.write(cr, uid, [timeline_id], updv, context=context)
vals['hr_analytic_timesheet_id'] = timeline_id
return super(project_work,self).create(cr, uid, vals, *args, **kwargs)
def write(self, cr, uid, ids, vals, context=None):
if context is None:
context = {}
vals_line = {}
obj = self.pool.get('hr.analytic.timesheet')
timesheet_obj = self.pool.get('hr.analytic.timesheet')
task = self.pool.get('project.task.work').browse(cr, uid, ids, context=context)[0]
line_id = task.hr_analytic_timesheet_id
# in case,if a record is deleted from timesheet,but we change it from tasks!
list_avail_ids = timesheet_obj.search(cr, uid, [], context=context)
if line_id in list_avail_ids:
if isinstance(ids, (long, int)):
ids = [ids,]
for task in self.browse(cr, uid, ids, context=context):
line_id = task.hr_analytic_timesheet_id
if not line_id:
# if a record is deleted from timesheet, the line_id will become
# null because of the foreign key on-delete=set null
continue
vals_line = {}
if 'name' in vals:
vals_line['name'] = '%s: %s' % (tools.ustr(task.task_id.name), tools.ustr(vals['name']) or '/')
if 'user_id' in vals:
vals_line['user_id'] = vals['user_id']
result = self.get_user_related_details(cr, uid, vals['user_id'])
vals_line['product_id'] = result['product_id']
vals_line['general_account_id'] = result['general_account_id']
vals_line['journal_id'] = result['journal_id']
vals_line['product_uom_id'] = result['product_uom_id']
for fld in ('product_id', 'general_account_id', 'journal_id', 'product_uom_id'):
if result.get(fld, False):
vals_line[fld] = result[fld]
if 'date' in vals:
vals_line['date'] = vals['date'][:10]
if 'hours' in vals:
vals_line['unit_amount'] = vals['hours']
prod_id = vals_line.get('product_id', line_id.product_id.id) # False may be set
# Compute based on pricetype
unit = False
amount_unit=obj.on_change_unit_amount(cr, uid, line_id,
vals_line['product_id'], vals_line['unit_amount'], unit, context=context)
if amount_unit:
vals_line['amount'] = (-1) * vals['hours'] * (amount_unit.get('value',{}).get('amount',0.0) or 0.0)
obj.write(cr, uid, [line_id], vals_line, context=context)
amount_unit = obj.on_change_unit_amount(cr, uid, line_id.id,
prod_id=prod_id,
unit_amount=vals_line['unit_amount'], unit=False, context=context)
if amount_unit and 'amount' in amount_unit.get('value',{}):
vals_line['amount'] = amount_unit['value']['amount'] * (-1.0)
obj.write(cr, uid, [line_id.id], vals_line, context=context)
return super(project_work,self).write(cr, uid, ids, vals, context)
def unlink(self, cr, uid, ids, *args, **kwargs):
pool_analytic_timesheet = self.pool.get('hr.analytic.timesheet')
for work_id in ids:
timesheet_id = self.read(cr, uid, work_id, ['hr_analytic_timesheet_id'])['hr_analytic_timesheet_id']
hat_obj = self.pool.get('hr.analytic.timesheet')
hat_ids = []
for task in self.browse(cr, uid, ids):
if task.hr_analytic_timesheet_id:
hat_ids.append(task.hr_analytic_timesheet_id)
# delete entry from timesheet too while deleting entry to task.
list_avail_ids = pool_analytic_timesheet.search(cr, uid, [])
if timesheet_id in list_avail_ids:
obj = pool_analytic_timesheet.unlink(cr, uid, [timesheet_id], *args, **kwargs)
if hat_ids:
hat_obj.unlink(cr, uid, hat_ids, *args, **kwargs)
return super(project_work,self).unlink(cr, uid, ids, *args, **kwargs)
_columns={
'hr_analytic_timesheet_id':fields.integer('Related Timeline Id')
'hr_analytic_timesheet_id':fields.many2one('hr.analytic.timesheet','Related Timeline Id', ondelete='set null'),
}
project_work()