Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

Tasks in custom module

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
task
2 Răspunsuri
7989 Vizualizări
Imagine profil
Shaun Dawson

I have a custom module, and I'd like to do the following two things:

  1. When an object gets into a particular state, automatically create a project.task item.
  2. When the task is Done, send a signal to my custom object workflow (to send it into the next state)

I know how to do #1 (by calling self.pool.get('project.task').create in my state action function). But, any idea how to do #2?

0
Imagine profil
Abandonează
Imagine profil
Keyur
Cel mai bun răspuns

Hi Shaun,

You can overwrite task done method in your custom module. Then you can do your code that change the state of your object to next state or call a workflow that change your next state.

Suppose task is done in action_close method. So you can overwrite action_close method & do your code.

def action_close(self, cr, uid, ids, context=None):
    res = super(task, self).action_cancel(cr, uid, ids, context)
    // Code to make your object record in next state
    return res

Hope this way it would work.

Thanks

2
Imagine profil
Abandonează
Imagine profil
Shaun Dawson
Autor Cel mai bun răspuns

Thanks for the pointer, Keyur.

In the interest of completion, I'll include exactly what I did so that there's a definitely working example in this answer.

(I'm modeling the requirement to perform a test on some equipment. The test_module.test model is the results of the test. When one of these objects is created, I want to create a Task that will track actually doing it.)

First, I added the logic to create a Task when my Test is created:

#this is in class test_module_test...
def test_pending(self, cr, uid, ids):
    project_task = self.pool.get('project.task')
    for test in self.browse(cr, uid, ids, context=None):
        #create the task for this new test
        print "Creating task for Test"
        task_id = project_task.create(cr, uid, {
            'name': test.task_name(),
            'user_id': test.task_uid(),
            'description': test.task_description(),
            test.column_for_test_id_in_task: test.id,
        }, context=None)

        self.write(cr,uid, ids, {'state':'pending', 'created_on': time.strftime('%Y-%m-%d')})
    return True

Then, in my modules.py file, I added the following class:

This class inherits from project.task, overriding the case_close method to signal my Test that it has been submitted.

class test_module_test_task(osv.osv):
    _name='project.task'
    _inherit='project.task'
    _columns = {
        'test_id': fields.many2one('eggrule.se_environmental_test', "SE Env. Test", ondelete='restrict'),
    }

    def case_close(self, cr, uid, ids, context=None):
        #if the super method succeeds...
        if super(test_module_test_task, self).case_close(cr, uid, ids, context=context):
            print "About to signal task workflows, if there are any"
            wf_service = netsvc.LocalService("workflow")
            #for each object that we were passed...
            for task in self.browse(cr, uid, ids):
                #if there is an environmental test...
                if task.test_id:
                    #signal it...
                    wf_service.trg_validate(uid, 'test_module.test', task.test_id.id, "test_submitted", cr)
            return True
        #else, the super method failed... (can't happen)
        return False

Voila!

0
Imagine profil
Abandonează
Keyur

Wow!!! That's great...You are doing it right...Thanks for your detail explanation.

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

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

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
How to make the task repeat in the settings but it’s not in the calendar
task
Imagine profil
0
apr. 24
2088
Odoo-serverfault when mark task as ready
task
Imagine profil
0
ian. 23
2446
How to create a new stage where i can create Tasks as Task templates but without it showing in Tasks?
task
Imagine profil
0
mar. 15
4484
How to create task with Assigned to via incoming email ?
task
Imagine profil
0
mar. 15
4691
Uncaught Error in project task page search bar
task
Imagine profil
Imagine profil
1
mar. 15
6468
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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