[IMP]:improved code
bzr revid: apa@tinyerp.com-20111123053154-gsay5gufpz83vkns
This commit is contained in:
parent
fe0754a549
commit
2e758fb463
|
@ -299,14 +299,12 @@ class hr_payslip(osv.osv):
|
|||
}
|
||||
|
||||
def _check_dates(self, cr, uid, ids, context=None):
|
||||
for i in self.read(cr, uid, ids, ['date_from', 'date_to'], context=context):
|
||||
if i['date_from'] > i['date_to']:
|
||||
return False
|
||||
return True
|
||||
for i in self.read(cr, uid, ids, ['date_from', 'date_to'], context=context):
|
||||
if i['date_from'] > i['date_to']:
|
||||
return False
|
||||
return True
|
||||
|
||||
_constraints = [
|
||||
(_check_dates, 'Error! Payslip from-date must be lower then contract to-date.', ['date_from', 'date_to'])
|
||||
]
|
||||
_constraints = [(_check_dates, 'Error! Payslip from-date must be lower then contract to-date.', ['date_from', 'date_to'])]
|
||||
|
||||
def copy(self, cr, uid, id, default=None, context=None):
|
||||
if not default:
|
||||
|
|
|
@ -34,21 +34,20 @@ class hr_payslip(osv.osv):
|
|||
_inherit = 'hr.payslip'
|
||||
_description = 'Pay Slip'
|
||||
|
||||
def _get_journal(self, cr, uid, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
journal_obj = self.pool.get('account.journal')
|
||||
res = journal_obj.search(cr, uid, [('type', '=','sale')])
|
||||
return res and res[0] or False
|
||||
|
||||
def _get_journal_id(self, cr, uid, *args):
|
||||
model_data = self.pool.get('ir.model.data')
|
||||
res = model_data.search(cr,uid, [('name', '=', 'expenses_journal')])
|
||||
if res:return model_data.browse(cr,uid,res[0]).res_id
|
||||
return False
|
||||
|
||||
_columns = {
|
||||
'period_id': fields.many2one('account.period', 'Force Period',states={'draft': [('readonly', False)]}, readonly=True, domain=[('state','<>','done')], help="Keep empty to use the period of the validation(Payslip) date."),
|
||||
'journal_id': fields.many2one('account.journal', 'Expense Journal',states={'draft': [('readonly', False)]}, readonly=True, required=True),
|
||||
'move_id': fields.many2one('account.move', 'Accounting Entry', readonly=True),
|
||||
}
|
||||
|
||||
|
||||
_defaults = {
|
||||
'journal_id': _get_journal,
|
||||
'journal_id':_get_journal_id
|
||||
}
|
||||
|
||||
def copy(self, cr, uid, id, default=None, context=None):
|
||||
|
|
Loading…
Reference in New Issue