Skip to Content
Menu
This question has been flagged
4 Replies
10683 Views

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.


Avatar
Discard

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'

Best Answer

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


Avatar
Discard
Author

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 Replies Views Activity
0
Apr 24
397
4
Nov 23
4244
0
Oct 23
377
0
Dec 22
1334
2
Dec 23
17348