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 method for handling long or unappealing 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 is paired with an automatic QR code image that can be downloaded, shared, or added to Odoo website pages.

Configure the rules for automatically creating short URLs based on an iterator and a token (for example, /s/12 and /s/rh72ko) or apply your keywords (for example, /s/desk, /s/best-chairs).

Create as many short links as needed for a single address to serve 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 while customizing the website or in Odoo's advanced backend. You can link to something that will soon expire or something that will last forever. You can 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 as soon as a visitor opens a page. The snippet 'Short URL QR Code' would automatically discover or generate a QR code 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 allows you to generate URL links automatically. The module's functionality 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 the iterator and the token. The iterator would generate a numeric URL, consequently iterating for new URLs (s/1, s/2, ...). Token - would generate unique identifiers of predefined length (s/aghs1, s/98hgy, etc.).

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 the token length (Token size cannot be less than 5 and bigger than 64)

5. Optionally set the validity days (When a short URL would expire 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 to 0, then all created URLs will be valid forever by default.

6. Click 'Save'.




Managing Short URLs


The short link can be generated automatically, according to preset configurations (see Short URLs Configuration), or added manually by applying your keywords, so the link will appear exactly as you want. The preset rules will be used in all instances: when generating links from the backend or website, and when adding 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 is paired with an automatic QR code image that can 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 complete 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 two 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 provide instructions to the module and specify the basis for creating a short URL. For example, you may use one of the product's links to make 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 that 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 helpful in a multi-website environment. It is beneficial, 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 two 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 they are. 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. To do this, select short URLs, click on the 'Action' icon above, and choose the desired action.


To add a new URL from the backend:

1. Click 'New'

2. Add a 'Target URL'

3. Optionally, add some notes to distinguish short links easily

4. Optionally, add the validity date to make a link auto-expire. If you have added a default validity date in short URL settings, you can still change or remove it for a particular link at 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 'Update' button in the pop-up window to apply the changes. You can also replace the token with your value. As you update the short link, the QR code is also updated accordingly.

To create your 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 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 the 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, including 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 view the validity date, notes, and the website associated with 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'

3. 'Archive'.

To change the details of the URL, click on one of the available fields and introduce the changes. This way, you can 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 developing a new one or by typing the value manually. So, the short link will appear exactly as 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.

Assigning an expiration date makes the short URL valid for only a specific amount of time. As you edit the link, you can 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 do not specify a particular one (yoursite1.com/s/chair, yoursite2.com/s/chair, etc.).


Not only can you manage the short URLs from the website, but you can also 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 expire

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, the "Customizable Desk. The original link is /shop/customizable-desk-9. It is too long and contains elements that are difficult to understand. 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 decided to fix it manually and write 'table'. Below the token, we can check the resulting short URL, allowing us to modify it if we don't like something. We added some notes to make it easier to maintain the high number of short links. The validity date is set by default; however, it can be changed if necessary. To create a link for the current website only, in the 'Website' field, select the target website. The link is now ready for use.


Website Snippet

The 'Site' menu on the website and the 'Short URLs' menu in the backend are available only to Odoo website designers. For specific pages, you may also be interested in displaying a short link for ordinary visitors.

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, 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 can add an XML line with the tag < a href="#" 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 such a snippet is opened, a short URL will be searched and - if not found - created. In this way, you can show a visitor a valid short URL, which they can 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 a date will be made.

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 expiration date and will remain valid until it is manually deleted.




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 a website page, a short link generated by the snippet will be visible to any visitor (see Website Snippet).



Short URLs in Scripts


The module might also be helpful for developers. While developing a custom add-on, script, or server action, you might be interested in having a short URL for specific 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 an expiration date. If set to False, planned-to-be-expired links might also be returned.

website_id - integer - If False, the app will search only global URLs; otherwise, it will search for a specific website (applicable for multi-website mode).

qr_base_url - boolean - if False, the method returns a final URL; if True, it returns a QR code content.

The method would either return a string - the first found short URL satisfying the received parameters (e.g., '/s/desk'), the 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 method for handling long or unappealing 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 is paired with an automatic QR code image that can be downloaded, shared, or added to Odoo website pages.

Configure the rules for automatically creating short URLs based on an iterator and a token (for example, /s/12 and /s/rh72ko) or apply your keywords (for example, /s/desk, /s/best-chairs).

Create as many short links as needed for a single address to serve 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 while customizing the website or in Odoo's advanced backend. You can link to something that will soon expire or something that will last forever. You can 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 as soon as a visitor opens a page. The snippet 'Short URL QR Code' would automatically discover or generate a QR code 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 allows you to generate URL links automatically. The module's functionality 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 the iterator and the token. The iterator would generate a numeric URL, consequently iterating for new URLs (s/1, s/2, ...). Token - would generate unique identifiers of predefined length (s/aghs1, s/98hgy, etc.).

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 the token length (Token size cannot be less than 5 and bigger than 64)

5. Optionally set the validity days (When a short URL would expire 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 to 0, then all created URLs will be valid forever by default.

6. Click 'Save'.




Managing Short URLs


The short link can be generated automatically, according to preset configurations (see Short URLs Configuration), or added manually by applying your keywords, so the link will appear exactly as you want. The preset rules will be used in all instances: when generating links from the backend or website, and when adding 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 is paired with an automatic QR code image that can 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 complete 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 two 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 provide instructions to the module and specify the basis for creating a short URL. For example, you may use one of the product's links to make 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 that 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 helpful in a multi-website environment. It is beneficial, 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 two 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 they are. 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. To do this, select short URLs, click on the 'Action' icon above, and choose the desired action.


To add a new URL from the backend:

1. Click 'New'

2. Add a 'Target URL'

3. Optionally, add some notes to distinguish short links easily

4. Optionally, add the validity date to make a link auto-expire. If you have added a default validity date in short URL settings, you can still change or remove it for a particular link at 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 'Update' button in the pop-up window to apply the changes. You can also replace the token with your value. As you update the short link, the QR code is also updated accordingly.

To create your 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 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 the 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, including 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 view the validity date, notes, and the website associated with 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'

3. 'Archive'.

To change the details of the URL, click on one of the available fields and introduce the changes. This way, you can 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 developing a new one or by typing the value manually. So, the short link will appear exactly as 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.

Assigning an expiration date makes the short URL valid for only a specific amount of time. As you edit the link, you can 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 do not specify a particular one (yoursite1.com/s/chair, yoursite2.com/s/chair, etc.).


Not only can you manage the short URLs from the website, but you can also 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 expire

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, the "Customizable Desk. The original link is /shop/customizable-desk-9. It is too long and contains elements that are difficult to understand. 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 decided to fix it manually and write 'table'. Below the token, we can check the resulting short URL, allowing us to modify it if we don't like something. We added some notes to make it easier to maintain the high number of short links. The validity date is set by default; however, it can be changed if necessary. To create a link for the current website only, in the 'Website' field, select the target website. The link is now ready for use.


Website Snippet

The 'Site' menu on the website and the 'Short URLs' menu in the backend are available only to Odoo website designers. For specific pages, you may also be interested in displaying a short link for ordinary visitors.

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, 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 can add an XML line with the tag < a href="#" 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 such a snippet is opened, a short URL will be searched and - if not found - created. In this way, you can show a visitor a valid short URL, which they can 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 a date will be made.

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 expiration date and will remain valid until it is manually deleted.




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 a website page, a short link generated by the snippet will be visible to any visitor (see Website Snippet).



Short URLs in Scripts


The module might also be helpful for developers. While developing a custom add-on, script, or server action, you might be interested in having a short URL for specific 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 an expiration date. If set to False, planned-to-be-expired links might also be returned.

website_id - integer - If False, the app will search only global URLs; otherwise, it will search for a specific website (applicable for multi-website mode).

qr_base_url - boolean - if False, the method returns a final URL; if True, it returns a QR code content.

The method would either return a string - the first found short URL satisfying the received parameters (e.g., '/s/desk'), the 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)