Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
5117 มุมมอง

Hello Guys!!!

I have a field defined with function type.

Here is the code:

    def _get_prime_code(self, cr, uid, ids, field_name, arg, context=None):

        res = {}

        obj_contract = self.pool.get('hr.contract')

        for emp in self.browse(cr, uid, ids, context=context):

            contract_ids = obj_contract.search(cr, uid, [('id', '=', emp.employee_id.contract_id.id)], context=context)

            if contract_ids:

            vals = obj_contract.read(cr,uid,contract_ids,['id','adjustment_prime'],context=context)

            if vals[0]['adjustment_prime']:

                res[emp.id] = vals[0]['adjustment_prime'][0]

            else:

                res[emp.id] = False

            print res

        return res


and the field:

         'adjustment_prime_code':fields.function(_get_prime_code, string="Code de prime de compensation", type='integer', relation="hr.contract", help="Code de prime de compensation"),

the problem is that nothing appears in the field in the view.

DId i a mistake.

Can anyone help please.

อวตาร
ละทิ้ง

Why are you using type='integer'? This is a many2one field

ผู้เขียน

i have changed it to many2one but it still not working

Related Posts ตอบกลับ มุมมอง กิจกรรม
0
มิ.ย. 15
3053
2
เม.ย. 21
4895
1
มี.ค. 15
4181
2
ก.ย. 23
9833
1
ก.พ. 22
6845