[MERGE] improve expense: readonly if not draft
bzr revid: fp@tinyerp.com-20121113073126-8z40r87mmyqknd8p
This commit is contained in:
commit
d8f9aecce7
|
@ -64,22 +64,22 @@ class hr_expense_expense(osv.osv):
|
|||
_description = "Expense"
|
||||
_order = "id desc"
|
||||
_columns = {
|
||||
'name': fields.char('Description', size=128),
|
||||
'name': fields.char('Description', size=128, required=True, readonly=True, states={'draft':[('readonly',False)], 'confirm':[('readonly',False)]}),
|
||||
'id': fields.integer('Sheet ID', readonly=True),
|
||||
'date': fields.date('Date', select=True),
|
||||
'date': fields.date('Date', select=True, readonly=True, states={'draft':[('readonly',False)], 'confirm':[('readonly',False)]}),
|
||||
'journal_id': fields.many2one('account.journal', 'Force Journal', help = "The journal used when the expense is done."),
|
||||
'employee_id': fields.many2one('hr.employee', "Employee", required=True),
|
||||
'employee_id': fields.many2one('hr.employee', "Employee", required=True, readonly=True, states={'draft':[('readonly',False)], 'confirm':[('readonly',False)]}),
|
||||
'user_id': fields.many2one('res.users', 'User', required=True),
|
||||
'date_confirm': fields.date('Confirmation Date', select=True, help="Date of the confirmation of the sheet expense. It's filled when the button Confirm is pressed."),
|
||||
'date_valid': fields.date('Validation Date', select=True, help="Date of the acceptation of the sheet expense. It's filled when the button Accept is pressed."),
|
||||
'user_valid': fields.many2one('res.users', 'Validation By'),
|
||||
'user_valid': fields.many2one('res.users', 'Validation By', readonly=True, states={'draft':[('readonly',False)], 'confirm':[('readonly',False)]}),
|
||||
'account_move_id': fields.many2one('account.move', 'Ledger Posting'),
|
||||
'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, string='Total Amount', digits_compute= dp.get_precision('Account')),
|
||||
'voucher_id': fields.many2one('account.voucher', "Employee's Receipt"),
|
||||
'currency_id': fields.many2one('res.currency', 'Currency', required=True),
|
||||
'department_id':fields.many2one('hr.department','Department'),
|
||||
'currency_id': fields.many2one('res.currency', 'Currency', required=True, readonly=True, states={'draft':[('readonly',False)], 'confirm':[('readonly',False)]}),
|
||||
'department_id':fields.many2one('hr.department','Department', readonly=True, states={'draft':[('readonly',False)], 'confirm':[('readonly',False)]}),
|
||||
'company_id': fields.many2one('res.company', 'Company', required=True),
|
||||
'state': fields.selection([
|
||||
('draft', 'New'),
|
||||
|
@ -100,6 +100,12 @@ class hr_expense_expense(osv.osv):
|
|||
'currency_id': _get_currency,
|
||||
}
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
for rec in self.browse(cr, uid, ids, context=context):
|
||||
if rec.state != 'draft':
|
||||
raise osv.except_osv(_('Warning!'),_('You can only delete draft expenses!'))
|
||||
return super(hr_expense_expense, self).unlink(cr, uid, ids, context)
|
||||
|
||||
def onchange_currency_id(self, cr, uid, ids, currency_id=False, company_id=False, context=None):
|
||||
res = {'value': {'journal_id': False}}
|
||||
journal_ids = self.pool.get('account.journal').search(cr, uid, [('type','=','purchase'), ('currency','=',currency_id), ('company_id', '=', company_id)], context=context)
|
||||
|
|
Loading…
Reference in New Issue