Te lo posto, ma non è che ci sia molto altro rispetto a quello che già hai visto
from osv import osv
from osv import fields
import pdb
class hr_employee_skill(osv.osv):
_name = "hr.employee.skill"
_description = "Skill Risorsa"
def _get_skill_complete(self, cr, uid, ids, field_name, arg, context=None):
res = {}
for record in self.browse(cr, uid, ids):
skill = record.skill.complete_name
level = record.level.x_name
complete_skill = (skill + " " + level)
res[record.id] = complete_skill
return res
def unlink(self, cr, uid, ids, context=None):
pdb.set_trace()
state = self.read(cr, uid, ids, ['is_primary'], context=context)
for t in state:
if t['is_primary']:
raise osv.except_osv(_('Azione non consentita!'), _('Non puoi eliminare lo skill primario della risorsa.'))
else:
super(hr_employee_skill, self).unlink(cr, uid, ids, context)
return True
_columns = {
'level': fields.many2one('x_senioritylevel', 'Seniority', select=True, required=True),
'skill': fields.many2one('hr.employee.category', 'Skill', select=True, required=True),
'name': fields.function(_get_skill_complete, method=True, type="char", string="Skill Primario", store=True),
#'employee_ids': fields.many2many('hr.employee', 'employee_skills_rel', 'skill_id', 'emp_id', 'Risorse', store=True),
'employee_id': fields.many2one('hr.employee', 'Risorsa', store=True, required=True, select=True),
'is_primary': fields.boolean('Skill primario')
}
_order = "skill"
hr_employee_skill()