I am trying to do something really simple here. But I can't find anything in the docs, or on help.openerp.com
I added a field (which is a many2one relationship with another table) on a form. This created a dropdown menu where can either pick or create new values.
If you click on "Create and Edit", this will open a new window, where you have a field that you can fill in, and save. But the label for this field is "unknown". Someone explained to me that I need to create a view for this form.
So I did, I created this view, at first, I inherited from another form (the users' one), but it throwing me error, moaning about missing fields. My question is: What should I inherit from?
The process works without defining my own view for this, but whenever I pick an existing record, create a new one, the value doesn't appear, but instead I have the name of the table, and its identifier as a link to the record (that will open a new window if I recall correctly). Is there a way to do a lookup instead, and display the value?
Here the code:
counties_view.xml
hubclub.counties.form hubclub.counties
extra-attributes.xml
res.users.form res.users
__openerp__.py
# -*- coding: utf-8 -*-
{
'name': 'Hubclub module',
'version': '1.0',
'author': 'Openapp',
'category': 'Tools',
'depends': ['base', 'point_of_sale'],
'data': ['extra-attributes.xml', 'counties_view.xml'],
'demo': [],
'installable': True,
}
hubclub_module.py
# -*- coding: utf-8 -*-
from openerp.osv import fields, osv
class hubclub_counties(osv.osv):
_name = 'hubclub.counties'
_columns = {
'county': fields.text(),
}
_sql_constraints = [('county_uniq', 'unique(county)',
'Country already exists')]
# User
class res_users(osv.osv):
_name = 'res.users'
_inherit = 'res.users'
_columns = {
'county_id': fields.many2one('hubclub.counties', 'County'),
}
_defaults = {
}
res_users()
hubclub_counties()
↧