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

How to put an onchange event on a calendar view?

Odebírat

Get notified when there's activity on this post

This question has been flagged
developmentv7
2 Odpovědi
13850 Zobrazení
Avatar
Bonnet Denis

In my personal add-on I've made some calendar,form and tree view. the onchange events work for form and tree view but I don't find how to handle a change of date or duration.

My calendar view:

    <record model="ir.ui.view" id="task_work_calendar">
        <field name="name">project.task.work.form</field>
        <field name="model">project.task.work</field>
        <field name="type">form</field>
        <field name="priority" eval="1"/>
        <field name="arch" type="xml">
            <calendar string="Planning des Taches" date_start="date" date_delay="hours" color="user_id" mode="week">
                <field name="id" invisible='1'/>
                <field name="name" on_change="onchange_name(name,id)" />
                <field name="date" on_change="onchange_date(date,id)" invisible='1'/>
                <field name="hours" on_change="onchange_hours(hours,id)" invisible='1'/>
                <field name="user_id" on_change="onchange_user_id(user_id,id)" modifiers="{'required': true}"/>
            </calendar>
        </field>
    </record>

Cordialement.

5
Avatar
Zrušit
Bonnet Denis
Autor

I've checked how work a calendar view. Bad news: it's only javascript and I can't use onchange event on calendar's fields(I can write it but it's not use => no Error in the log file). Someone can help me or have a trick to make this??? Thanks

Serpent Consulting Services Pvt. Ltd.

Please remove this field <field name="type">form</field> and try it because in openerp v7 the type field is not medatory and in calendar tag define version="7.0"

Bonnet Denis
Autor

Thanks, I will try this week.

Avatar
Shaun Dawson
Nejlepší odpověď

Yeah, on_change does not seem to be supported for calendar fields, which makes sense I suppose.

The way that I accomplished this in my module was to override the Model class 'write' method:

def write(self, cr, uid, ids, vals, context=None):
    print "in write, vals: ", vals
    #fiddle with vals to change what gets written to the DB
    return super(class_name, self).write(cr, uid, ids, vals, context=context)
1
Avatar
Zrušit
Avatar
Jeudy Nicolas
Nejlepší odpověď

Hello,

I use a small hack on each model definition to track changes when writing them.

first, define which field you want to watch:

  • first parameter: field name you want to watch
  • second one: function you want to launch if it change

Here is an example for project.project model:

_watch_attrs = {'stage_id': 'on_change_stage_id', 'project_id': 'on_change_project_id'}

then add this new write function to handle this

def write(self, cr, uid, ids, vals, context=None):

    ## On Change attributes checks
    objs = self.browse(cr, uid, ids)
    for attr, on_change_label in self._watch_attrs.iteritems():
        if attr in vals:
            if any(obj[attr] != vals[attr] for obj in objs):
                vals = getattr(self, on_change_label)(cr, uid, ids, vals, context=context)

    return super(my_inheritedclass, self).write(cr, uid, ids, vals, context)

you now just have to défine what you want in the function that is executed when watching changes:

def on_change_project_id(self, cr, uid, ids, vals, context):
    task_obj = self.pool.get('project.task')
    tasks = self.browse(cr,uid,ids,context=context)[0].tasks_id
    if vals.get('project_id',False):
        new_project = vals.get('project_id',False)
        for task in tasks:
            #DO SOMETHING like chatter post message or action ..

    return vals

So if ou drag an drop event on calendar, you car watch date_start or date_end and execute one specific method. It is very usefull to track stage_id changes when clicking on status widget.

0
Avatar
Zrušit
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
What's the context? Vyřešeno
development v7
Avatar
Avatar
Avatar
Avatar
9
bře 24
121000
How to hook to events of objects?
development v7
Avatar
Avatar
1
čvn 20
13079
Editing process in openerp Vyřešeno
development v7
Avatar
Avatar
Avatar
2
bře 16
11243
Is there a change in how new modules are created in v7?
development v7
Avatar
1
bře 15
4572
How to make OpenERP take my python code modifications into account?
development v7
Avatar
Avatar
2
bře 15
11049
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