I am trying to set default value from 'on delivery order'
to 'on demand'
in create invoice field in quotations other information tab in odoo. But it's not setting as default value to on demand. Can anyone help me out how to set default value of create invoice in 'on demand'.
Code:
'order_policy': fields.selection([
('manual', 'On Demand'),
('picking', 'On Delivery Order'),
('prepaid', 'Before Delivery'),
],
'Create Invoice',
required=True,
readonly=True,
states={
'draft': [('readonly', False)],
'sent': [('readonly', False)]
},
),
Results
_defaults = {
'order_policy': 'manual',
}
You can do it by two way.
1). As @KHELILI Hamza suggested you should redefine that field and set default value.
2). You need to override default_get method.
Solution:
def default_get(self, cr, uid, fields, context=None):
res = super(class_name, self).default_get(cr, uid, fields, context=context)
res.update({'order_policy': 'manual'})
return res
If you want to set the default value conditionally then you can manage in that code easily.