From 60ad4cdfe6f18419116c8b479eada9f91c19604f Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Thu, 21 Apr 2011 12:52:56 +0530 Subject: [PATCH] [IMP] Payroll_account: improved views, on the other state of draft make fields on payslip to readonly=true bzr revid: mra@mra-laptop-20110421072256-la7412gwr7osf0hj --- addons/hr_payroll/hr_payroll.py | 2 +- addons/hr_payroll_account/hr_payroll_account.py | 8 ++++---- addons/hr_payroll_account/hr_payroll_account_view.xml | 7 ++++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index 45826254df5..9b20e048bcf 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -226,7 +226,7 @@ class hr_payslip(osv.osv): return result _columns = { - 'struct_id': fields.many2one('hr.payroll.structure', 'Structure', help='Defines the rules that have to be applied to this payslip, accordingly to the contract chosen. If you let empty the field contract, this field isn\'t mandatory anymore and thus the rules applied will be all the rules set on the structure of all contracts of the employee valid for the chosen period'), + 'struct_id': fields.many2one('hr.payroll.structure', 'Structure', readonly=True, states={'draft': [('readonly', False)]},help='Defines the rules that have to be applied to this payslip, accordingly to the contract chosen. If you let empty the field contract, this field isn\'t mandatory anymore and thus the rules applied will be all the rules set on the structure of all contracts of the employee valid for the chosen period'), 'name': fields.char('Description', size=64, required=False, readonly=True, states={'draft': [('readonly', False)]}), 'number': fields.char('Reference', size=64, required=False, readonly=True, states={'draft': [('readonly', False)]}), 'employee_id': fields.many2one('hr.employee', 'Employee', required=True, readonly=True, states={'draft': [('readonly', False)]}), diff --git a/addons/hr_payroll_account/hr_payroll_account.py b/addons/hr_payroll_account/hr_payroll_account.py index 231a8b8d837..af7a911bf31 100644 --- a/addons/hr_payroll_account/hr_payroll_account.py +++ b/addons/hr_payroll_account/hr_payroll_account.py @@ -213,15 +213,15 @@ class hr_payslip(osv.osv): _description = 'Pay Slip' _columns = { - 'journal_id': fields.many2one('account.journal', 'Expense Journal'), - 'bank_journal_id': fields.many2one('account.journal', 'Bank Journal'), + 'journal_id': fields.many2one('account.journal', 'Expense Journal',states={'draft': [('readonly', False)]}, readonly=True), + 'bank_journal_id': fields.many2one('account.journal', 'Bank Journal', states={'draft': [('readonly', False)]}, readonly=True), 'move_ids':fields.one2many('hr.payslip.account.move', 'slip_id', 'Accounting vouchers'), 'move_line_ids':fields.many2many('account.move.line', 'payslip_lines_rel', 'slip_id', 'line_id', 'Accounting Lines', readonly=True), 'move_payment_ids':fields.many2many('account.move.line', 'payslip_payment_rel', 'slip_id', 'payment_id', 'Payment Lines', readonly=True), - 'period_id': fields.many2one('account.period', 'Force Period', domain=[('state','<>','done')], help="Keep empty to use the period of the validation(Payslip) date."), + '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."), 'account_move_ids': fields.many2many('account.move', 'payslip_move_rel', 'slip_id', 'move_id', 'Accounting Entries', readonly=True), } - + def onchange_contract_id(self, cr, uid, ids, date_from, date_to, employee_id=False, contract_id=False, context=None): contract_obj = self.pool.get('hr.contract') res = super(hr_payslip, self).onchange_contract_id(cr, uid, ids, date_from=date_from, date_to=date_to, employee_id=employee_id, contract_id=contract_id, context=context) diff --git a/addons/hr_payroll_account/hr_payroll_account_view.xml b/addons/hr_payroll_account/hr_payroll_account_view.xml index 8ff199fb466..94af7526192 100644 --- a/addons/hr_payroll_account/hr_payroll_account_view.xml +++ b/addons/hr_payroll_account/hr_payroll_account_view.xml @@ -49,6 +49,7 @@ + @@ -152,12 +153,12 @@ - - - + + +