[IMP] on_change_contract works for every condition now
bzr revid: psi@tinyerp.co.in-20110330132114-i30h0pk8ho8ikjme
This commit is contained in:
parent
bc6a98c3ab
commit
4bf712c413
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
|
||||
<!-- Email Template Preview -->
|
||||
<record model="ir.ui.view" id="email_template_preview_form">
|
||||
<field name="name">email_template.preview.form</field>
|
||||
|
@ -22,7 +22,7 @@
|
|||
<field name="subject" colspan="8"/>
|
||||
</group>
|
||||
<group col="4" colspan="4">
|
||||
<separator string= "Body(Text)" colspan="2"/>
|
||||
<separator string= "Body(Text)" colspan="2"/>
|
||||
<separator string= "Body(Html)" colspan="2"/>
|
||||
<newline/>
|
||||
<field name="body_text" nolabel="1" colspan="2"/>
|
||||
|
@ -33,7 +33,7 @@
|
|||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="wizard_email_template_preview" model="ir.actions.act_window">
|
||||
<field name="name">Template Preview</field>
|
||||
<field name="res_model">email_template.preview</field>
|
||||
|
|
|
@ -952,19 +952,25 @@ class hr_payslip(osv.osv):
|
|||
if not employee_id:
|
||||
update['value'].update({'contract_id': False, 'struct_id': False})
|
||||
return update
|
||||
|
||||
employee_id = empolyee_obj.browse(cr, uid, employee_id, context=context)
|
||||
ttyme = datetime.fromtimestamp(time.mktime(time.strptime(ddate, "%Y-%m-%d")))
|
||||
if not contract_id:
|
||||
update['value'].update({'struct_id': False})
|
||||
|
||||
if employee_id and context.get('contract', False) == False:
|
||||
employee_id = empolyee_obj.browse(cr, uid, employee_id, context=context)
|
||||
contracts = self.get_contract(cr, uid, employee_id, ddate, context=context)
|
||||
# update['value'].update({
|
||||
# 'struct_id': contracts[0].get('function', False),
|
||||
# 'contract_id': contracts[0].get('id', False)
|
||||
# })
|
||||
else:
|
||||
contracts = [contract_obj.browse(cr, uid, contract_id, context=context)]
|
||||
update['value'].update({'struct_id': contracts[0].struct_id.id})
|
||||
contracts = [contracts[0]]
|
||||
update['value'].update({
|
||||
'struct_id': contracts[0].struct_id.id,
|
||||
'contract_id': contracts[0].id
|
||||
})
|
||||
if context.get('contract', False) == True:
|
||||
if contract_id:
|
||||
employee_id = empolyee_obj.browse(cr, uid, employee_id, context=context)
|
||||
contracts = [contract_obj.browse(cr, uid, contract_id, context=context)]
|
||||
update['value'].update({'struct_id': contracts[0].struct_id.id})
|
||||
else:
|
||||
employee_id = empolyee_obj.browse(cr, uid, employee_id, context=context)
|
||||
contracts = self.get_contract(cr, uid, employee_id, ddate, context=context)
|
||||
update['value'].update({'contract_id': False, 'struct_id': False})
|
||||
|
||||
if not contracts:
|
||||
update['value'].update({
|
||||
|
@ -979,6 +985,7 @@ class hr_payslip(osv.osv):
|
|||
final_total = 0.0
|
||||
all_basic = 0.0
|
||||
for contract in contracts:
|
||||
|
||||
function = contract.struct_id.id
|
||||
sal_structure = []
|
||||
if function:
|
||||
|
@ -1236,16 +1243,16 @@ class hr_payslip(osv.osv):
|
|||
})
|
||||
return update
|
||||
|
||||
def onchange_contract_id(self, cr, uid, ids, contract_id=False, struct_id=False, context=None):
|
||||
if not contract_id:
|
||||
return {}
|
||||
def onchange_contract_id(self, cr, uid, ids, date, employee_id=False, contract_id=False, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
res = {}
|
||||
contract = self.pool.get('hr.contract').browse(cr,uid, contract_id)
|
||||
res.update({
|
||||
'struct_id':contract.struct_id.id
|
||||
})
|
||||
|
||||
return {'value': res}
|
||||
res = {'value':{'line_ids':[], 'holiday_ids':[], 'name':'', 'working_days': 0.0, 'holiday_days': 0.0, 'worked_days': 0.0, 'basic_before_leaves': 0.0, 'basic_amount': 0.0, 'leaves': 0.0, 'total_pay': 0.0}}
|
||||
context.update({'contract': True})
|
||||
if not contract_id:
|
||||
res['value'].update({'struct_id': False})
|
||||
res = self.onchange_employee_id(cr, uid, ids, ddate=date, employee_id=employee_id, contract_id=contract_id, context=context)
|
||||
return res
|
||||
|
||||
hr_payslip()
|
||||
|
||||
|
|
|
@ -228,11 +228,11 @@
|
|||
<field name="arch" type="xml">
|
||||
<form string="Payslip">
|
||||
<group col="6" colspan="4">
|
||||
<field name="employee_id" context="{'employee': True}" on_change="onchange_employee_id(date, employee_id, contract_id, context)"/>
|
||||
<field name="employee_id" on_change="onchange_employee_id(date, employee_id, contract_id)"/>
|
||||
<field name="name"/>
|
||||
<field name="number"/>
|
||||
<field name="date"/>
|
||||
<field name="contract_id" groups="base.group_extended" domain="[('employee_id','=',employee_id)]" on_change="onchange_employee_id(date, employee_id, contract_id)"/>
|
||||
<field name="contract_id" groups="base.group_extended" domain="[('employee_id','=',employee_id)]" on_change="onchange_contract_id(date, employee_id, contract_id)"/>
|
||||
<field name="struct_id" groups="base.group_extended"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
|
|
Loading…
Reference in New Issue