Siirry sisältöön
Odoo Menu
  • Kirjaudu sisään
  • Kokeile ilmaiseksi
  • Sovellukset
    Talous
    • Kirjanpito
    • Laskutus
    • Kulut
    • Datataulukot (BI)
    • Asiakirjat
    • Allekirjoita
    Myynti
    • CRM
    • Myynti
    • Kassajärjestelmä myymälään
    • Kassajärjestelmä ravintolaan
    • Tilaukset
    • Vuokraus
    Verkkosivut
    • Verkkosivun Rakennustyökalu
    • Verkkokauppa
    • Blogi
    • Foorumi
    • Livechat
    • Verkko-oppiminen
    Toimitusketju
    • Varastointi
    • Tuotanto
    • Tuotteen elinkaaren hallinta (PLM)
    • Ostot
    • Huolto
    • Laatu
    Henkilöstöhallinto
    • Työntekijät
    • Rekrytointi
    • Vapaat
    • Arvioinnit
    • Suositukset
    • Kuljetuskalusto
    Markkinointi
    • Somemarkkinointi
    • Sähköpostimarkkinointi
    • Tekstiviestimarkkinointi
    • Tapahtumat
    • Markkinoinnin automaatio
    • Kyselyt
    Palvelut
    • Projekti
    • Työaikakirjaukset
    • Kenttähuolto
    • Asiakaspalvelu
    • Suunnittelu
    • Ajanvaraukset
    Tuottavuus
    • Viestintä
    • Hyväksynnät
    • IoT
    • IP-puhe
    • Tietokirjasto
    • WhatsApp
    Kolmannen osapuolen sovellukset Odoo-Studio Odoo-Pilvialusta
  • Toimialat
    Vähittäiskauppa
    • Kirjakauppa
    • Vaatekauppa
    • Huonekaluliike
    • Ruokakauppa
    • Laitteistokauppa
    • Lelukauppa
    Ruoka & Majoitus
    • Baari ja Pubi
    • Ravintola
    • Pikaruoka
    • Majatalo
    • Juomien jakelija
    • Hotelli
    Kiinteistöt
    • Kiinteistönvälitystoimisto
    • Arkkitehtitoimisto
    • Rakentaminen
    • Kiinteistönhallinta
    • Puutarhanhoito
    • Kiinteistön omistajien yhdistys
    Konsultointi
    • Tilitoimisto
    • Odoo-kumppani
    • Markkinointitoimisto
    • Lakitoimisto
    • Osaajahankinta
    • Tilintarkastus & sertifiointi
    Tuotanto
    • Tekstiili
    • Metalli
    • Huonekalut
    • Ruoka
    • Panimo
    • Yrityslahjat
    Terveys & Liikunta
    • Urheiluseura
    • Silmälasiliike
    • Kuntokeskus
    • Hyvinvointialan ammattilaiset
    • Apteekki
    • Kampaamo
    Kaupat
    • Yleismies
    • IT-laitteisto & Tuki
    • Aurinkoenergiajärjestelmät
    • Suutari
    • Siivouspalvelut
    • LVI-palvelut
    Muut
    • Voittoa tavoittelematon järjestö
    • Ympäristötoimisto
    • Mainostaulujen vuokraus  
    • Valokuvaus
    • Leasing-pyörät
    • Ohjelmistojen jälleenmyyjä
    Selaa kaikkia toimialoja
  • Yhteisö
    Opi
    • Kurssit
    • Dokumentaatio
    • Todistukset
    • Koulutus
    • Blogi
    • Podcast
    Kannusta kouluttautumaan
    • Koulutusohjelmat
    • Scale Up! Liiketoimintapeli
    • Vieraile Odoolla
    Hanki ohjelmisto
    • Lataa
    • Vertaile versioita
    • Julkaisut
    Tee yhteistyötä
    • Github
    • Foorumi
    • Tapahtumat
    • Käännökset
    • Ryhdy kumppaniksi
    • Kumppanipalvelut
    • Rekisteröi tilitoimistosi
    Hanki palveluja
    • Löydä kumppani
    • Löydä kirjanpitäjä
    • Varaa asiantuntijatapaaminen
    • Implementaatiopalvelut
    • Asiakasreferenssit
    • Tuki
    • Versionkorotukset
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Varaa demo
  • Hinnoittelu
  • Asiakaspalvelu

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

  • CRM
  • e-Commerce
  • Kirjanpito
  • Varastointi
  • PoS
  • Projekti
  • MRP
