# -*- encoding: utf-8 -*-
##############################################################################
#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
# This program is free software: you can redistribute it and/or modify
'employee_id': fields.many2one('hr.employee', 'Employee', required=True),
'user_id': fields.many2one('res.users', 'User', required=True),
'date_confirm': fields.date('Date Confirmed'),
- 'date_valid': fields.date('Date Valided'),
+ 'date_valid': fields.date('Date Validated'),
'user_valid': fields.many2one('res.users', 'Validation User'),
'account_move_id': fields.many2one('account.move', 'Account Move'),
- 'line_ids': fields.one2many('hr.expense.line', 'expense_id', 'Expense Lines'),
+ 'line_ids': fields.one2many('hr.expense.line', 'expense_id', 'Expense Lines', readonly=True, states={'draft':[('readonly',False)]} ),
'note': fields.text('Note'),
'amount': fields.function(_amount, method=True, string='Total Amount'),
'invoice_id': fields.many2one('account.invoice', 'Invoice'),
('accepted', 'Accepted'),
('invoiced', 'Invoiced'),
('paid', 'Reimbursed'),
- ('canceled', 'Canceled')],
+ ('cancelled', 'Cancelled')],
'State', readonly=True),
}
_defaults = {
return True
def expense_canceled(self, cr, uid, ids, *args):
- self.write(cr, uid, ids, {'state':'canceled'})
+ self.write(cr, uid, ids, {'state':'cancelled'})
return True
def expense_paid(self, cr, uid, ids, *args):
tax_id = [x.id for x in l.product_id.supplier_taxes_id]
else:
acc = self.pool.get('ir.property').get(cr, uid, 'property_account_expense_categ', 'product.category')
+ if not acc:
+ raise osv.except_osv(_('Error !'), _('Please configure Default Expanse account for Product purchase, `property_account_expense_categ`'))
+
lines.append((0, False, {
'name': l.name,
'account_id': acc,
'account_analytic_id': l.analytic_account.id,
}))
if not exp.employee_id.address_id:
- raise osv.except_osv(_('Error !'), _('The employee must have a contact address'))
+ raise osv.except_osv(_('Error !'), _('The employee must have a working address'))
acc = exp.employee_id.address_id.partner_id.property_account_payable.id
payment_term_id = exp.employee_id.address_id.partner_id.property_payment_term.id
inv = {
'price_type': 'tax_included',
'currency_id': exp.currency_id.id,
'payment_term': payment_term_id,
+ 'fiscal_position': exp.employee_id.address_id.partner_id.property_account_position.id
}
if payment_term_id:
to_update = invoice_obj.onchange_payment_term_date_invoice(cr, uid, [],
return res
hr_expense_expense()
+class product_product(osv.osv):
+ _inherit = "product.product"
+
+ _columns = {
+ 'hr_expense_ok': fields.boolean('Can be Expensed', help="Determine if the product can be visible in the list of product within a selection from an HR expense sheet line."),
+ }
+
+product_product()
+
class hr_expense_line(osv.osv):
_name = "hr.expense.line"
'date_value': fields.date('Date', required=True),
'expense_id': fields.many2one('hr.expense.expense', 'Expense', ondelete='cascade', select=True),
'total_amount': fields.function(_amount, method=True, string='Total'),
- 'unit_amount': fields.float('Unit Price', readonly=True, states={'draft':[('readonly',False)]}),
- 'unit_quantity': fields.float('Quantities', readonly=True, states={'draft':[('readonly',False)]}),
- 'product_id': fields.many2one('product.product', 'Product', readonly=True, states={'draft':[('readonly',False)]}),
- 'uom_id': fields.many2one('product.uom', 'UoM', readonly=True, states={'draft':[('readonly',False)]}),
+ 'unit_amount': fields.float('Unit Price'),
+ 'unit_quantity': fields.float('Quantities' ),
+ 'product_id': fields.many2one('product.product', 'Product', domain=[('hr_expense_ok','=',True)]),
+ 'uom_id': fields.many2one('product.uom', 'UoM' ),
'description': fields.text('Description'),
'analytic_account': fields.many2one('account.analytic.account','Analytic account'),
'ref': fields.char('Reference', size=32),
hr_expense_line()
-
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: