How it works...

In step 1, we added a dependency to the quality_mrp_iot module in the manifest file. The quality_mrp_iot module is part of the Enterprise edition and contains a widget that allows you to request an image from a camera through the IoT Box. This will install the mrp modules, but for the sake of simplicity, we will use quality_mrp_iot as a dependency. If you do not want to use this dependency, you can create your own field widget. Refer to the Creating custom widgets recipe in Chapter 16, Web Client Development, to learn more about widgets.

In step 2, we added the fields required to capture an image from the camera. To capture the image, we need two things: the device identifier and the IP address of the IoT Box. We want to give the user the option to select the camera, so we added a device_id field. The user will choose a camera to capture the image, and based on the selected camera device, we extracted IP and device identifier information through related fields. Based on these fields, Odoo will know where to capture the image, if you have multiple IoT Boxes. We have also added a binary field, picture, to save the image.

In step 3, we added fields in the form view. Note that we used the iot_picture widget on the picture field. We added the ip and identifier fields as invisible fields because we do not want to show them to the user; rather, we want to use them in the picture field options. This widget will add the button in the form view; on clicking the button, Odoo will make a request to the IoT Box to capture the image. The IoT Box will return image data as the response. This response will be saved in the picture binary field.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset