[FIX] Analytic_user_function and project_timsheet corrected according to pricetype
bzr revid: joel.grandguillaume@camptocamp.com-20091223171409-a0wfgy034f8o5yjw
This commit is contained in:
parent
90ddcec2d7
commit
b75d214b25
|
@ -99,8 +99,11 @@ class hr_analytic_timesheet(osv.osv):
|
|||
_('There is no expense account define ' \
|
||||
'for this product: "%s" (id:%d)') % \
|
||||
(r.product_id.name, r.product_id.id,))
|
||||
amount = unit_amount * self.pool.get('product.uom')._compute_price(cr, uid,
|
||||
r.product_id.uom_id.id, r.product_id.standard_price, False)
|
||||
# Compute based on pricetype
|
||||
amount_unit=self.on_change_unit_amount(cr, uid, ids,
|
||||
r.product_id.id, unit_amount, r.product_id.uom_id.id)['value']['amount']
|
||||
|
||||
amount = unit_amount * amount_unit
|
||||
res ['value']['amount']= - round(amount, 2)
|
||||
res ['value']['general_account_id']= a
|
||||
return res
|
||||
|
@ -132,8 +135,11 @@ class hr_analytic_timesheet(osv.osv):
|
|||
_('There is no expense account define ' \
|
||||
'for this product: "%s" (id:%d)') % \
|
||||
(r.product_id.name, r.product_id.id,))
|
||||
amount = unit_amount * r.product_id.uom_id._compute_price(cr, uid,
|
||||
r.product_id.uom_id.id, r.product_id.standard_price, False)
|
||||
# Compute based on pricetype
|
||||
amount_unit=self.on_change_unit_amount(cr, uid, ids,
|
||||
r.product_id.id, unit_amount, r.product_id.uom_id.id)['value']['amount']
|
||||
|
||||
amount = unit_amount * amount_unit
|
||||
res ['value']['amount']= - round(amount, 2)
|
||||
res ['value']['general_account_id']= a
|
||||
return res
|
||||
|
|
|
@ -56,7 +56,7 @@ class hr_analytic_timesheet(osv.osv):
|
|||
def on_change_unit_amount(self, cr, uid, id, prod_id, unit_amount, unit, context={}):
|
||||
res = {}
|
||||
# if prod_id and unit_amount:
|
||||
if prod_id and date:
|
||||
if prod_id:
|
||||
# find company
|
||||
company_id=self.pool.get('res.company')._company_default_get(cr, uid, 'account.analytic.line', context)
|
||||
res = self.pool.get('account.analytic.line').on_change_unit_amount(cr, uid, id, prod_id, unit_amount,company_id,unit, context)
|
||||
|
|
|
@ -77,8 +77,12 @@ class project_work(osv.osv):
|
|||
vals_line['journal_id'] = result['journal_id']
|
||||
vals_line['amount'] = 00.0
|
||||
timeline_id = obj.create(cr, uid, vals_line, {})
|
||||
|
||||
vals_line['amount'] = (-1) * vals['hours']* ( obj.browse(cr,uid,timeline_id).product_id.standard_price or 0.0)
|
||||
|
||||
# Compute based on pricetype
|
||||
amount_unit=obj.on_change_unit_amount(cr, uid, line_id,
|
||||
vals_line['product_id'], vals_line['unit_amount'], unit, context)
|
||||
|
||||
vals_line['amount'] = (-1) * vals['hours']* (unit_amount or 0.0)
|
||||
obj.write(cr, uid,[timeline_id], vals_line, {})
|
||||
vals['hr_analytic_timesheet_id'] = timeline_id
|
||||
return super(project_work,self).create(cr, uid, vals, *args, **kwargs)
|
||||
|
|
Loading…
Reference in New Issue