Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
5049 Zobrazení

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 :)

Avatar
Zrušit
Nejlepší odpověď

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.

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
0
pro 24
9625
3
zář 24
21891
5
pro 24
53205
4
čvc 24
10699
7
srp 23
11118