Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to get value from DB using Odoo(ver. 9-10) ORM

By
Andrew
on 10/27/16, 4:51 AM 148 views

Hi everyone!
I need to get value from Database WITHOUT using SQL in python script.
I was tried to get parent_id field from model 'ir.ui.menu' and set a new value for this field, but unsuccessfully.
Can someone help me with this?

0
yousif Mobark
On 10/27/16, 5:38 AM

just use the ORM method write.

e.g:-

    rec=self.env['ir.ui.menu'].browes(id) #browes take the record id

     rec.parent_id=Value

    or

   rec.write({'parent_id':Value})

Thank you!

And, maybe you know, how to use this in class constructor?

I try to use this

db = sql_db.db_connect('main-db')

cr = db.cursor()

env = api.Environment(cr, SUPERUSER_ID, {})

model = env['ir.ui.menu'].browse(90)

print model.parent_id

And getting error 'ir.ui.menu' object has no attribute 'id'"

Now this code working with decorator '@api.onchange('field')', but I want execute him one time and without any actions on front-end (like changing 'field' like now)

Andrew
on 10/27/16, 6:41 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 10/27/16, 4:51 AM
Seen: 148 times
Last updated: 10/27/16, 6:20 AM