mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[FIX]14.0-pms_api_rest: fix pre-commit
This commit is contained in:
@@ -2,18 +2,24 @@ 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),
|
||||
])
|
||||
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
|
||||
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 ''
|
||||
return result if result else ""
|
||||
|
||||
Reference in New Issue
Block a user