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

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

Suscribirse

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

Se marcó esta pregunta
calendarcalendar_view
2 Respuestas
2176 Vistas
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
Mejor respuesta

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.
Mejor respuesta

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
# ],
# },

¿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
Change slotMinTime and slotMaxTime in Odoo calendar v17.
calendar calendar_view
Avatar
0
feb 25
1226
how change calandar library
calendar calendar_view
Avatar
0
dic 21
2492
Jalali-calendar- odoo18
calendar
Avatar
Avatar
1
jul 25
1563
Internal Team Grouping for Calendar Resuelto
calendar
Avatar
Avatar
2
jun 25
1866
Odoo 15 community: Calendar view enddate shows wrong date
calendar
Avatar
Avatar
1
may 25
3084
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