~unifield-team/unifield-wm/us-31

« back to all changes in this revision

Viewing changes to msf_homere_interface/hr.py

  • Committer: jf
  • Date: 2015-02-19 16:57:04 UTC
  • mfrom: (2395.3.1 unifield-wm)
  • Revision ID: jfb@tempo-consulting.fr-20150219165704-1jb6up3govohc0b1
US-94 [FIX] expat employee creation from form, identification id mandatory but no saved
lp:~unifield-team/unifield-wm/us-94b

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
            res[e] = allowed
50
50
        return res
51
51
 
 
52
    def _get_ex_allow_edition(self, cr, uid, ids, field_name=None, arg=None,
 
53
        context=None):
 
54
        """
 
55
        US-94 do not allow to modify an already set identification id for expat
 
56
        """
 
57
        res = {}
 
58
        if not ids:
 
59
            return res
 
60
 
 
61
        if not context:
 
62
            context = {}
 
63
        if isinstance(ids, (int, long)):
 
64
            ids = [ids]
 
65
        for self_br in self.browse(cr, uid, ids, context=context):
 
66
            can_edit = True
 
67
            if self_br.employee_type == 'ex' and self_br.identification_id:
 
68
                can_edit = False
 
69
            res[self_br.id] = can_edit
 
70
        return res
 
71
 
52
72
    def onchange_type(self, cr, uid, ids, e_type=None, context=None):
53
73
        """
54
74
        Update allow_edition field when changing employee_type
83
103
        'destination_id': fields.many2one('account.analytic.account', string="Destination", domain="[('category', '=', 'DEST'), ('type', '!=', 'view'), ('state', '=', 'open')]"),
84
104
        'allow_edition': fields.function(_get_allow_edition, method=True, type='boolean', store=False, string="Allow local employee edition?", readonly=True),
85
105
        'photo': fields.binary('Photo', readonly=True),
 
106
        'ex_allow_edition': fields.function(_get_ex_allow_edition, method=True, type='boolean', store=False, string="Allow expat employee edition?", readonly=True),
86
107
    }
87
108
 
88
109
    _defaults = {
91
112
        'homere_id_staff': lambda *a: 0.0,
92
113
        'homere_id_unique': lambda *a: '',
93
114
        'gender': lambda *a: 'unknown',
 
115
        'ex_allow_edition': lambda *a: True,
94
116
    }
95
117
 
96
118
    def _check_unicity(self, cr, uid, ids, context=None):