Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Workflows in inheritance by prototyping (_name != _inherit)

By
Shaun Dawson
on 6/18/13, 5:46 PM 818 views

I have a class defined like this:

class mymodule_thing(osv.osv):
    _name = "mymodule.thing",
    _columns = {
        #some columns in the parent class
    }

Then, I have two children of that;

class mymodule_thing_type_a(osv.osv):
    _name = "mymodule.thing_type_a",
    _columns = {
         #some columns only in type a
    }

class mymodule_thing_type_b(osv.osv):
    _name = "mymodule.thing_type_b",
    _columns = {
         #some columns only in type a
    }

My problem is with workflow. I tried defining the same workflow on three different osvs like this:

<record model="workflow" id="wkf_mymodule_thing">
    <field name="name">mymodule_thing.wkf</field>
    <field name="osv">mymodule.thing</field>
    <field name="on_create">True</field>
</record>

<record model="workflow" id="wkf_mymodule_thing">
    <field name="name">mymodule_thing.wkf</field>
    <field name="osv">mymodule.thing_a</field>
    <field name="on_create">True</field>
</record>

<record model="workflow" id="wkf_mymodule_thing">
    <field name="name">mymodule_thing.wkf</field>
    <field name="osv">mymodule.thing_b</field>
    <field name="on_create">True</field>
</record>

but, that didn't work. (What happened was that the workflow only worked for thing_b, the last to be declared).

Defining the workflow only on mymodule.thing didn't work either. The workflow wasn't applied to the child objects.

The only way that I've figured out to do what I need is to declare three different workflows, one for the parent, and then one for each of the children. That's unmaintainable.

Any ideas?

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 6/18/13, 5:46 PM
Seen: 818 times
Last updated: 3/16/15, 8:10 AM