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

Filter many2one field with another many2one field

By
Uppili Arivukkannu
on 11/7/16, 7:46 AM 146 views

In product.template class the two fields 'name' , 'type'

the 'name' field contains the product name and 'type' is a selection field of product type like stockable product, consumable, etc.

In manufacturing(mrp) module I like to add this 'type' field and based on this 'type' field I need to filter the 'product_id' field( product in mrp).

I simply added the the selection field in mrp

'product_type': fields.selection(            [('product', 'Stockable product'), ('consu', 'Consumable'), ('service', 'Service')], 'Material Type',            required=True,            help="Consumable: Will not imply stock management for this product. \nStockable product: Will imply stock management for this product."),

I also set the domain in 'product_id' field

'product_id': fields.many2one('product.product', 'Material', required=True, readonly=True, states={'draft': [('readonly', False)]}, domain=[('product_id','=','product_type')]),

 Since the filter is based on the 'product_type' this field should be many2one field of field 'type' from product.template.

Already the 'product_id' is the many2one field of 'name' from product.template.

Now how can I call two many2one field from the same class product.template?

I have no plan how to override name_get method


0

Axel Mendoza

--Axel Mendoza--
10308
| 7 7 8
Camaguey, Cuba
--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 an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 11/7/16, 9:30 PM

Hi Uppili

You are doing it wrong with the domain in the field, remove it and try it exactly like this but in the XML view:

<field name="product_type"/>
<field name="product_id" domain="[('type','=', product_type)]"/>

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: 11/7/16, 7:46 AM
Seen: 146 times
Last updated: 11/7/16, 9:30 PM