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
7559 Zobrazení

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


Avatar
Zrušit
Nejlepší odpověď

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)]"/>
Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
2
dub 21
11386
0
srp 17
4854
6
srp 15
8654
2
čvc 15
4843
0
bře 15
4223