All apps
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Kaikki kirjoitukset Ihmiset Merkit
Tunnisteet (Näytä kaikki)
odoo accounting v14 pos v15
Tietoa tästä foorumista
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Kaikki kirjoitukset Ihmiset Merkit
Tunnisteet (Näytä kaikki)
odoo accounting v14 pos v15
Tietoa tästä foorumista
Apua

How do I activate a workflow transition from a wizard?

Tilaa

Saat ilmoituksen, kun tähän viestiin ilmaantuu aktiviteettia

Tämä kysymys on merkitty
wizardworkflowtransitionsignal
7 Vastaukset
14365 Näkymät
Avatar
Luis Filipe Castanheira

I've set up a wizard in OpenERP 7.0 that is updating fields correctly and all is working fine. Now I would like that, after submitting and updating the information on my object, the wizard would send a signal to the workflow of the object it acted uppon, to check if there is any transition to be taken.

How should I do that?

Do I have to directly call the workflow action from inside the def save_info() (see code below)? (I've tried this call self.pool.get('generic.request').req_reformulate_request(cr, uid, context['active_id'], context) but it throws so many errors, that I quickly gave up this approach)

Do I have to return something like 'signal': 'generic.request.req_reformulate_request' ?

Since I didn't find any information on this, I'm completely lost here, so any help would be very appreciated!

Thanks!

My wizard python code is the following:

from openerp.osv import osv
from openerp.osv import fields
from openerp.tools.translate import _

class ref_generic_request(osv.osv_memory):
    _name='ref.generic.request'

    _columns = {
        'reformulation_info': fields.text('Reformulation instructions', help='Instructions for the requestor justification the reformulation needs'),
            }

    def save_info(self, cr, uid, ids, context=None):
        if 'active_id' in context:
            info=self.browse(cr,uid,ids)[0].reformulation_info
            self.pool.get('generic.request').write(cr,uid,context['active_id'],{'reformulation_info' : info, 'needs_reformulation': 1})

          #self.pool.get('generic.request').req_reformulate_request(cr, uid, context['active_id'], context)
        return {
                'type': 'ir.actions.act_window_close',
         }
ref_generic_request()

And this is the XML that defines wizard's view:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record id="view_reformulate_generic_request_wizard" model="ir.ui.view">
            <field name="name">reformulate_generic_request_wizard.form</field>
            <field name="model">ref.generic.request</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Insert reformulation info" version="7.0">
                    <group >
                        <separator string="Please insert instruction for the reformulation of this request" colspan="2"/>
                        <field name="reformulation_info" string="Reformulation info"/>
                        <newline/>
                    </group>
                    <div style="text-align:right">
                        <button  icon="gtk-cancel" special="cancel" string="Cancel"/>
                        <button  icon="gtk-ok" name="save_info" string="Send to reformulation" type="object" />
                    </div>
               </form>
            </field>
        </record>
        <record id="action_reformulate_generic_request" model="ir.actions.act_window">
            <field name="name">Reformulate Request</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">ref.generic.request</field>
            <field name="view_type">form</field>
            <field name="view_mode">form</field>
            <field name="view_id" ref="view_reformulate_generic_request_wizard"/>
            <field name="target">new</field>
        </record>
        <act_window id="action_reformulate_generic_request"
                name="Reformulate Request"
                res_model="ref.generic.request"
                view_mode="form"
                target="new"
        />
    </data>
</openerp>

I have a workflow (I'll show here only the part that is relevant for this question):

<?xml version="1.0"?>
<openerp>
    <data>
        <record model="workflow" id="wkf_request">
            <field name="name">request.wkf</field>
            <field name="osv">generic.request</field>
            <field name="on_create">True</field>
        </record>
    (...)
        <record model="workflow.activity" id="act_confirm">
            <field name="wkf_id" ref="wkf_request" />
            <field name="name">request_confirmed</field>
            <field name="kind">function</field>
            <field name="action">confirm_request()</field>
        </record>
        <record model="workflow.activity" id="act_req_reformulate">
            <field name="wkf_id" ref="wkf_request" />
            <field name="name">request_reformulation</field>
            <field name="kind">function</field>
            <field name="action">req_reformulate_request()</field>
        </record>
    (...)
        <record model="workflow.transition" id="request_t2">
            <field name="act_from" ref="act_submit" />
            <field name="act_to" ref="act_req_reformulate" />
            <field name="signal">req_reformulate_request</field>
        </record>
    (...)
    </data>
</openerp>

And after the wizard updates info in my generic.request object I would like it to signal a function that and is actually called from the workflow the make the transition:

def req_reformulate_request(self, cr, uid, ids, context=None):
    req = self.browse(cr, uid, ids, context=context)
    goto = req[0].state
    if goto:
        self.write(cr, uid, ids, {'goto': goto, 'state': 'req_reformulation', 'needs_reformulation': True} )
    else:
        self.write(cr, uid, ids, {'state': 'req_reformulation', 'needs_reformulation': True})
    self.insert_trace(cr, uid, ids, context)
    return True

1
Avatar
Hylkää
Avatar
Axel Mendoza
Paras vastaus

For OpenERP v7 as  said:

import netsvc
...
wf_service = netsvc.LocalService('workflow')
wf_service.trg_validate(uid, 'account.invoice', id, 'invoice_cancel', cr)

For Odoo v8 the code change a little

from openerp import workflow
...
workflow.trg_validate(uid, 'account.invoice', id, 'invoice_cancel', cr)

#or with the new api
self.pool.get('account.invoice').signal_workflow(cr, uid, account_invoice, 'invoice_open')
#Edit for Update
For Odoo v9 and v10 and latter ...

records = self.env['account.invoice'].browse(ids)
records.signal_workflow('invoice_cancel')
5
Avatar
Hylkää
Avatar
Luis Filipe Castanheira
Tekijä Paras vastaus

Thanks a lot! I'll try it out and will give you feedback right away!. This code should be included in my wizard.py, right?

Jos De Graeve,YOU are the best! It worked! Thanks a lot.

For future reference, I'll leave here the modification on my py code, in order to make it work.

from openerp.osv import osv
from openerp.osv import fields
from openerp.tools.translate import _
import netsvc

class ref_generic_request(osv.osv_memory):
    _name='ref.generic.request'

    _columns = {
        'reformulation_info': fields.text('Reformulation instructions', help='Instructions for the requestor justification the reformulation needs'),
            }

    
    def save_info(self, cr, uid, ids, context=None):
        if 'active_id' in context:
            info=self.browse(cr,uid,ids)[0].reformulation_info
            self.pool.get('generic.request').write(cr,uid,context['active_id'],{'reformulation_info' : info, 'needs_reformulation': 1})
            wf_service = netsvc.LocalService('workflow')
            wf_service.trg_validate(uid,'generic.request',context['active_id'],'req_reformulate_request',cr)    
        return {
                'type': 'ir.actions.act_window_close',

         }

ref_generic_request()

Once again, many, many thanks!

1
Avatar
Hylkää
Adnier Rosello

Hi, netsvc module does not import correctly, I get this error: ImportError: No module named netsvc, any idea what happens, thanks

Adnier Rosello

well, i have got imported the module netsvc, but now i have this error: File "/home/usuario/workspace/odoo/addons/mrp_zabyca/mrp_production.py", line 130, in set_justify wf_service.trg_validate(self.env.user,'mrp.production',id,'button_cancel', self.env.cr) File "/home/usuario/workspace/odoo/openerp/workflow/__init__.py", line 85, in trg_validate return WorkflowService.new(cr, uid, res_type, res_id).validate(signal) File "/home/usuario/workspace/odoo/openerp/workflow/service.py", line 37, in new return cls(Session(cr, uid), Record(model_name, record_id)) File "/home/usuario/workspace/odoo/openerp/workflow/helpers.py", line 6, in __init__ assert isinstance(uid, (int, long)) AssertionError

Axel Mendoza

see how to do it in odoo v8 here in my answer

Avatar
Jos De Graeve
Paras vastaus

Hello Luis,

In order to do your thing with worflows, the code below should do the trick:

 

import netsvc

request_id = context['active_id']

if request_id:

wf_service = netsvc.LocalService('workflow')

wf_service.trg_validate(uid,'generic.request',request_id,'req_reformulate_request',cr)

 

Regards,

Jos

1
Avatar
Hylkää
Avatar
odoo
Paras vastaus

@Axel Mendoza,


I haven't karma to comment your answer but if in V8 the code change a little, what about in v10 ?

I need to delete a workflow then create it in V10 but i didn't get uid, cr parameters, any help please ?

from openerp import workflow
...
workflow.trg_validate(uid, 'account.invoice', id, 'invoice_cancel', cr)
0
Avatar
Hylkää
Axel Mendoza

see the update of the answer

Please could someone change the accept answer on this thread as seems to be mine the most requested so others in the future could pick it quickly

odoo

Thank you a lot :D

Luis Filipe Castanheira
Tekijä

@Axel done :)

Axel Mendoza

thanks

Nautitko keskustelusta? Älä vain lue, vaan osallistu!

Luo tili jo tänään nauttiaksesi yksinoikeusominaisuuksista ja osallistuaksesi mahtavaan yhteisöömme!

Rekisteröidy
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
Activate a workflow transition from a wizard
wizard workflow
Avatar
Avatar
Avatar
2
maalisk. 15
6432
Transition in the workflow doesn't work - Recreate an invoice per percentage after canceled the old one
workflow invoice transition
Avatar
1
kesäk. 16
5111
What's the equivalent in V9 of "purchase.act_draft" (V8) ? Ratkaistu
workflow transition 9.0
Avatar
Avatar
3
maalisk. 16
2094
how return a wizard from workflow activity (Odoo) Ratkaistu
wizard workflow odoo
Avatar
Avatar
1
lokak. 15
7309
Define group restrictions for a workflow transition in xml Ratkaistu
workflow group transition
Avatar
Avatar
Avatar
2
heinäk. 15
7519
Yhteisö
  • Kurssit
  • Dokumentaatio
  • Foorumi
Avoin lähdekoodi
  • Lataa
  • Github
  • Runbot
  • Käännökset
Palvelut
  • Odoo.sh hosting
  • Tuki
  • Versionkorotus
  • Räätälöidyt kehitykset
  • Koulutus
  • Löydä kirjanpitäjä
  • Löydä kumppani
  • Ryhdy kumppaniksi
Meistä
  • Yrityksemme
  • Tavaramerkki
  • Ota yhteyttä
  • Työpaikat
  • Tapahtumat
  • Podcast
  • Blogi
  • Asiakkaat
  • Oikeudellinen ilmoitus • Yksityisyys
  • Tietoturva
الْعَرَبيّة 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 on kokoelma avoimen lähdekoodin yrityssovelluksia, jotka kattavat kaikki yrityksesi tarpeet: asiakkuudenhallinta eli CRM, verkkokauppa, kirjanpito, varastointi, kassajärjestelmä, projektinhallinta, jne.

Odoon uniikki arvolupaus on olla samanaikaisesti erittäin helppokäyttöinen ja täysin integroitu.

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