2016-09-21 52 views
0

我想在試用期結束時讓員工自動停用。我的代碼下面有 (原諒我的英文不好)。如何在openerp 7的特定日期刪除員工?

def inctivate_employee(self, cr, uid, ids, context=None): 
    emp_id = self.browse(cr, uid, ids)[0].employee_id.resource_id.id 
    the_date = self.pool.get('hr.contract').browse(cr, uid, contract_id, context=context).trial_date_end 
    self.pool.get('resource.resource').write(cr, uid, emp_id, { 
     'active': False,}) # here must be something define the date of the action 

    return True 

回答

0

您可以創建一個調度的動作每天要檢查trial_date_end:

class hr_contract(models.Model): 
    _inherit = 'hr.contract' 

    @api.model 
    def employee_end_trial(self): 
     today = fields.Date.today() 
     contract_obj = self.env['hr.contract'] 
     contracts = hr_contract.search([('trial_date_end', '=', today)]) 

     # Add your code here 
+0

這是有用的? – Zety

相關問題