Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

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

Odoberať

Get notified when there's activity on this post

This question has been flagged
surveyjsonjsodoo17
1989 Zobrazenia
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
Zrušiť
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrácia
Related Posts Replies Zobrazenia Aktivita
I got error undefined column survey_survey.active does not existed
survey odoo17
Avatar
Avatar
1
jún 24
2465
How to inherit survey question container template in odoo 17? Solved
survey odoo17
Avatar
1
jún 24
2625
How to replace or put new element in survey template xml in odoo 17?
survey v17 odoo17
Avatar
Avatar
Avatar
2
jún 24
3402
how to inherit or override a funtion in odoo javascript
function inherit js odoo17
Avatar
0
okt 24
2276
Odoo 17 JavaScript Module not working.
javascript js owl odoo17
Avatar
Avatar
1
aug 24
4623
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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