Hello,
i have the following data.xml:
<record id="hd_general" model="videc.helpdesk.product"> <field name="name">Allgemeinfield>
record>
How can i get the Database ID by id="hd_general" ?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hello,
i have the following data.xml:
<record id="hd_general" model="videc.helpdesk.product"> <field name="name">Allgemeinfield>
record>
How can i get the Database ID by id="hd_general" ?
Hi,
Using the self.env.ref you can get the database id of the record.
For example, if the module name is sales_extended and record id is hd_general, then the external id of the record will be sales_extended.hd_general
Now you have to pass this external id to the self.env.ref : self.env.ref('sales_extended.hd_general') which will give the record set of the record, then using .id you can get the database id of the record
self.env.ref('sales_extended.hd_general', raise_if_not_found=False)
Along with it you can pass raise_if_not_found=False not to race the error, when the record is deleted from the db
Thanks
Hi,
You can get the database ID by using the record ID as follows:-
id = self.env.ref('module_name.hd_general').id
instead of module_name add your module_name in which the data file is added
Hope it helps
Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!
Aanmelden