I have a data of some photos and i need to enter them on my module to be displayed on a many2one field, I need to know How i can add the path of some photos to uploaded automatically on the xml,
here is my XML data file:
<record model="employee.bilds_properties" id="employee_bilds_properties_1">
<field name="photo"> </field>
DeactivableMixin, ModelSQL, ModelView):
__name__ = 'employee.bilds_properties'
_order_name = 'rec_name'
photo = fields.Binary('Photo')
name = fields.Char('Name')
def get_rec_name(self, name):
How i can add the path of the photos in XML file that will be exist under the module name to be display it automatically on a many2one field?
I guess you could use CDATA to fill the value of the field with binary data (but there is a risk that the binary contains the CDATA closing).
Indeed the best would be to implement a type binary in
convert.py which will decode the content as base64.
can you give me more details about how i can implement a type binary in
convert.py which will decode the content as base64. Is there any example exit in one of the standard modules i can follow?
I can not without implemented it
convert.py the code loads the XML file.
What you’re looking for is how to handle the different field. It happens there:
You’ll see that we get the field of the model on this line:
You can then use this information to put a flag on the
RecordTagHandler so that when the parser enters
endElement (https://foss.heptapod.net/tryton/tryton/-/blob/01e788d9b71f199073bfcb11491b91b3aa7db709/trytond/trytond/convert.py#L293) it knows that the content of value is a base64 encoded binary. And thus there you can do the transformation. Do not forget to reset the flag.
There’s probably a lot of things I haven’t though about but this is an outline on how to tackle this task.