Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Intelligence artificielle
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Supermarché
    • Quincaillerie
    • Magasin de jouets
    Restauration & Hôtellerie
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brasserie
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Commerce
    • Homme à tout faire
    • Matériel informatique & support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Parcourir toutes les industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenir partenaire
    • Services pour partenaires
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

issue in useService("bus_Service") in owl

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
javascriptowlodoo17OwlError
2 Réponses
4616 Vues
Avatar
Kishan Toliya
/** @odoo-module */

import { registry } from "@web/core/registry";
import { listView } from "@web/views/list/list_view";
import { ListController } from "@web/views/list/list_controller";
import { ListRenderer } from "@web/views/list/list_renderer";
import { useService } from "@web/core/utils/hooks";
import { useState } from "@odoo/owl";

class SaleOrderListController extends ListController {

setup() {
super.setup();
this.orm = useService("orm");
this.searchFilters = {};
this.state=useState({ searchList:[],
uniqueNames:[]
})
this.busService = useService("bus_service");
this.busService.addEventListener("custom_event", this._onCustomEvent.bind(this));

this.busService.addEventListener("searching update", this._onSearchUpdate.bind(this));
}

async _onCustomEvent(event) {
const deta=event.detail.data
await this.model.load({ domain :deta ? [["partner_id","ilike",deta]] : [] })
}


async _onSearchUpdate(event) {
this.searchFilters = event.detail;
console.log("search=>", this.searchFilters);
let domain = [];
Object.keys(this.searchFilters).forEach(field => {
domain = domain.concat(this.searchFilters[field]);
});
await this.model.load({ domain });
this.showResult(domain);
}



async showResult(domain){
this.state.searchList = await this.orm.searchRead('sale.order',domain,['partner_id'])
this.state.uniqueNames = [...new Set(this.state.searchList.map(task => task.partner_id[1]))];
const names=Object.values(this.state.uniqueNames)
console.log("name=>",names)
}
}

