@http.route('/api/company', type='http', auth='none', cors="*", csrf=False, website=False, methods=['GET'])
def get_company_info(self):
# Fetch the company record
company = request.env['res.company'].sudo().search([], limit=1) # Get the first company record
# Check if a company is found
if not company:
# Return the response as JSON with 404 status
return Response(
json.dumps({'error': 'No company found.'}),
status=404,
content_type='application/json'
)
here is my api how i convert here my logo in base64 can anyone help me
# Convert logo to Base64 string if it exists
logo_url = None
if company.logo:
try:
# Convert binary data to Base64 and prefix with 'data:image/png;base64,'
logo_base64 = base64.b64encode(company.logo).decode('utf-8')
logo_url = f"data:image/png;base64,{logo_base64}"
except Exception as e:
# Log the error for debugging purposes
_logger.error(f"Error encoding logo to base64: {e}")
logo_url = None # Set logo to None in case of an error
# Prepare the response data
response_data = {
'company_name': company.name,
'company_logo': logo_url # Base64-encoded logo URL or None
}
# Return the response as JSON with 200 status
return Response(
json.dumps(response_data),
status=200,
content_type='application/json'
)
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Akuntansi
- Inventaris
- PoS
- Project
- MRP
Pertanyaan ini telah diberikan tanda
11479
Tampilan
Menikmati diskusi? Jangan hanya membaca, ikuti!
Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!
Daftar