npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

Iā€™ve always been into building performant and accessible sites, but lately Iā€™ve been taking it extremely seriously. So much so that Iā€™ve been building a tool to help me optimize and monitor the sites that I build to make sure that Iā€™m making an attempt to offer the best experience to those who visit them. If youā€™re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, šŸ‘‹, Iā€™m Ryan HefnerĀ  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If youā€™re interested in other things Iā€™m working on, follow me on Twitter or check out the open source projects Iā€™ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soonā€“ish.

Open Software & Tools

This site wouldnā€™t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you šŸ™

Ā© 2024 ā€“Ā Pkg Stats / Ryan Hefner

odoo-webclient

v1.0.1

Published

Odoo-WebClientšŸ“” offers a simply but super effective solution that reuse the powerful capability of native Odoo WebClient from outside frontend applications, seamless interact with Odoo Services in customize client application, maximize the value of the s

Downloads

144

Readme

Odoo-WebClient šŸ“”

Odoo-WebClient šŸ“” offers a simply but super effective solution that reuse the powerful capability of native Odoo WebClient from outside frontend applications, handly seamless interact with Odoo Services from customize SPA(Single-Page App) or PWA(Progressive Web App), Maximize the value of the services that implemeted by PythonšŸ code.

Install

npm install odoo-webclient

Usage

  • Step 1: Setup client manager, configure the odoo instance address
import { getClientManager, DefaultClientManagerOption } from 'odoo-webclient';

async function setupOdooWebClient() {
  const option = new DefaultClientManagerOption()
  option.root = 'http://localhost:8069'; // odoo instance address, the instance should install Odoo-site module~
  getClientManager().setup(option);
  
}

setupOdooWebClient();
  • Step 2: Hook the webclient mounted event, while the instance WebClient is ready then load data through orm service
getClientManager().mounted((event)=>{ 
    reloadData();
  });
 
function reloadData(){
  const webClient = getClientManager().getWebClient(); 
  
  if (!webClient){
    return;
  }
  fetchApps(webClient)

}
async function fetchApps(webClient) {
  console.debug('āš”ļø getWebClient', webClient)

  const orm = webClient.orm
  // http://localhost:8069/web/dataset/call_kw/ir.module.module/web_search_read
  const specification = {
    icon: {},
    icon_flag: {},
    to_buy: {},
    name: {},
    state: {},
    summary: {},
    website: {},
    application: {},
    module_type: {},
    shortdesc: {},
  }
  const domain = ['application', '=', true]
  const result = await orm.call('ir.module.module', 'web_search_read', [[domain], specification])

  console.debug('šŸ“” fetchApps', result)

  dataSet.value = result.records
}
  • Step 3: Let šŸš€, do login then enjoy the smoothly and seamless data access experience.
const user = 'admin'; const password = 'admin'
const clientManager = getClientManager();
const request = await clientManager.login(user,password,true).subscribe(
  {
    next:x=>{
      console.log('login reponse, should includes data.scrpitTags:',x)
      
    }
  },
  error:(err)=>{
    throw err;
  });
 

Example App

Odoo Site App

APIs

  • Core class: IClientMananger

export interface IClientMananger { 
  
  setup(val: IServerOption): IClientMananger; 

  login(
    login: string,
    password: string,
    autoLoadClient: boolean
  ): Observable<ApiResponse>;

  logout(): Observable<boolean>;

  getWebClient(): IWebClient | null;

  loadClient(scriptTags: string): Observable<any>;

  mounted(handler: MessageHandler): void;
  unmounted(handler: MessageHandler): void;
}
  • IClientMananger.login

    login(login: string, password: string, autoLoadClient: boolean) Observable< ApiResponse >
  • Parameters:

    autoLoadClient: Type: boolean, identify whether auto load Odoo WebClicent instance

Login feature. the response contains field: data.scrpitTags, use the string value 'data.scrpitTags' build the HTMLScriptElement then will instance the native Odoo WebClient, in this scene, the WebClient was concised that can seamless use the capability of native Odoo WebClient from outside frontend applications. The value of 'data.scrpitTags' could be play 'Accesss Token' role, store in locale and use later like regular mobile frontend application.

const user = 'admin'; const password = 'admin'
const clientManager = getClientManager();
const request = await clientManager.login(user,password).subscribe(
  {
    next:x=>{
      console.log('login reponse, should includes data.scrpitTags:',x) 
    }
  },
  error:(err)=>{
    throw err;
  }); 
  • IClientMananger.mounted

    mounted(handler: MessageHandler): void
    Listen the Odoo WebClient instance mounted event.
getClientManager().mounted((event)=>{ 
    reloadData();
  });
 
function reloadData(){
  const webClient = getClientManager().getWebClient(); 
  
  if (!webClient){
    return;
  }
  fetchApps(webClient)

}
  • IClientMananger.logout

    logout() Observable< ApiResponse >
    Logout feature, quit session.

Backend Services Required

  • Odoo-Site
    Odoo Site expose the Odoo WebClient to Frontend Apps smoothly,seamless reuse the powerful capability of Odoo framework from outside Client Apps .
  • Odoo
    The Odoo framework To Grow Your Business.

Tech Stacks & Dependencies

Mechanism Workflow

Window fetch call RESTful api ----> API response includes script Tags of Odoo WebClient ----> render script Tags <Script>...</Script> on web page ----> load the odoo webclient success----> use js orm service call pyšŸ code directly šŸš€

LICENSE

MIT

Appendix