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

Use JS to customize, allowing users to select addresses by region in the survey

Suscribirse

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

Se marcó esta pregunta
surveyjsonjsodoo17
1986 Vistas
Avatar
MHKone113

Hi, now i will summary all the information: First Iam created a new selection (address) for survey.question --> I created a new template for this question.container too (my template worked). So , from this template , I need create js for user can select addresses according to each region.
i created my module , have some model for save my data geography , with that , Iam created  a model controller, Js file  --> This is my code controller:

@http.route('/survey/get_states', type='json', auth="public", website=True)
def get_states(self, country_id):
states = request.env['res.country.state'].sudo().search([('country_id', '=', int(country_id))])
return [{'id': state.id, 'name': state.name} for state in states]

@http.route('/survey/get_districts', type='json', auth="public", website=True)
def get_districts(self, state_id):
districts = request.env['res.country.district'].sudo().search([('state_id', '=', int(state_id))])
return [{'id': district.id, 'name': district.name} for district in districts]

@http.route('/survey/get_wards', type='json', auth="public", website=True)
def get_wards(self, district_id):
wards = request.env['res.country.ward'].sudo().search([('district_id', '=', int(district_id))])
return [{'id': ward.id, 'name': ward.name} for ward in wards]

And this my JS file , but when i press F12 , F5 -> I got error (
Uncaught Error: Dependencies should be defined by an array: function(require){"use strict";var publicWidget=require('web.public.widget');var core=require('web.core');var _t=core._t;var SurveyAddressWidget=publicWidget.Widget.extend({selector:'.js_address_widget',events:{'change .js_country':'_onCountryChange','change .js_state':'_onStateChange','change .js_district':'_onDistrictChange',},start:function(){return this._super.apply(this,arguments);},_onCountryChange:function(ev){var countryId=$(ev.currentTarget).val();this._updateStates(countryId);},_onStateChange:function(ev){var stateId=$(ev.currentTarget).val();this._updateDistricts(stateId);},_onDistrictChange:function(ev){var districtId=$(ev.currentTarget).val();this._updateWards(districtId);},_updateStates:function(countryId){var self=this;this._rpc({route:'/survey/get_states',params:{country_id:countryId,},}).then(function(states){var $stateSelect=self.$('.js_state');$stateSelect.empty().append($('


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
I got error undefined column survey_survey.active does not existed
survey odoo17
Avatar
Avatar
1
jun 24
2464
How to inherit survey question container template in odoo 17? Resuelto
survey odoo17
Avatar
1
jun 24
2622
How to replace or put new element in survey template xml in odoo 17?
survey v17 odoo17
Avatar
Avatar
Avatar
2
jun 24
3391
how to inherit or override a funtion in odoo javascript
function inherit js odoo17
Avatar
0
oct 24
2273
Odoo 17 JavaScript Module not working.
javascript js owl odoo17
Avatar
Avatar
1
ago 24
4616
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.

Sitio web hecho con

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