How to put url inside QR in odoo report - odoo

I want to create a QR that redirects to a url with the following code:
<img t-att-src="'/report/barcode/?type=%s&value=%s&width=%s&height=%s' % ('QR', doc.id, 600, 50)" style="width:30px;height:30px;"/>
I want the value be like this:
https://example.com/doc.id
I idea how to concat 2 strings? Thanks!!

You can just concat them right there:
<img t-att-src="'/report/barcode/?type=%s&value=%s&width=%s&height=%s' % ('QR', my_url + str(doc.id), 600, 50)" style="width:30px;height:30px;"/>
my_url + str(doc.id) could also be a lot of other things, but it's python code, because t-att-src will be evaluated later.
Biggest concerns and things i can't answer right now:
how to handle an url within an url, look here
how will this escaped url work with Odoo's barcode generator
where to get the url from: can it be hardcoded or do you want to get it dynamically on conditions?

There are apps that add the QR code of the document URL in the pdf report.
When you scan the QR code, it will redirect you to a specific document.
Here are the apps: https://apps.odoo.com/apps/modules/browse?search=ehcs_qr_code

Related

Google Custom Search Engine - Edit the URLs in SERP

Good evening, I'm working with Google Custom Search Engine: https://cse.google.it/cse/ and I need to add, only for some URLs (in total 10 URLs) a parameter at the end of each search results URL. For example: if the domain is www.dominio-test.com then the URL to show is www.dominio-test.com/123456 the CSE searches on the web without restriction.
The code I use is the following:
<script async src = "https://cse.google.com/cse.js cx=014431187084467459449:v2cmjgvgjr0"> </script>
<div class = "gcse-search"> </div>
I thought of proceeding with reading the DOM with getElementsByClassName (), extracting the content and adding it to a variable, at this point add the if / else / replace controls and output again.
But I don't know how to proceed, can you please support me?
Thanks and good job
Search Element callbacks might work for you: https://developers.google.com/custom-search/docs/element#callbacks

Extract portion of HTML from website?

I'm trying to use VBA in Excel, to navigate a site with Internet explorer, to download an Excel file for each day.
After looking through the HTML code of the site, it looks like each day's page has a similar structure, but there's a portion of the website link that seems completely random. But this completely random part stays constant and does not change each time you want to load the page.
The following portion of the HTML code contains the unique string:
<a href="#" onClick="showZoomIn('222698519','b1a9134c02c5db3c79e649b7adf8982d', event);return false;
The part starting with "b1a" is what is used in the website link. Is there any way to extract this part of the page and assign it as a variable that I then can use to build my website link?
Since you don't show your code, I will talk too in general terms:
1) You get all the elements of type link (<a>) with a Set allLinks = ie.document.getElementsByTagName("a"). It will be a vector of length n containing all the links you scraped from the document.
2) You detect the precise link containing the information you want. Let's imagine it's the 4th one (you can parse the properties to check which one it is, in case it's dynamic):
Set myLink = allLinks(3) '<- 4th : index = 3 (starts from zero)
3) You get your token with a simple split function:
myToken = Split(myLink.onClick, "'")(3)
Of course you can be more synthetic if the position of your link containing the token is always the same, like always the 4th link:
myToken = Split(ie.document.getElementsByTagName("a")(3).onClick,"'")(3)

Access the image URL of a product

I am trying to get the image URL inside Edit Theme Files -> product.html
I already have some values like:
{{product.title}}, that gives me "Product name"
{{product.url}}, that gives me the URL
etc...
but no matter what i try, i can't get the URL.
The closest I got was using this: {{product.main_image.data}}
which gives me something like this:
https://cdn3.bigcommerce.com/s-8lxh1/images/stencil/%7B:size%7D/products/882/1700/RAM_VB_193_SW1__09586.1463668242.jpg?c=2
But that does not produce a image link.
Would appreciate any help or insights.
Thanks in advance!
The string that you're returning doesn't work because there's a "size" placeholder embedded in the URL. You can use Stencil's getImage Handlebars helper to specify the image dimensions and return a working URL:
{{getImage product.main_image.data "thumbnail"}}
The "thumbnail" string specifies an image size that exists in your theme settings. You can also specify a numeric size, like "200x200". Check out the docs here

Netsuite PDF Templating: get number of pages as attribute

I am templating pdfs in Netsuite using freemarker and I want to display the footer only on the last page. I have been doing some research, but couldn't find a solution (since looks like the environment does not allow me to include or import libs), so I thought that just comparing the number of the page with the total pages in an if tag would be a nice and easy workaround. I already know how to display the numbers by using the <pagenumber/> and <totalpages/> tags, but still cannot get them as values so I can use them like this:
<#if (pagenumber == totalpages) >
... footer html...
</#if>
Any ideas of how or where can I get those values from?
The approach you are trying won't work, because you are mixing BFO and Freemarker syntax. Netsuite uses two different "engines" to process PDF Templates. The first step is Freemarker, which merges the record fields with your template and produces an XML file, which is then converted by BFO into a PDF file. The <totalpages/> element is meaningless to Freemarker, as it is only converted into a number by BFO later.
Unfortunately, the ability to add a footer to only the last page of a document is currently a limitation of BFO, as per the BFO FAQ:
At the moment we do not have a facility for explicitly assigning a
footer or header to the last page in a document when the number of
pages is unknown.
You CAN add it after a page break - and put the page break at the end of the body
<pbr footer="nlfooter" footer-height="25%"></pbr>
</body>
The issue here is - on a one page output - you will get 2 pages minimum... it will always ADD a page for the disclaimer / footer...

How to check the number of shares of an url on Google+?

Is there a way to check how many shares of url is done on Google+?
The equivalent from Facebook and Twitter would be:
http://graph.facebook.com/http://stackoverflow.com
and
http://urls.api.twitter.com/1/urls/count.json?url=http://stackoverflow.com
Is there an equivalent on Google+?
Are you looking for this?
https://plusone.google.com/_/+1/fastbutton?url=http://stackoverflow.com
If you are searching for the text value, you can search the following line in the source code of the url:
<div id="aggregateCount" class="Oy">{NUMBER_OF_SHARES}</div>
The following JavaScript will extract the number of shares from the url:
parseInt(document.getElementById('aggregateCount').innerHTML.replace('.',''))