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

I have field selection ,I want to get Id of the selection,Then I save id on field.char .What should I do

Can you help me ?

อวตาร
ละทิ้ง

selection field or one2many field?

ผู้เขียน

i'm sorry . selection is one2many field

คำตอบที่ดีที่สุด

See the below example

In Python:

  _columns = {
            'name': fields.many2one('hr.employee', "Employee", required=True),
            'id_no': fields.char('Wage', size=64),
        }

        def onchange_employee_id(self, cr, uid, ids, employee_id, context=None):
            v = {}
            if employee_id:
                emp_sr = self.pool.get('hr.employee').search(cr, uid, [('id','=',employee_id)], context=context)
                if emp_sr:
                    empt_br = self.pool.get('hr.employee').browse(cr, uid, emp_sr, context=context)[0]
                    v['id_no'] = str(emp_br.id)

            return {'value': v}

In XML:

<field name="name" on_change="onchange_employee_id(name)"/>
<field name="id_no"/>
อวตาร
ละทิ้ง
ผู้เขียน

No,I have selection ,it is many2one .And i have fields char . when form is loaded ,fields char will get id of selection

How you select the value to many2one field while form loading? Do you pass any default value to many2one while form loading?

Related Posts ตอบกลับ มุมมอง กิจกรรม
0
มี.ค. 15
3814
1
ธ.ค. 23
27348
1
มี.ค. 15
4350
1
มี.ค. 15
8310
1
มี.ค. 15
4279