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

Urgent, i need copy value from <field name="item_id"/> into another field.

On_change .... don't work :) because it require an action. I would like to copy data whilst record is loaded.


อวตาร
ละทิ้ง

What is the other field you intend to copy data to, and why. Also, I think if you saved the record with a specific value in the target field, why you need to override it again. I think this would be a function field that reads a value from specific other fields and format the result by its own function. Some explanation is needed to be able to give more accurate reply.

I suggest using a function field

I'm sorry, I converted my answer to a comment to put a new answer, and your comments posted to the last answer has been lost. To summarize your reply, you needed to get the item_id.id in a separate field, and you're going to use this field to add it in a link and when clicking it you'll open a file that has the name : 'the number of the item_id field'

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

Here is my solution using a function field:

You have the field item_id, create a new field 'item_id_number' 

def _item_id_no(self, cr, uid, ids, name, args, context=None):
    res = {}
    for line in self.browse(cr, uid, ids, context=context):
        res[line.id]=line.item_id.id
    return res


_columns = {
....
'item_id_number':fields.function(_item_id_no,type='integer',string='Item Id #',),
....
}

Then add the field 'item_id_number' to the view as

    ....        
    <field name="item_id_no"/>
....

That's all. I hope this would be helpful


อวตาร
ละทิ้ง
ผู้เขียน

By any chance ... version working on 8.0 new API ?

It should, after the required modification needed by the new API. I'm still using the old coding style under Odoo 8.0, and it works fine

Moreover, if you checked all modules that imported from OpenERP 7 to Odoo 8 you'll find that their code is still as it is with no any changes. New APIs are applied to the code written newly for Odoo 8

Related Posts ตอบกลับ มุมมอง กิจกรรม
0
เม.ย. 24
1953
4
พ.ย. 23
6053
0
ต.ค. 23
1799
0
ธ.ค. 22
2696
2
ธ.ค. 23
19472