← Back to team overview

openerp-india team mailing list archive

[Bug 1194169] Re: [Trunk/7.0] hr_timesheet.py - cost of employee not taken into account in timesheet

 

[Expired for OpenERP Addons because there has been no activity for 60
days.]

** Changed in: openobject-addons
       Status: Incomplete => Expired

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Addons.
https://bugs.launchpad.net/bugs/1194169

Title:
  [Trunk/7.0] hr_timesheet.py - cost of employee not taken into account
  in timesheet

Status in OpenERP Addons (modules):
  Expired

Bug description:
  When the employee is compiling a timesheet, its cost is not registered
  in the analytic accounting line.

  The following patch is proposed:

  ***************
  *** 115,124 ****
  --- 115,135 ----
                emp = emp_obj.browse(cr, uid, emp_id[0], context=context)
                if emp.product_id:
                    return emp.product_id.uom_id.id
            return False
    
  +     def _getEmployeeCost(self, cr, uid, context=None):
  +         if context is None:
  +             context = {}
  +         emp_obj = self.pool.get('hr.employee')
  +         emp_id = emp_obj.search(cr, uid, [('user_id', '=', context.get('user_id') or uid)], context=context)
  +         if emp_id:
  +             emp = emp_obj.browse(cr, uid, emp_id[0], context=context)
  +             if emp.product_id:
  +                 return emp.product_id.standard_price
  +         return False
  + 
        def _getGeneralAccount(self, cr, uid, context=None):
            emp_obj = self.pool.get('hr.employee')
            if context is None:
                context = {}
            emp_id = emp_obj.search(cr, uid, [('user_id', '=', context.get('user_id') or uid)], context=context)
  ***************
  *** 129,139 ****
                    if not a:
                        a = emp.product_id.categ_id.property_account_expense_categ.id
                    if a:
                        return a
            return False
  ! 
        def _getAnalyticJournal(self, cr, uid, context=None):
            emp_obj = self.pool.get('hr.employee')
            if context is None:
                context = {}
            if context.get('employee_id'):
  --- 140,150 ----
                    if not a:
                        a = emp.product_id.categ_id.property_account_expense_categ.id
                    if a:
                        return a
            return False
  !  
        def _getAnalyticJournal(self, cr, uid, context=None):
            emp_obj = self.pool.get('hr.employee')
            if context is None:
                context = {}
            if context.get('employee_id'):
  ***************
  *** 152,161 ****
  --- 163,173 ----
        _defaults = {
            'product_uom_id': _getEmployeeUnit,
            'product_id': _getEmployeeProduct,
            'general_account_id': _getGeneralAccount,
            'journal_id': _getAnalyticJournal,
  +         'amount': _getEmployeeCost,
            'date': lambda self, cr, uid, ctx: ctx.get('date', fields.date.context_today(self,cr,uid,context=ctx)),
            'user_id': lambda obj, cr, uid, ctx: ctx.get('user_id') or uid,
        }
        def on_change_account_id(self, cr, uid, ids, account_id, context=None):
            return {'value':{}}

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-addons/+bug/1194169/+subscriptions