Import images or pdf files from specific path

odoo/addons/base/tests/test_pdf.py
import base64
import re

from odoo.tests.common import TransactionCase
from odoo.tools import pdf
from odoo.modules.module import get_module_resource
import io


    def setUp(self):
super().setUp()
file_path = get_module_resource('base', 'tests', 'minimal.pdf')
self.file = open(file_path, 'rb').read()
self.minimal_reader_buffer = io.BytesIO(self.file)
self.minimal_pdf_reader = pdf.OdooPdfFileReader(self.minimal_reader_buffer)
addons/lunch/models/lunch_product_category.py
import base64
from odoo import api, fields, models
from odoo.modules.module import get_module_resource
    @api.model
def _default_image(self):
image_path = get_module_resource('lunch', 'static/img', 'lunch.png')
return base64.b64encode(open(image_path, 'rb').read())
Views
0 Total Views
0 Members Views
0 Public Views
Actions
0 Likes
0 Dislikes
0 Comments
Share on Social Networks
Share Link
Share by mail

Please login to share this webpage by email.