Set default value while creating record from one2many field - odoo

后端 未结 2 588
轻奢々
轻奢々 2021-01-07 13:57

I want to set default value for multiple fields while creating records from one2many field, in that default value will be taken from the parent model.

Odoo M

2条回答
  •  时光说笑
    2021-01-07 14:29

    I got the way how to do it.

    In order to set default values directly while adding records in one2many fields, we need to set values in context with prefix default_field_name : value.

    context="{'default_currency_id' : currency_id, 'default_company_id' : company_id}"

    Note: active_id is not available while you creating new record and with that new record if you provide value in one2many model then active id(s) won't be there. It's only accessible once you save the parent record.

    Solution :

    
        
            
            
            
            
            
             
        
    
    

    If you want to add domain in fields of one2many model and in that you want to use the values of parent model then you can do it by the following way.

    
    

提交回复
热议问题