Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita una demostración
  • Precios
  • Ayuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyectos
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

issue in useService("bus_Service") in owl

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
javascriptowlodoo17OwlError
2 Respuestas
3242 Vistas
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
Descartar
Avatar
Kishan Toliya
Autor Mejor respuesta

Thank you for your support! 

i already solve it

0
Avatar
Descartar
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Mejor respuesta

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
Descartar
¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
Odoo 17 JavaScript Module not working.
javascript js owl odoo17
Avatar
Avatar
1
ago 24
4403
standalone OWL application and used Odoo’s Dialog Service?
javascript service dialog owl OwlError
Avatar
Avatar
Avatar
3
ago 25
2504
How can I listen to the onFieldChange event in Odoo 17 using JavaScript?
javascript selected owl OWL odoo17
Avatar
0
mar 25
1693
Inheriting service on JS
javascript js owl v17 odoo17
Avatar
Avatar
1
ago 24
3877
OWL Cannot resolve symbol 'Component' 
owl odoo17
Avatar
Avatar
1
jul 24
2953
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidad
  • Seguridad
الْعَرَبيّة 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 ภาษาไทย Türkçe українська Tiếng Việt

Odoo es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y estar totalmente integrado.

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