Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
5240 Vistas

I'm developing new module("patient.patient") that register patient of hospital and when i tried to upload a image in image section of the form, a bug which is "Could not display the selected image" appears all the time but in Employees module, the image field which is written same method as well as my currently developing module ("patient.patient") works totally fine. I dont understand why? and how to tackle this bug. Please help me!!!.

import base64
import itertools
from werkzeug import url_encode
from odoo import models, fields, api
from odoo.modules.module import get_module_resource



class Patient(models.Model):
_name = 'patient.patient'
_description = 'Patient'
_mail_post_access = 'read'
_inherit = ['image.mixin']

@api.model
def _default_image(self):
image_path = get_module_resource('patient', 'static/src/img', 'default_image.png')
return base64.b64encode(open(image_path, 'rb').read())

name = fields.Many2one('res.partner',string='Patients Name', required=True)
image_1920 = fields.Image(default=_default_image, string="Image", max_width=1920, max_height=1920)


Avatar
Descartar
Mejor respuesta

Hello. I had this same exact error and the issue causing it was that I had made the name field in my model a Many2one relation with another model. It got fixed when i removed the relation from the name field and made a different cgpa_id field for it. So kindly check if the name field in your model is a relational field.
Hope it helps :)

Avatar
Descartar