class SaleOrderListRenderer extends ListRenderer {
static template = "owl.SaleOrderListView.render";

setup() {
super.setup();
this.orm = useService("orm");
this.busService = useService("bus_service");
this.passValue = this.passValue.bind(this);
this.records = [];
this.filters = {};
this.partnerTags = useState([]);
this.salespersonTags = useState([]);
this.searchList = useState([])
this.uniqueNames = useState([])
this.names = useState([])
this.toggle = true
this.events=""
}

async onSearchInput(event) {

const field = event.target.dataset.field;
const query = event.target.value.trim();

if (!field) return;



if (field == 'partner_id'){
this.toggle = true
this.events = event.target.value;
if(query == ""){
this.toggle = false
console.log("trigger")
this.render(true)
}
}
else{
this.toggle = false

}

if (field === "create_date_start" || field === "create_date_end") {
if (field === "create_date_start") {
this.startDate = query;
} else {
this.endDate = query;
}

if (this.startDate && this.endDate) {
this.filters["create_date"] = [["create_date", ">=", this.startDate], ["create_date", "<=", this.endDate]];

} else {
delete this.filters["create_date"];
}

await this.busService.trigger("searching update", this.filters);
return;
}

if (field === "state") {
if (query) {
this.filters[field] = [[field, "=", query]];
} else {
delete this.filters[field];
}
await this.busService.trigger("searching update", this.filters);
return;
}



if (field === "partner_id" || field === "user_id") {
if (event.inputType === "insertText" && event.data === " ") {
const values = query.split(/\s+/).filter(val => val);
if (values.length > 0) {
if (field === "partner_id" && !this.partnerTags.includes(values[0])) {
this.partnerTags.push(values[0]);
} else if (field === "user_id" && !this.salespersonTags.includes(values[0])) {
this.salespersonTags.push(values[0]);
}
event.target.value = "";
}
this.updateFilters();
return;
}
}


if (query) {
this.filters[field] = [[field, "ilike", query]];
} else {
delete this.filters[field];
}

this.showResult(this.filters)
await this.busService.trigger("searching update", this.filters);
}


removeTag(field, index) {
if (field === "partner_id") {
this.partnerTags.splice(index, 1);

} else if (field === "user_id") {
this.salespersonTags.splice(index, 1);
}
this.updateFilters();
}


updateFilters() {
let partnerConditions = this.partnerTags.map(tag => ["partner_id", "ilike", tag]);
// let salespersonConditions = this.salespersonTags.map(tag => ["user_id", "ilike", tag]);

console.log("Condition tags =>", partnerConditions);

if (partnerConditions.length > 1) {
// Ensure correct Odoo domain syntax
let combinedPartnerConditions = [];
for (let i = 0; i < partnerConditions.length; i++) {
if (i > 0) combinedPartnerConditions.unshift("|"); // Add "|" before every condition
combinedPartnerConditions.push(partnerConditions[i]);
}
this.filters["partner_id"] = combinedPartnerConditions;
} else if (partnerConditions.length === 1) {
this.filters["partner_id"] = [partnerConditions[0]];
} else {
delete this.filters["partner_id"];
}
// if (salespersonConditions.length > 1) {
// let combinedSalespersonConditions = [];
// for (let i = 0; i < salespersonConditions.length; i++) {
// if (i > 0) combinedSalespersonConditions.unshift("|");
// combinedSalespersonConditions.push(salespersonConditions[i]); /// in that section problem is when user search in partner_id then partner_id changed by user_id fix it letter
// }
//// this.filters["user_id"] = combinedSalespersonConditions;
// } else {
//// this.filters["user_id"] = salespersonConditions;
// }

this.busService.trigger("searching update", this.filters);
}

async showResult(filters){
let domain = [];
Object.keys(filters).forEach(field => {
domain = domain.concat(filters[field]);
});
console.log("here is from in=>",Object.keys(filters)[0])
if(Object.keys(filters)[0]=='partner_id'){
this.searchList = await this.orm.searchRead('sale.order',domain,['partner_id'])
this.uniqueNames = [...new Set(this.searchList.map(task => task.partner_id[1]))];
this.names=Object.values(this.uniqueNames)
this.render(true)

}
}

passValue(event) {
if (!this.partnerTags.includes(event)) {
this.partnerTags.push(event);
}
this.events = "";

this.toggle = false;
this.updateFilters();
this.render(true);
}




}

export const SaleOrderListView = {
...listView,
Controller: SaleOrderListController,
Renderer: SaleOrderListRenderer,
};

registry.category("views").add("sale_order_list_search", SaleOrderListView);


this is right code which is written in odoo16 but now problem is in odoo17 when i migrate that in odoo17 its return error because of useService("bus_service") its not work in odoo17 please give me solution how can i use bus_service
0
Avatar
Ignorer
Avatar
Kishan Toliya
Auteur Meilleure réponse

Thank you for your support! 

i already solve it

0
Avatar
Ignorer
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Meilleure réponse

Hi Kishan Toliya,

You can access the bus service from the environment like this:

setup() {

    this.busService = this.env.services.bus_service;

}

Hope this helps

0
Avatar
Ignorer
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
Odoo 17 JavaScript Module not working.
javascript js owl odoo17
Avatar
Avatar
1
août 24
5937
standalone OWL application and used Odoo’s Dialog Service?
javascript service dialog owl OwlError
Avatar
Avatar
Avatar
3
août 25
4273
How can I listen to the onFieldChange event in Odoo 17 using JavaScript?
javascript selected owl OWL odoo17
Avatar
0
mars 25
2776
Inheriting service on JS
javascript js owl v17 odoo17
Avatar
Avatar
1
août 24
5042
OWL Cannot resolve symbol 'Component' 
owl odoo17
Avatar
Avatar
1
juil. 24
4024
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenir partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk Slovenščina Español (América Latina) Español Svenska ภาษาไทย Türkçe українська Tiếng Việt

Odoo est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now