Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
4 Risposte
11583 Visualizzazioni

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
Abbandona

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'

Risposta migliore

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
Abbandona
Autore

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

Post correlati Risposte Visualizzazioni Attività
0
apr 24
1957
4
nov 23
6060
0
ott 23
1800
0
dic 22
2704
2
dic 23
19486