I have this URL http://mydomain/hr-attendance/auto-change-qrcode on my app. Then when I opened the URL, I will se an image that showing a QRCode.
When I look at the page source, I found something like this:
There is a img tag inside, which is like this:
My question is not about the QRCode, but I want to ask, how to get the src link of the image (just one image on the page) from a page using URL?
This my snippet of code from where I want to get the data: The Odoo Pyton code that show make the link available:
@http.route('/hr-attendance/auto-change-qrcode', auth='user', type='http')
def auto_change_qrcode(self):
hr_employee_qrcode_ids = secrets.choice(
request.env['hr.employee.qrcode'].sudo().search([('state', '=', 'unused')], limit=1))
secret = hr_employee_qrcode_ids.auto_change_qrcode()
return http.request.render('aqur_attendance.attendance_qrcode', {'secret': secret})
And the is the snippet code of my javascript where I want to fetch the img src URL.
start: function () {
var self = this;
self.session = Session;
var def = this._rpc({
model: 'hr.employee.qrcode',
method: 'search_read',
args: [[['id', '=', 122003]]],
})
.then(function (hremplpoyeeqrcode){
self.qrcode_secret = hremplpoyeeqrcode[0]['secret'];
self.qr_code_url = self.session.url('/hr-attendance/auto-change-qrcode');
self.$el.html(QWeb.render("AqurAttendanceQRCodeKioskMode", {widget: self}));
self.start_clock();
});
setInterval(function () {
$('.View').fadeOut('slow', function() {
$(this).load('/echo/json/', function() {
$(this).fadeIn('slow');
});
});
}, 3000); // refresh every 3000 milliseconds
},