About Website URL Shortener
Website URL Shortener is an Odoo app that assigns and manages short URLs for Odoo website links. URL shortening is a well-known methodology to cope with too long and ugly-looking web addresses. The app introduces this technique in Odoo by allowing website editors to manually or automatically generate, control, and administrate short URLs for any Odoo web links.
Each short URL peers with an automatic QR code image that might be downloaded, shared, or added to Odoo website pages.
Configure the rules for automatically creating short URLs based on iterator and token (for example, /s/12 and /s/rh72ko) or apply your own keywords (for example, /s/desk, /s/best-chairs).
Have as many short links for a single address as needed for various purposes. Share one link on Facebook, another - on Twitter, and a special one - for specific partners. Then, count redirects for each source.
Use the URL shortener right while customizing the website or in Odoo's advanced backend. Make a link soon expired or forever-lasting. Update the token at any moment or archive a link if it is no longer valid.
The app introduces two special website snippets that might be added to any Odoo website's inner content. The snippet 'Short URLs' would find or create a short URL right when a visitor opens a page. The snippet 'Short URL QR Code' would find or generate a QR code right when a visitor opens a page.
Developers might use the app to find or create a short URL for a target website address by applying a single Python method.
Automatic or custom URLs
Website snippet
Multi channels control
Available for scripts and custom add-ons
Short URLs Configuration
The module lets generate the URL links automatically. The functionality of the module can be accessed either from the backend website configuration or when customizing a website from the frontend.
You can configure the way, your short links are generated. There are 2 generation methods, that you can choose from. The rules for the automatic creation of short URLs are based on iterator and token. The iterator would generate a numeric URL consequentially iterating for new URLs (s/1, s/2, ...). Token - would generate unique identifiers of predefined length (s/aghs1, s/98hgy, ...).
To configure the URL Shortener:
1. Go to General Settings > Website
2. Find the section 'URLs Shortener'
3. Choose the Generation method (Iterator or Token)
4. If you chose 'Token', then also choose tokens length (Token size cannot be less than 5 and bigger than 64)
5. Optionally set the validity days (When a short URL would be expired after creation. Put 0 to make all URLs valid forever by default). For example, if you set up validity days as 90, and today is the 25th of October, then all your passwords created today will be valid till the 23rd of January. If you set the validity days as 0, then all created URLs will be valid forever by default.
6. Click 'Save'
Managing Short URLs
The short link can be either generated automatically, according to the preset configurations (see Short URLs Configuration), or added manually by applying your own keywords, so the link will look exactly the way you want. The preset rules will be considered in all places: as you generate links from the backend or website and even when you add a website snippet to a page. Thus, it will take just a few seconds to add a short URL to a page.
Each short URL peers with an automatic QR code image that might be downloaded, shared, or added to Odoo website pages. Use the snippet 'Short URL QR Code' to find or generate the QR code as soon as a visitor opens the page (see Website Snippet).
It is possible to have as many short links for a single address as needed for various purposes. That is particularly useful if you want to share different links in various social media to track the redirects for each source. For example, you can create a link to post on Facebook and another one - on Twitter. Then, you will be able to tell which source of the campaign was the most successful.
The full list of the created short URLs can be managed from the backend. Add new short URLs, edit, archive, or delete the existing ones.
Managing URLs from the Backend
All created short URLs can be seen and managed from the backend. There are 2 ways to open the short URLs menu:
1. From General Settings > Website, the section 'URLs Shortener' by clicking 'Manage Short URLs'
2. Under the menu Websites >Configuration > Short URLs
In the short URLs menu, you will see the list of short URLs with information about their 'Target URL', the validity time, and the related website.
You need a 'Target link' to give the instructions to the module, and on what basis to create a short URL. For example, you may use one of the product's links to create a short URL (and get yoursite.com/s/desk instead of yoursite.com/shop/customizable-desk-config-9#attr=1,3,47).
The 'Validity time' can be set, so the link will be available only for a particular amount of time and then automatically disabled. For example, when you need the link to be available only during the 'October sale', set the validity as 31 days.
The field website is useful in the multi-website environment. It is particularly useful, as some or all available websites may contain similar products with the same links. So, you can create a short URL, which will be used on all websites. For example, you have 2 sites with the same product 'custom chair' (website1 and website2). You create a short URL /chair and make it available for both sites (as you don't choose a particular site). Thus, the products will be available through the following links: website1.com/s/chair and website2.com/s/chair.
For extra convenience, you can group short URLs by a 'Target URL'. Thus, you will be able to see, how many links each 'Target URL' has and what are they. This is particularly useful if you have multiple short links for the 'Target URLs'.
In the Short URLs menu, you can manage links in a batch. You can export, archive, unarchive, and delete links. For that, just select short URLs, click on an 'Action' icon above, and choose the action.
To add a new URL from the backend:
1. Click 'New'
2. Add a 'Target URL'
3. Optionally, add some notes to easily distinguish short links
4. Optionally, add the validity date to make a link auto expired. If you have added a default validity date in short URL settings, you can still change or remove it for a particular link on this step (see Short URLs Configuration)
5. Optionally, choose the website to restrict usage for a specific site or use a link globally (the app fully supports Odoo multi-website mode)
As soon as you click the button 'New' the short URL and linked QR code are generated. If you don't like the short link, you can generate a new one, by clicking 'Update'. There you will see a new Token. Click the button 'Update' in the pop-up window to apply it. You can also replace the Token with your own value. As you update the short link, the QR code is also updated accordingly.
To create your own short URL, use only the following numbers and symbols: 0123456789abcdefghijklmnopqrstuvwxyz_-. Other symbols will be replaced with the symbol '-'. Capital letters will be decapitalized.
To update an existing short URL from the backend:
1. Open any short URL
2. Add some changes
Website Interface for Short URLs
Use the URL shortener right while customizing the website. Here you can see and manage the short URLs for the active page address or add new short links. Change the Target URL if needed, then available short links will be recalculated.
To see all available short links of a particular page, open any website page and click Site > Short URLs. The app would automatically retrieve a target web address with all search and hash parameters from a browser. In the list, you will see all URLs, that lead to the page. You will also be able to see the validity date, notes, and the website of a short URL.
On the right side of each URL, you will find the following buttons:
1. 'Copy to the clipboard'
2. 'Download QR code'
2. 'Archive'
To change the details of the URL just click on one of the available fields and introduce the changes. This way you will be able to change a token, assign an expiration date, and apply it to this website or to all sites.
You can change the automatically generated token by either generating a new one or by typing the value manually. So, the short link will look exactly the way you like. For example, the generated token is sf32jk, and you want to show in the link the relation to a product, so you change it to 'chair' and the link will look the following way: yourwebsite.com/s/chair.
The assigning of an expiration date makes the short URL valid only for a particular amount of time. As you edit the link, it is possible to add, change or remove the expiration date of a short URL, if necessary.
By applying a short URL to one, several, or all sites, you define the websites, to which the created short links will lead. For example, if you have a similar product with the same link on all of your websites, then you can set the short link for all three at once. Thus, the short link /s/chair will be available for all of your sites, if you will not specify a particular one (yoursite1.com/s/chair, yoursite2.com/s/chair...).
Not only can you manage the short URLs from the website, but also you can create a short URL for the currently opened page.
To create a new short URL:
1. Open the page, to which you want to add a short link
2. Click Site > Short URLs
3. Click 'Add'
4. The token will be generated automatically, but you can change it the way you want (for example, add related words)
5. Optionally set the date, after which the link will be expired
6. Optionally choose a website
7. Click 'Save'
After that, the short link will be added to the list of URLs of the related page and will lead to the target URL.
For example, let's create a short URL for one of our products 'Customizable Desk'. The original link is /shop/customizable-desk-9. It is too long and contains elements, which are difficult to understand. So, as we click the 'add' button, we see an automatically generated token cmqs9 which, unfortunately, doesn't identify the type of product to which the link leads. So, we decide to fix it manually and write 'table'. Below the token we can check the resulting short URL, so, we can fix it if we don't like something. We add some notes, so it will be easier to maintain the high number of short links. The validity date is set by default, but we can change it, if necessary. As we want to create a link for the current website only, in the field 'Website', we choose 'This website'. Now the link is ready to be used.
Website Snippet
The website menu 'Site' and the backend menu 'Short URLs' is available only for Odoo website designers. For certain pages, you might be interested to show a short link for ordinary visitors as well.
The app introduces two special website snippets that might be added to any Odoo website's inner content. This way, as a visitor opens a page the snippet would find or create a short URL/QR code.
For that, you might drag and drop the special website editor snippets 'Short URLs' and 'Short URL QR Code'.
The snippet 'Short URLs' adds a text block with a short link. Alternatively, you may add an XML line with the tag a with the HREF "#" and the class "short_url_widget".
The snippet 'Short URL QR Code' adds a QR code image that you may customize using the standard Odoo website designer tools.
Each time a page with a such snippet is opened, a short URL will be searched and - if not found - created. In such a way, you may show a visitor a valid short URL, which he/she might copy, share and scan.
Take into account: the snippet searches only for 'always valid' global short URLs. If the previously created short URLs have an expiration date, then the new link without such will be created.
For example, let's add a short URL to one of the products. As we add the snippet to the page, we see the line 'Computed Automatically'. After saving the page, the short link is automatically generated. This link has no validity date and it will be valid until deleted manually.
Access to URL Shortener
To manage short URLs a user should belong to the standard Odoo group 'Website Editor'. To assign the group to a user:
1. Go to General Settings
2. Click 'Manage Users'
3. Open a user
4. Find the section 'Website' and assign the user the role 'Editor and Designer'
When you add a URL snippet to the website page, a short link generated by the snippet will be seen by any visitor (see Website Snippet).
Short URLs in Scripts
The module might be also useful for developers. While developing a custom add-on, script, or server action you might be interested to have a short URL for certain website addresses. With the help of the module, it is possible to find or create a short URL for a target website address by applying a single Python method.
To generate a short URL, you should trigger the method 'action_find_surl' of the model 'short.url.redirect'
As arguments it should receive:
target_url - string - relative web path. For example, "/shop/customizable-desk-config-9#attr=7,4,47)".
tocreate - boolean - whether a new short URL should be created if there are no active ones.
alwaysvalid - boolean - whether to search only short URLs without expiration date. If set to False, planned to be expired links might be also returned.
website_id -integer - if False the app would search only global URLs, otherwise - for a specific website (applicable for multi-website mode).
qr_base_url - boolean - if False the method would return a final URL, if True - a QR code content.
The method would either return a string - the first found short URL satisfying the received parameters (e.g. '/s/desk'), a binary content of a QR code, or False (boolean) if nothing was found.
For example:
my_short_url = self.env["short.url.redirect"].action_find_surl("/shop/customizable-desk-config-9#attr=7,4,47", True, True, 1, False)
About Website URL Shortener
Website URL Shortener is an Odoo app that assigns and manages short URLs for Odoo website links. URL shortening is a well-known methodology to cope with too long and ugly-looking web addresses. The app introduces this technique in Odoo by allowing website editors to manually or automatically generate, control, and administrate short URLs for any Odoo web links.
Each short URL peers with an automatic QR code image that might be downloaded, shared, or added to Odoo website pages.
Configure the rules for automatically creating short URLs based on iterator and token (for example, /s/12 and /s/rh72ko) or apply your own keywords (for example, /s/desk, /s/best-chairs).
Have as many short links for a single address as needed for various purposes. Share one link on Facebook, another - on Twitter, and a special one - for specific partners. Then, count redirects for each source.
Use the URL shortener right while customizing the website or in Odoo's advanced backend. Make a link soon expired or forever-lasting. Update the token at any moment or archive a link if it is no longer valid.
The app introduces two special website snippets that might be added to any Odoo website's inner content. The snippet 'Short URLs' would find or create a short URL right when a visitor opens a page. The snippet 'Short URL QR Code' would find or generate a QR code right when a visitor opens a page.
Developers might use the app to find or create a short URL for a target website address by applying a single Python method.
Automatic or custom URLs
Website snippet
Multi channels control
Available for scripts and custom add-ons
Short URLs Configuration
The module lets generate the URL links automatically. The functionality of the module can be accessed either from the backend website configuration or when customizing a website from the frontend.
You can configure the way, your short links are generated. There are 2 generation methods, that you can choose from. The rules for the automatic creation of short URLs are based on iterator and token. The iterator would generate a numeric URL consequentially iterating for new URLs (s/1, s/2, ...). Token - would generate unique identifiers of predefined length (s/aghs1, s/98hgy, ...).
To configure the URL Shortener:
1. Go to General Settings > Website
2. Find the section 'URLs Shortener'
3. Choose the Generation method (Iterator or Token)
4. If you chose 'Token', then also choose tokens length (Token size cannot be less than 5 and bigger than 64)
5. Optionally set the validity days (When a short URL would be expired after creation. Put 0 to make all URLs valid forever by default). For example, if you set up validity days as 90, and today is the 25th of October, then all your passwords created today will be valid till the 23rd of January. If you set the validity days as 0, then all created URLs will be valid forever by default.
6. Click 'Save'
Managing Short URLs
The short link can be either generated automatically, according to the preset configurations (see Short URLs Configuration), or added manually by applying your own keywords, so the link will look exactly the way you want. The preset rules will be considered in all places: as you generate links from the backend or website and even when you add a website snippet to a page. Thus, it will take just a few seconds to add a short URL to a page.
Each short URL peers with an automatic QR code image that might be downloaded, shared, or added to Odoo website pages. Use the snippet 'Short URL QR Code' to find or generate the QR code as soon as a visitor opens the page (see Website Snippet).
It is possible to have as many short links for a single address as needed for various purposes. That is particularly useful if you want to share different links in various social media to track the redirects for each source. For example, you can create a link to post on Facebook and another one - on Twitter. Then, you will be able to tell which source of the campaign was the most successful.
The full list of the created short URLs can be managed from the backend. Add new short URLs, edit, archive, or delete the existing ones.
Managing URLs from the Backend
All created short URLs can be seen and managed from the backend. There are 2 ways to open the short URLs menu:
1. From General Settings > Website, the section 'URLs Shortener' by clicking 'Manage Short URLs'
2. Under the menu Websites >Configuration > Short URLs
In the short URLs menu, you will see the list of short URLs with information about their 'Target URL', the validity time, and the related website.
You need a 'Target link' to give the instructions to the module, and on what basis to create a short URL. For example, you may use one of the product's links to create a short URL (and get yoursite.com/s/desk instead of yoursite.com/shop/customizable-desk-config-9#attr=1,3,47).
The 'Validity time' can be set, so the link will be available only for a particular amount of time and then automatically disabled. For example, when you need the link to be available only during the 'October sale', set the validity as 31 days.
The field website is useful in the multi-website environment. It is particularly useful, as some or all available websites may contain similar products with the same links. So, you can create a short URL, which will be used on all websites. For example, you have 2 sites with the same product 'custom chair' (website1 and website2). You create a short URL /chair and make it available for both sites (as you don't choose a particular site). Thus, the products will be available through the following links: website1.com/s/chair and website2.com/s/chair.
For extra convenience, you can group short URLs by a 'Target URL'. Thus, you will be able to see, how many links each 'Target URL' has and what are they. This is particularly useful if you have multiple short links for the 'Target URLs'.
In the Short URLs menu, you can manage links in a batch. You can export, archive, unarchive, and delete links. For that, just select short URLs, click on an 'Action' icon above, and choose the action.
To add a new URL from the backend:
1. Click 'New'
2. Add a 'Target URL'
3. Optionally, add some notes to easily distinguish short links
4. Optionally, add the validity date to make a link auto expired. If you have added a default validity date in short URL settings, you can still change or remove it for a particular link on this step (see Short URLs Configuration)
5. Optionally, choose the website to restrict usage for a specific site or use a link globally (the app fully supports Odoo multi-website mode)
As soon as you click the button 'New' the short URL and linked QR code are generated. If you don't like the short link, you can generate a new one, by clicking 'Update'. There you will see a new Token. Click the button 'Update' in the pop-up window to apply it. You can also replace the Token with your own value. As you update the short link, the QR code is also updated accordingly.
To create your own short URL, use only the following numbers and symbols: 0123456789abcdefghijklmnopqrstuvwxyz_-. Other symbols will be replaced with the symbol '-'. Capital letters will be decapitalized.
To update an existing short URL from the backend:
1. Open any short URL
2. Add some changes
Website Interface for Short URLs
Use the URL shortener right while customizing the website. Here you can see and manage the short URLs for the active page address or add new short links. Change the Target URL if needed, then available short links will be recalculated.
To see all available short links of a particular page, open any website page and click Site > Short URLs. The app would automatically retrieve a target web address with all search and hash parameters from a browser. In the list, you will see all URLs, that lead to the page. You will also be able to see the validity date, notes, and the website of a short URL.
On the right side of each URL, you will find the following buttons:
1. 'Copy to the clipboard'
2. 'Download QR code'
2. 'Archive'
To change the details of the URL just click on one of the available fields and introduce the changes. This way you will be able to change a token, assign an expiration date, and apply it to this website or to all sites.
You can change the automatically generated token by either generating a new one or by typing the value manually. So, the short link will look exactly the way you like. For example, the generated token is sf32jk, and you want to show in the link the relation to a product, so you change it to 'chair' and the link will look the following way: yourwebsite.com/s/chair.
The assigning of an expiration date makes the short URL valid only for a particular amount of time. As you edit the link, it is possible to add, change or remove the expiration date of a short URL, if necessary.
By applying a short URL to one, several, or all sites, you define the websites, to which the created short links will lead. For example, if you have a similar product with the same link on all of your websites, then you can set the short link for all three at once. Thus, the short link /s/chair will be available for all of your sites, if you will not specify a particular one (yoursite1.com/s/chair, yoursite2.com/s/chair...).
Not only can you manage the short URLs from the website, but also you can create a short URL for the currently opened page.
To create a new short URL:
1. Open the page, to which you want to add a short link
2. Click Site > Short URLs
3. Click 'Add'
4. The token will be generated automatically, but you can change it the way you want (for example, add related words)
5. Optionally set the date, after which the link will be expired
6. Optionally choose a website
7. Click 'Save'
After that, the short link will be added to the list of URLs of the related page and will lead to the target URL.
For example, let's create a short URL for one of our products 'Customizable Desk'. The original link is /shop/customizable-desk-9. It is too long and contains elements, which are difficult to understand. So, as we click the 'add' button, we see an automatically generated token cmqs9 which, unfortunately, doesn't identify the type of product to which the link leads. So, we decide to fix it manually and write 'table'. Below the token we can check the resulting short URL, so, we can fix it if we don't like something. We add some notes, so it will be easier to maintain the high number of short links. The validity date is set by default, but we can change it, if necessary. As we want to create a link for the current website only, in the field 'Website', we choose 'This website'. Now the link is ready to be used.
Website Snippet
The website menu 'Site' and the backend menu 'Short URLs' is available only for Odoo website designers. For certain pages, you might be interested to show a short link for ordinary visitors as well.
The app introduces two special website snippets that might be added to any Odoo website's inner content. This way, as a visitor opens a page the snippet would find or create a short URL/QR code.
For that, you might drag and drop the special website editor snippets 'Short URLs' and 'Short URL QR Code'.
The snippet 'Short URLs' adds a text block with a short link. Alternatively, you may add an XML line with the tag a with the HREF "#" and the class "short_url_widget".
The snippet 'Short URL QR Code' adds a QR code image that you may customize using the standard Odoo website designer tools.
Each time a page with a such snippet is opened, a short URL will be searched and - if not found - created. In such a way, you may show a visitor a valid short URL, which he/she might copy, share and scan.
Take into account: the snippet searches only for 'always valid' global short URLs. If the previously created short URLs have an expiration date, then the new link without such will be created.
For example, let's add a short URL to one of the products. As we add the snippet to the page, we see the line 'Computed Automatically'. After saving the page, the short link is automatically generated. This link has no validity date and it will be valid until deleted manually.
Access to URL Shortener
To manage short URLs a user should belong to the standard Odoo group 'Website Editor'. To assign the group to a user:
1. Go to General Settings
2. Click 'Manage Users'
3. Open a user
4. Find the section 'Website' and assign the user the role 'Editor and Designer'
When you add a URL snippet to the website page, a short link generated by the snippet will be seen by any visitor (see Website Snippet).
Short URLs in Scripts
The module might be also useful for developers. While developing a custom add-on, script, or server action you might be interested to have a short URL for certain website addresses. With the help of the module, it is possible to find or create a short URL for a target website address by applying a single Python method.
To generate a short URL, you should trigger the method 'action_find_surl' of the model 'short.url.redirect'
As arguments it should receive:
target_url - string - relative web path. For example, "/shop/customizable-desk-config-9#attr=7,4,47)".
tocreate - boolean - whether a new short URL should be created if there are no active ones.
alwaysvalid - boolean - whether to search only short URLs without expiration date. If set to False, planned to be expired links might be also returned.
website_id -integer - if False the app would search only global URLs, otherwise - for a specific website (applicable for multi-website mode).
qr_base_url - boolean - if False the method would return a final URL, if True - a QR code content.
The method would either return a string - the first found short URL satisfying the received parameters (e.g. '/s/desk'), a binary content of a QR code, or False (boolean) if nothing was found.
For example:
my_short_url = self.env["short.url.redirect"].action_find_surl("/shop/customizable-desk-config-9#attr=7,4,47", True, True, 1, False)