mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
26 lines
744 B
Python
26 lines
744 B
Python
from odoo.http import request
|
|
|
|
|
|
def url_image_pms_api_rest(model, record_id, field):
|
|
rt_image_attach = (
|
|
request.env["ir.attachment"]
|
|
.sudo()
|
|
.search(
|
|
[
|
|
("res_model", "=", model),
|
|
("res_id", "=", record_id),
|
|
("res_field", "=", field),
|
|
]
|
|
)
|
|
)
|
|
if rt_image_attach and not rt_image_attach.access_token:
|
|
rt_image_attach.generate_access_token()
|
|
result = (
|
|
request.env["ir.config_parameter"].sudo().get_param("web.base.url")
|
|
+ "/web/image/%s?access_token=%s"
|
|
% (rt_image_attach.id, rt_image_attach.access_token)
|
|
if rt_image_attach
|
|
else False
|
|
)
|
|
return result if result else ""
|