Search 1.9 billion lines of Odoo code on GitHub

vue-api

Author: Cristian González Ruz
License: OEEL-1
Branch: 12.0
Repository: OSevangelist/vsf-odoo
Dependencies: base, vue_storefront, and web
Languages: HTML (10, 0.4%), Markdown (95, 3.4%), Python (2622, 93.7%), and XML (70, 2.5%)

<h1>Odoo module for Vue Storefront</h1> <p><img src="docs/vuepress/public/logo.png" alt="Logo"></p> <h2>Why Odoo?</h2> <p>In contrast of eCommerce integration solutions, Odoo is unique in that it includes ERP, eCommerce and CMS functionalities without the need for additional solutions. As explained in the official website, Odoo is a suite of open-source business apps that cover all the company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc. All in all, Odoo&#39;s unique value proposition is to be at the same time very easy to use and fully integrated.</p> <h2>Why Vue Storefront?</h2> <p>Vue Storefront offers a mobile native-like user experience:</p> <ul> <li>A look and feel that is integrated with the native platform, which implies: <ul> <li>An app icon on the home screen.</li> <li>App is able to run full screen.</li> </ul></li> <li>A decrease in loading times after the app installs the Service Workers, thanks to caching layouts and content. The mobile app tries to act as immediately as possible on user input, avoiding the use of the internet connection as much as possible.</li> <li>Re-engaging with users via push notifications.</li> </ul> <p>Vue Storefront avoids the complexity of having to maintain several native developments – for instance, one for Android and one for iOS –, having a single platform to avoid extra development costs. Furthermore, with the possibility of enabling Server-Side Rendering for the load of the first webpage, we can remark the importance of SEO within the eCommerce industry and offer a solution capable of being crawled by search engines.</p> <h2>Modifying the default architecture of Vue Storefront</h2> <p>By default, Vue Storefront includes a NoSQL/ElasticSearch database back-end within its architecture (https://docs.vuestorefront.io/guide/#what-is-vue-storefront). However, in order to avoid the maintenance of two different data stores, the proposed architecture for this project removes the Elastic Search data store in favour of directly connecting the front-end with the Odoo back-end. As a result, the new architecture is based on the fact that the front-end should be able to directly crawl the Odoo back-end API, as it is presented with the following diagram.</p> <p><img src="docs/vuepress/public/architecture.png" alt="Architecture"></p> <p>The class called SearchAdapter is a client-side code which is responsible of retrieving the following data from the back-end: - Product - Attribute - Category - Tax rule</p> <p align="center"> <img width="200" align="center" alt="UML class diagram of SearchAdapter client-side class" src="https://github.com/cristian-g/vsf-odoo/blob/master/docs/vuepress/public/search_adapter.png?raw=true"> </p> <p>As a result, this class is responsible of loading the product listing that appears on the home screen and category pages, not only when the user makes a search. While the default SearchAdapter provided by Vue Storefront retrieves data from the ElasticSearch back-end, this project uses a RESTful API using JSON format as back-end. </p> <p>Changes that must be done in order to achieve a working communication between the front-end and the Odoo back-end are avaliable on this repo:</p> <p><a href="https://github.com/cristian-g/vue-storefront/compare/5c3f4aa2f827b4910248f4a666b24e93ba5d5248...develop">https://github.com/cristian-g/vue-storefront</a></p> <h2>Odoo module</h2> <p>The API development of this project is packaged as an Odoo module, which is composed by the following elements:</p> <ul> <li>Controllers</li> <li>Business objects</li> <li>Data files</li> <li>Static web data</li> </ul> <p><img src="docs/vuepress/public/class_diagram.png" alt="Class diagram"></p> <h3>Controllers</h3> <p>They are declared as Python classes that handle requests by extending the Controller class from odoo.http package. In the case of this project, there are three Controllers:</p> <h4>PublicAPIController</h4> <ul> <li>Handles requests which do not use user authentication.</li> <li>Examples: retrieve products, sign up, etc.</li> </ul> <h4>PrivateAPIController</h4> <ul> <li>Handles requests which can use user authentication (it can either be required or optional).</li> <li>Examples: add product to cart, edit profile, etc.</li> </ul> <h4>TokenAPIController</h4> <ul> <li>Handles requests about generating or invalidating authentication tokens. It receives the credentials of the user – email and password – and then returns the computed token.</li> </ul> <h3>Business objects</h3> <p>They are declared as Python classes extending Model class from odoo.models package which integrates them into the automated persistence system (database). In the case of this project:</p> <ul> <li><strong>AccessToken</strong> is a new model created to encapsulate the attributes of each authentication token, such as its lifetime and the related user.</li> <li><strong>User</strong> model has been explicitly created in order to extend the existing User model to add the related identification tokens.</li> </ul> <h3>Data files</h3> <p>In the case of this project, it consists in an XML file declaring configuration data (module parameterization). It is named &quot;ir_config_param.xml&quot; inside the &quot;data&quot; folder and contains a parameter, which is the number of seconds of lifetime of the authentication token.</p> <h3>Static web data</h3> <p>They are static assets, such as images, CSS files or JavaScript files that can be used by the web interface or Odoo website. In the case of this project, they are located inside the &quot;static&quot; folder, which includes the &quot;description&quot; assets, which are used to display the module within the Odoo administration panel.</p> <ul> <li>icon.png</li> <li>index.html (contains module title and description)</li> <li>main_screenshot.png</li> </ul> <h2>Installation of the Odoo module</h2> <ol> <li><code>cd C:\Program Files (x86)\Odoo 12.0\server\odoo\addons</code></li> <li><code>git clone https://github.com/cristian-g/vsf-odoo.git vue_storefront</code></li> <li>Copy <code>data/ir_config_param_example.xml</code> to <code>data/ir_config_param.xml</code> and set your desired params</li> <li>Update apps/modules list <img src="docs/vuepress/public/list.png" alt="List"> <img src="docs/vuepress/public/update_list.png" alt="Update list"></li> <li>Install module <img src="docs/vuepress/public/install.png" alt="Install"> <img src="docs/vuepress/public/installed.png" alt="Installed"></li> </ol> <h2>Installation of Vue Storefront</h2> <p>Note that the Odoo module just includes the needed API. </p> <p>Install Vue Storefront, including my SearchAdapter from my repo: <a href="https://github.com/cristian-g/vue-storefront">https://github.com/cristian-g/vue-storefront</a></p> <p>Remember to set <code>useExactUrlsNoProxy</code> to <code>true</code>, if you are not using ImageMagick or similar.</p> <p>In order to set up a production environment, it is recommended to follow <a href="https://github.com/DivanteLtd/vue-storefront/blob/master/docs/guide/installation/production-setup.md">this instructions</a>.</p> <p>Otherwise, in case you are just developing, just run <code>yarn</code> in order to install the dependencies and then <code>yarn dev</code> in order to compile and run the front-end in your browser.</p> <h2>Examples</h2> <h3>Product listing</h3> <p align="center"> <img align="center" alt="Product listing" src="https://github.com/cristian-g/vsf-odoo/blob/master/docs/vuepress/public/product_listing.gif?raw=true"> </p> <h3>Categories and subcategories</h3> <p align="center"> <img align="center" alt="Categories and subcategories" src="https://github.com/cristian-g/vsf-odoo/blob/master/docs/vuepress/public/categories_and_subcategories.gif?raw=true"> </p> <h3>Variants</h3> <p align="center"> <img align="center" alt="Variants" src="https://github.com/cristian-g/vsf-odoo/blob/master/docs/vuepress/public/variants.gif?raw=true"> </p> <h2>Roadmap</h2> <ul> <li>Open-source alpha release (June) - Done</li> <li>Beta release (July) - Done</li> </ul> <h2>Compatibility</h2> <ul> <li>Odoo v12</li> <li>Vue Storefront v1.9.2</li> </ul> <h2>The license</h2> <p>Odoo module for Vue Storefront source code is completely free and released under the <a href="https://github.com/cristian-g/vsf-odoo/blob/master/LICENSE">MIT License</a>.</p> <h2>Contributing</h2> <p>If you like the idea behind Odoo and Vue Storefront and want to become a contributor - do not hesitate and check our <a href="https://github.com/cristian-g/vsf-odoo/issues">list of the active issues</a> or contact me directly via vsfodoo@cristiangonzalez.com.</p> <p>If you have discovered a 🐜 or have a feature suggestion, feel free to create an issue on Github.</p>