Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textil
    • Kov
    • Nábytek
    • Jídlo
    • Pivovar
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • Podpora IT & hardware
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Procházet všechna odvětví
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Služby pro partnery
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

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

Odebírat

Get notified when there's activity on this post

This question has been flagged
calendarcalendar_view
2 Odpovědi
2213 Zobrazení
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
Zrušit
Avatar
Sandeep Mishra
Nejlepší odpověď

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
Zrušit
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.
Nejlepší odpověď

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
Zrušit
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!

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
Change slotMinTime and slotMaxTime in Odoo calendar v17.
calendar calendar_view
Avatar
0
úno 25
1261
how change calandar library
calendar calendar_view
Avatar
0
pro 21
2522
Jalali-calendar- odoo18
calendar
Avatar
Avatar
1
čvc 25
1588
Internal Team Grouping for Calendar Vyřešeno
calendar
Avatar
Avatar
2
čvn 25
1901
Odoo 15 community: Calendar view enddate shows wrong date
calendar
Avatar
Avatar
1
kvě 25
3105
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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