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

V17. Do not allow make appointments on calendar at specify days

Subscriure's

Get notified when there's activity on this post

This question has been flagged
calendarcalendar_view
2 Respostes
2169 Vistes
Avatar
Matias

Hi all. I create a center module to creates appointments using calendar widget.

In my appointment model i have all the restriction when the appointment create (i check open/close, holidays and days when center open) and all works perfect but always when i click the appointment create (i can click wherever i want on the calendar view)

I want to add this controls at the calendar view. I mean, i want to block the click create event appointment on the calendar when when center close or when holidays. I read that with JavaScript this could be done but i dont know how to do it. check some javascript code but they are too old and i dont know what methods have to override to do it. Im literally new at odoo and python hehe. Could some one give a tips on how to do it? Thanks a lot!



1
Avatar
Descartar
Avatar
Sandeep Mishra
Best Answer

Hi Matias,


You can do using changing code  extend the web_calendar widget in your module's JavaScript file. You can override the onCreate method to include your restrictions.


odoo.define('your_module_name.CalendarViewRestrictions', function (require) {

    "use strict";


    const CalendarController = require('web.CalendarController');

    const rpc = require('web.rpc');


    CalendarController.include({

        async onCreateEvent(event) {

            const date = event.data.date; // The clicked date


            // Call the backend method to check restrictions

            const is_allowed = await rpc.query({

                model: 'your.model.name',

                method: 'check_calendar_restrictions',

                args: [date],

            });


            if (!is_allowed) {

                this.do_warn('Restriction', 'You cannot create an appointment on this date.');

                return;

            }


            // If allowed, proceed with the default behavior

            this._super.apply(this, arguments);

        },

    });

});


0
Avatar
Descartar
Matias
Autor

First, thanks for the reply. It helps me a lot to understand more about Odoo.
When i try it, i have this error when open my odoo (I restart odoo server with --dev=assets flag)

"The following modules are needed by other modules but have not been defined, they may not be present in the correct asset bundle:
web.CalendarController
web.rpc
The following modules could not be loaded because they have unmet dependencies, this is a secondary error which is likely caused by one of the above problems:
@cng_appointments/js/appointment"

JavaScript file is added on __manifest__.py file

'assets': {
'web.assets_backend': [
'cng_appointments/static/src/js/calendar_restriction.js',
],
}

Avatar
Jainil Joshi D.
Best Answer

Hello matias,

can you be more specific

If you need to create the appointments via backend/erp you need to pass validations in there, else if you have created the widget in website then can you provide me a screenshot of how it looks based on that i can give you some reference of js for this validations in calender you are asking.

0
Avatar
Descartar
Matias
Autor

Hello! I cant provide a screenshot (button disabled) but this is what i have.

<record id="action_appointment_calendar" model="ir.actions.act_window">
<field name="name">Calendario de Citas</field>
<field name="res_model">cng_appointments.appointment</field>
<field name="view_mode">calendar,tree</field>
</record>

<record id="view_appointment_calendar" model="ir.ui.view">
<field name="name">cng_appointments.appointment.calendar</field>
<field name="model">cng_appointments.appointment</field>
<field name="arch" type="xml">
<calendar string="Calendario de Citas" mode="day" date_start="date_start" date_stop="date_end" color="box_id">
<field name="patient_id"/>
<field name="service_id"/>
<field name="box_id"/>
<field name="center_id"/>
</calendar>
</field>
</record>

<record id="view_appointment_calendar" model="ir.ui.view">
<field name="name">cng_appointments.appointment.calendar</field>
<field name="model">cng_appointments.appointment</field>
<field name="arch" type="xml">
<calendar string="Calendario de Citas" mode="day" date_start="date_start" date_stop="date_end" color="box_id">
<field name="patient_id"/>
<field name="service_id"/>
<field name="box_id"/>
<field name="center_id"/>
</calendar>
</field>
</record>

<menuitem id="menu_appointment_root" sequence="1" name="Gestión de Citas"/>
<menuitem id="menu_calendar_appointments"
name="Ver Citas"
parent="menu_appointment_root"
action="action_appointment_calendar"/>

I validate all on appointment form (After select a hour/day and confirm the popup create buttom). But i want the validations on the calendar. I mean, disable click or info the person that center is closed before the popup create button appears. @Sandeep Mishra answer i think works well but i have an error when try it.

Sorry with my english, is not good. Hope you understand what i want :')

Jainil Joshi D.

Hello matias
thanks for sharing the code this did me help for understanding your need and your problem.
you need to create a separate model named off days in which youre storing dates which are off dates and also passing a method in the calender model whcih will check the date is an off date and pass then show an warning/validation (depends on that youre passing on the offday) that the day with an off day should not be selected/ your string for the off day choosen and also you can create an boolean which will check the saturday sunday off and add those days in the off days model i believe this would help if it doesnt you can still ask me here or ping me here by upvoting i will surely respond you with your need.
Thanks
and yes this is an view (Calender view) adding constraint/validation via js doesnt make sense doing via backend/python does thus do it via python if you have this form on the portal end/website module then you need to create a validation via js.

Matias
Autor

I try what Sandeep Mishra but i have this error when restart odoo server.

"The following modules are needed by other modules but have not been defined, they may not be present in the correct asset bundle:
web.CalendarController
web.rpc
The following modules could not be loaded because they have unmet dependencies, this is a secondary error which is likely caused by one of the above problems:
@cng_appointments/js/appointment"

Do you have any idea what can this error be?

Jainil Joshi D.

Hello matias,
the sandeep mishra thing need to be covered in the asset as in the manifest you need to add the file name under the folder with the path given so the compiler will register your file and thus will need compile your code and give you an needed response you needed thus for the sandeep code you need to add that in manifest file which i will give you an example below.
If this doesnt solve your problem give me your whole js code and then give me your whole error in the message thus i can see that and respond you properly with that i have your calender thing code just give me manifest code andf the js code which you have written for the validation feature.
I am providing you the code of the js file register in the manifest below.
Thanks

#This you need to put below the data file in the manifest file
# "assets": {
# "web.assets_frontend": [
# # assets for frontend
# ],
# },

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
Change slotMinTime and slotMaxTime in Odoo calendar v17.
calendar calendar_view
Avatar
0
de febr. 25
1225
how change calandar library
calendar calendar_view
Avatar
0
de des. 21
2489
Jalali-calendar- odoo18
calendar
Avatar
Avatar
1
de jul. 25
1550
Internal Team Grouping for Calendar Solved
calendar
Avatar
Avatar
2
de juny 25
1852
Odoo 15 community: Calendar view enddate shows wrong date
calendar
Avatar
Avatar
1
de maig 25
3073
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