跳至內容
選單
此問題已被標幟
4 回覆
11587 瀏覽次數

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

相關帖文 回覆 瀏覽次數 活動
0
4月 24
1957
4
11月 23
6060
0
10月 23
1802
0
12月 22
2707
2
12月 23
19487