~mathieu-julius/extra-service-job/trunk-1

« back to all changes in this revision

Viewing changes to service_job_generator/partner_contract.py

  • Committer: Mathieu VATEL
  • Date: 2012-12-27 16:53:20 UTC
  • Revision ID: mathieu@julius.fr-20121227165320-b9uwnc6pyxlwu975
[IMP] - add actions directly on partner contracts and employee contract to generate services

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
class partner_contract(osv.osv):
26
26
    _inherit = "contract.contract"
27
27
    
 
28
    def _get_employee_contract_ids(self, cr, uid, ids, field_name, arg, context=None):
 
29
        res = {}
 
30
        for contract in self.browse(cr, uid, ids, context=context):
 
31
            employee_contract_ids = []
 
32
            for attendance in contract.usual_hours_ids:
 
33
                if attendance.employee_contract_id and attendance.employee_contract_id.id not in employee_contract_ids:
 
34
                    employee_contract_ids.append(attendance.employee_contract_id.id)
 
35
            res[contract.id] = employee_contract_ids
 
36
        return res
 
37
    
28
38
    _columns = {
29
39
        'usual_hours_ids': fields.one2many('resource.calendar.attendance', 'contract_id', 'Usual hours'),
 
40
        'employee_contract_ids': fields.function(_get_employee_contract_ids, method=True, type='many2many', relation='hr.contract', string='Employees contracts'),
30
41
    }
31
42
 
32
43
partner_contract()