fiscal_id = fields.Many2one('account.fiscalyear', 'Financial Year',default= '2020-2021')
I want default value as 2020-2021 in many2one field but i don't know how to assign the default value??
fiscal_id = fields.Many2one('account.fiscalyear', 'Financial Year',default= '2020-2021')
I want default value as 2020-2021 in many2one field but i don't know how to assign the default value??
Kenly
On
You can use a function to search for the default record using the current date and return the corresponding record.
In the following example we return the first record found and set it as a default value for fiscal_id field.
@api.model
def _get_default_fiscalyear(self):
return self.env['account.fiscalyear'].search([], limit=1)
fiscal_id = fields.Many2one('account.fiscalyear', 'Financial Year',default= _get_default_fiscalyear)
Copyright © 2021 Jogjafile Inc.
you could use default
lambdafuntion as following:in this case you need an
xml idwhich will create the data record from xml file as following:please note that you may need to map the xml data correctly according to your model definition.
don't hesitate to let us know if it is working