diff --git a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py index 54257f5efba..a4f08a854ec 100644 --- a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py +++ b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py @@ -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,