[Trunk/70/61/60/50] Workflow transitions on core modules should be pluggable

Bug #1169335 reported by Juan Márquez
20
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Confirmed
Wishlist
OpenERP R&D Addons Team 3

Bug Description

Most workflow transition condition are set as "True" and I think it is wrong because it prevents (or at least makes it difficult) from implementing validations in transitions. For example in a model "account.voucher" is impossible to avoid a ban payment to a partner or any other validation required, also applies to "account.invoice", from "draft" to "open" can not validate anything. The right thing should be for all transitions point to methods that return "True" by default maken then inheritable inherit and allowing to implement the required specifications.

Attached is a module [V6.0] that I had to develop to implement these Hits on "account.voucher"

https://code.launchpad.net/~jmarquez/openerp-tecvemar/tcv_account_voucher_extra_wkf

Revision history for this message
Amit Parik (amit-parik) wrote :

Hello Juan,

I have checked the workflow of account voucher and its working fine, Would you please tell us where you faced the problem.

Thank you!

Changed in openobject-addons:
status: New → Incomplete
Revision history for this message
Juan Márquez (jmarquez) wrote :

Hi, I think I did not explain well, the workflow if working well, but all transitions set to "True" by default, instead of defining them as a function that returns "True", we have to overwrite the original workflow to implement transition's validations. I think that the right thing would be to define all transitions as functions in the core.

This is exactly what does the module attached.

(please excuse my english)

Note: this applies for most default workflows

Revision history for this message
Juan Márquez (jmarquez) wrote :

Sample 2:

I need to do this for accoint.invoice's workflow: (Replace default "True" with function "test_open()"

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>

        <record id="account.t4" model="workflow.transition">
            <field name="act_from" ref="account.act_draft"/>
            <field name="act_to" ref="account.act_open"/>
            <field name="signal">invoice_open</field>
            <field name="condition">test_open()</field> <!-- <field name="condition">True</field> -->
        </record>

    </data>
</openerp>

What would happen if any other developer required to modify the module's transition?

I really think that to avoid problems all transitions should be associated with functions and not to the value "True".

Revision history for this message
Juan Márquez (jmarquez) wrote :

I make a quick search and found:

http://help.openerp.com/question/327/how-can-i-activate-a-credit-limit-for-my-customers/
http://help.openerp.com/question/5118/how-do-i-add-new-state-and-change-the-workflow-of-purchase-order/

In these situations probably will need to overwrite the transitions, and can cause incompatibility issues within other modules.

Juan Márquez (jmarquez)
Changed in openobject-addons:
status: Incomplete → New
Juan Márquez (jmarquez)
summary: - [Trunk/70/61/60/50] Workflow transitions omitted
+ [Trunk/70/61/60/50] Workflow transitions should be pluggable
summary: - [Trunk/70/61/60/50] Workflow transitions should be pluggable
+ [Trunk/70/61/60/50] Workflow transitions on core modules should be
+ pluggable
Revision history for this message
Juan Márquez (jmarquez) wrote :

Most workflow transition condition are set as "True" and I think it is wrong because it prevents (or at least makes it difficult) from implementing validations in transitions. For example in a model "account.voucher" is impossible to avoid banning a payment to a partner or any other validation required, also applies to "account.invoice", from "draft" to "open" can't insert any validations without overwriting the original condition (True) that should be a method so others developers can extend the method with their own implementations. The right thing should be for all transitions point to methods that return "True" by default making then inheritable and allowing to implement the required specifications.

Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 3 (openerp-dev-addons3)
importance: Undecided → Wishlist
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.