[FIX] hr_timesheet_invoice: Add the default values for the account journal and the account in the account.analytic.line (Invoice Tasks Work)
bzr revid: stw@openerp.com-20120731105402-wqq9qv5db1si6na9
This commit is contained in:
parent
84ea8f59d7
commit
c82a87bbd8
|
@ -126,6 +126,25 @@ class account_analytic_line(osv.osv):
|
|||
'to_invoice': fields.many2one('hr_timesheet_invoice.factor', 'Type of Invoicing', help="It allows to set the discount while making invoice"),
|
||||
}
|
||||
|
||||
def _default_journal(self, cr, uid, context=None):
|
||||
proxy = self.pool.get('hr.employee')
|
||||
record_ids = proxy.search(cr, uid, [('user_id', '=', uid)], context=context)
|
||||
employee = proxy.browse(cr, uid, record_ids[0], context=context)
|
||||
return employee.journal_id and employee.journal_id.id or False
|
||||
|
||||
def _default_general_account(self, cr, uid, context=None):
|
||||
proxy = self.pool.get('hr.employee')
|
||||
record_ids = proxy.search(cr, uid, [('user_id', '=', uid)], context=context)
|
||||
employee = proxy.browse(cr, uid, record_ids[0], context=context)
|
||||
if employee.product_id and employee.product_id.property_account_income:
|
||||
return employee.product_id.property_account_income.id
|
||||
return False
|
||||
|
||||
_defaults = {
|
||||
'journal_id' : _default_journal,
|
||||
'general_account_id' : _default_general_account,
|
||||
}
|
||||
|
||||
def write(self, cr, uid, ids, vals, context=None):
|
||||
self._check_inv(cr, uid, ids, vals)
|
||||
return super(account_analytic_line,self).write(cr, uid, ids, vals,
|
||||
|
|
Loading…
Reference in New Issue