Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

How are inputs set required in website_sale billing form?

Subscriure's

Get notified when there's activity on this post

This question has been flagged
formecommercewebsite_saleodoo12
1 Respondre
5336 Vistes
Avatar
Samo Arko

Can anyone explain how are inputs on the template website_sale.address set as required? I need to make zip required but cannot figure out what method is used. I don't see anything in template controller or I haven't found anything in js files.


<div t-attf-class="form-group #{error.get('phone') and 'o_has_error' or ''} col-lg-6" id="div_phone">

    <label class="col-form-label" for="phone">Phone</label>

    <input type="tel" name="phone" t-attf-class="form-control #{error.get('phone') and 'is-invalid' or ''}" t-att-value="'phone' in checkout and checkout['phone']" />

</div>


<t t-set='zip_city' t-value='country and [x for x in country.get_address_fields() if x in ["zip", "city"]] or ["city", "zip"]'/>

<t t-if="'zip' in zip_city and zip_city.index('zip') &lt; zip_city.index('city')">

    <div t-attf-class="form-group #{error.get('zip') and 'o_has_error' or ''} col-md-4 div_zip">

        <label class="col-form-label label-optional" for="zip">Zip Code</label>

        <input type="text" name="zip" t-attf-class="form-control #{error.get('zip') and 'is-invalid' or ''}" t-att-value="'zip' in checkout and checkout['zip']" />

    </div>

</t>

Phone input is required, zip is not. How is it done?

0
Avatar
Descartar
Avatar
Ivan Yang
Best Answer

Hi Samo,

You can set required by inherit website_sale controller -> main.py

Here we got 2 function:
_get_mandatory_billing_fields
_get_mandatory_shipping_fields

Just add your field name that you wish to make it required


Regards,
Ivan

2
Avatar
Descartar
Samo Arko
Autor

thanks!

Samo Arko
Autor

I've extended the controller but it doesn't work. It still isn't mandatory!

Ivan Yang

What Odoo version did you use ?

Samo Arko
Autor

odoo 12 CE. I've even extended the template input field name="field_required" with zip

Ivan Yang

You've restarted your server right ?

I tried & it works from my side, you may need to try & print the variable in checkout_form_validate function

Samo Arko
Autor

yeah, I've restarted the server. I've extended the controller:

from odoo.addons.website_sale.controllers.main import WebsiteSale

class TablaWebsiteSale(WebsiteSale):

def _get_mandatory_billing_fields(self):

return ["name", "email", "street", "city", "zip", "country_id"]

def _get_mandatory_shipping_fields(self):

return ["name", "street", "city", "zip", "country_id"]

But when I log the output of those methods

I get only: odoo.addons.website_sale.controllers.main: mandatory shipping: ['name', 'street', 'city', 'country_id'], mandatory billing: ['name', 'email', 'street', 'city', 'country_id']

Ivan Yang

I think you also need to inherit "checkout" and "checkout_form_validate" function, because these 2 functions call for it

Samo Arko
Autor

Ok now it works, thanks.... but weird I never needed to inherit other methods.

Ivan Yang

Glad it works!

Enjoying the discussion? Don't just read, join in!

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

Registrar-se
Related Posts Respostes Vistes Activitat
How to disable "Add to Cart" button in E-commerce product page in Odoo 12? Solved
ecommerce odoo12
Avatar
Avatar
Avatar
Avatar
Avatar
5
d’oct. 23
17009
How to pass custom page form fields to another page
form ecommerce
Avatar
0
de maig 23
2247
Add shop and wishlist buttons on new website theme module
ecommerce website_sale
Avatar
0
de febr. 22
2948
How to submit an element of an radio list in website? Javascript event problem.
javascript ecommerce website website_sale odoo12
Avatar
0
de febr. 21
3310
when adding product to cart while accessing site with www I get catr is empty!
ecommerce odoo12
Avatar
0
de juny 20
3004
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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