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

Hi, I have a char field name home_number and a Boolean field same_as_above and a char field name present_number, I was looking foe something, as I click the same_as_above field I want to copy the above value i.e home_number to the char field present_number.

Can I achieve this in Openerp V7 in views(XML). ..?

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Okay I got the answer. In .py file

class MyFields(osv.osv):
    _name='my.fields'
    _columns={
         'home_number':fields.char('Home Number',size=100),
         'same_as_above':fields.boolean(),
         'present_number':fields.char('Present Number',size=100)
    }
def onchange_same_as_above(self,cr, uid, ids,same_as_above,home_number,context=None):
    if same_as_above:
        return {'value':{'present_number':home_number,}}
    return {'value':{}}

In XML file

<field name="home_number"/>
<field name="same_as_above" on_change="onchange_same_as_above(same_as_above,present_number)"/>
<field name="present_number"/>
อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

You want to use the boolean field to behave like a button?

To answer your question: No you cannot do this in XML (only). You need to write some code, and link that code to the field (probably on_change_<name field="">). The linking is done in XML, but the code in your custom python module.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Thanks for reply, I want when boolean field is True, then copy the value . In on_change I can use the values from the database , but I cant use the values that are on views , before saving the form ....

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
เม.ย. 15
20705
0
ม.ค. 24
2594
How to copy one2many field in odoo แก้ไขแล้ว
1
ก.ย. 21
8367
2
ก.ย. 18
14510
1
เม.ย. 17
5252