Odoo Help


3 Answers



| 7 5 9
Tbilisi, 格鲁吉亚
2015/5/7 上午6:11

Wrong parameter. The many2one field doesn't have parameter "selection". 

Can you explain please, why you don't want to use:

_columns = {
'partner_sup_id': fields.many2one('res.partner', 'Select Supplier 2 ', domain=[('supplier','=',True), ('is_company','=',True)),
you can also set domain in the XML, if you like to have domain filter only in the particular page.


if you want to limit displayed columns(fields) to the 'name' field in the selection(you seem to try this in your function), then you've to achieve it with custom view (treeview) for this model.


Axel Mendoza

--Axel Mendoza--
| 8 8 10
Camaguey, 古巴
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full-time employee trying to understand what to do and how

Reach me at aekroft@gmail.com

Axel Mendoza
2015/7/10 下午1:25

You can use any of the provided Options here but the final adjustment is that you need to set the widget selection for the field in your xml view definition. For example:

#in your .py  

_columns = {

    'partner_sup_id': fields.many2one('res.partner', 'Select Supplier 2 ', domain=[('supplier','=',True), ('is_company','=',True)),



#in your xml

<field name="partner_sup_id" widget="selection">


Techno-Functional Associate with 7+ years of experience in Odoo (formerly known as OpenERP).

2015/5/7 上午11:20

Well if you don't want to use Domain / Widget...

Then you can try with either of these options

Option 1:

Define a field as Selection, instead of Many2One, along with a selection to achieve your requirement...

Coming to your Requirement:

def _get_partner_sup(self, cr, uid, context=None):

obj = self.pool.get('res.partner')

ids = obj.search(cr, uid, [('supplier','=',True), ('is_company','=',True)])

res = obj.read(cr, uid, ids, ['name', 'id','email'], context)

res = [(r['id'], r['name']) for r in res]

return res

_columns = {

'partner_sup_id': fields.Selection(selection=_get_partner_sup),


Option2: If your intention is just not to provide Create/Edit option to the users, then in XML, against that fields just "options={'no_create':True}", by doing this also, you can achieve the same...

Ask a Question
Keep Informed
2 follower(s)
About This Community

This platform 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.

Odoo Training Center

Access to our eLearning platform and experience all Odoo Apps through learning videos, use cases and quizzes.

Test it now