Closed alvinkg closed 2 years ago
demo data cannot load: in the end I reinstalled the app.
Also I replaced my files with the provided files.
Finally I removed the extra demo in the manifest file.
I was planning to activate the config file demo key but was not needed.
In this recipe, we will add a different type of data from the XML file. We'll add a book and an author as demonstration data. We'll also add a well-known publisher as normal data in our module. Add a file called data/data.xml to your manifest, in the data section. element can contain a value as simple text in the case of scalar values. If you need to pass the content of a file (to set an image, for example), use the file attribute on the element and pass the file's name relative to the add-ons path.
For setting up references, there are two possibilities. The simplest is using the ref attribute, which works for many2one fields and just contains the XML ID of the record to be referenced. For one2many and many2many fields, we need to use the eval attribute. This is a general-purpose attribute that can be used to evaluate Python code to use as the field's value; think of strftime('%Y-01-01') as an example to populate a date field. X2many fields expect to be populated by a list of three tuples, where the first value of the tuple determines the operation to be carried out. Within an eval attribute, we have access to a function called ref, which returns the database ID of an XML ID given as a string. This allows us to refer to a record without knowing its concrete ID, which is probably different in different databases
In step 2, the