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

Store char in field ?

v7
By
Nanda Kanoko
on 7/10/13, 7:57 AM 930 views

Please tell me how to store char in a field so i can relate it to other field in other model but same module

My py :

from osv import fields, osv
import time

class notebook_project(osv.osv):
    _name = "notebook.project"
    _description = "Notebook Project ID"
    _columns = {
        'project_name' : fields.many2one('project.project', 'Project Name'),
        'project_name_id' : fields.char('Project ID', size=32, required=True, store=True),
        }


notebook_project()

class notebook_member(osv.osv):
    _name = "notebook.member"
    _description = "Notebook Member of Project"
    _columns = {
        'project_member' : fields.many2one('hr.employee', 'Member Name',required=True, store=True),
        'project_id' : fields.related('project_name_id', 'project_id', type='many2one', relation='notebook.project', string='Project ID', store=True, readonly=True',),
        }


notebook_member()

I need the value of project ID ( char ) to be stored so I can call it on other model ( in notebook.member , from notebook.project ) . Thanks in advance :)

0
Alessandro Pillan
On 7/12/13, 6:27 AM

You need to set the attribute "store" only on functional fields and only if you need to search on them. Fields like char, many2x are already stored. At the moment I can't see any relation between notebook_project and notebook_member so you can't get the project_name_id using a related field.

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

0 follower(s)

Stats

Asked: 7/10/13, 7:57 AM
Seen: 930 times
Last updated: 3/16/15, 8:10 AM