← Back to team overview

openerp-india team mailing list archive

[Bug 961919] [NEW] Subflow signal not received when it ends in the activity's python action

 

Public bug reported:

Hello,

I will try to explain this issue which is a bit tricky.

It probably doesn't occurs in the OpenERP addons, but it implies
limitations of the framework.

When a subflow ends within a python action of the activity, the
transition to the next activity is not triggered.

Let say I have inherited the method action_invoice_create of sale.order
in order to automatically open the invoice and reconcile a payment
directly when the invoice is created.

Something like that (simplified code of a real case in base_sale_multichannels) : 
class sale_order(osv.osv):

    _inherit = 'sale.order'

    def action_invoice_create(self, cr, uid, ids, grouped=False, states=['confirmed', 'done', 'exception'], date_inv = False, context=None):
        inv_obj = self.pool.get('account.invoice')
        wf_service = netsvc.LocalService("workflow")
        res = super(sale_order, self).action_invoice_create(cr, uid, ids, grouped, states, date_inv, context)
        for order in self.browse(cr, uid, ids, context=context):
            if order.order_policy == 'postpaid':
                    for invoice in order.invoice_ids:
                        wf_service.trg_validate(uid, 'account.invoice', invoice.id, 'invoice_open', cr)
                        inv_obj.auto_reconcile(cr, uid, [invoice.id], context=context)

        return res

sale_order()

class account_invoice(osv.osv):

    _inherit = 'account.invoice'

    def auto_reconcile(self, cr, uid, ids, context=None):
        # code to automatically reconcile my invoice with an existing payment

account_invoice()


Here is a use case :

 - I create a sale order in post-paid and confirm it -> delivery order is created
 - I create a payment for the amount of the sale order
 - I deliver the packing -> the invoice is created with action_invoice_create()
 - Within action_invoice_create, the invoice is opened and reconciled => it reaches the "paid" state
 - Now, the sale order is : 
    * delivered
    * paid
    * BUT, it is still "in progress" instead of "done". The workflow state is still "invoice"
 -> the transition invoice to invoice_end triggered by subflow.paid has not been triggered.
 -> the workflow is stuck in an intermediate state

Here is a bug report on the module base_sale_multichannels where we
encounter this issue :
https://bugs.launchpad.net/magentoerpconnect/+bug/957136

The only solution I've found yet is to deactivate the auto-
reconciliation not to break the workflow.

I really tried to dive in the workflow code to find why this happens,
but I had have no success, I missed some keys to understand this complex
machinery.

If I can help to solve this problem, please ask.

Thanks
Guewen

** Affects: openobject-server
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Server.
https://bugs.launchpad.net/bugs/961919

Title:
  Subflow signal not received when it ends in the activity's python
  action

Status in OpenERP Server:
  New

Bug description:
  Hello,

  I will try to explain this issue which is a bit tricky.

  It probably doesn't occurs in the OpenERP addons, but it implies
  limitations of the framework.

  When a subflow ends within a python action of the activity, the
  transition to the next activity is not triggered.

  Let say I have inherited the method action_invoice_create of
  sale.order in order to automatically open the invoice and reconcile a
  payment directly when the invoice is created.

  Something like that (simplified code of a real case in base_sale_multichannels) : 
  class sale_order(osv.osv):

      _inherit = 'sale.order'

      def action_invoice_create(self, cr, uid, ids, grouped=False, states=['confirmed', 'done', 'exception'], date_inv = False, context=None):
          inv_obj = self.pool.get('account.invoice')
          wf_service = netsvc.LocalService("workflow")
          res = super(sale_order, self).action_invoice_create(cr, uid, ids, grouped, states, date_inv, context)
          for order in self.browse(cr, uid, ids, context=context):
              if order.order_policy == 'postpaid':
                      for invoice in order.invoice_ids:
                          wf_service.trg_validate(uid, 'account.invoice', invoice.id, 'invoice_open', cr)
                          inv_obj.auto_reconcile(cr, uid, [invoice.id], context=context)

          return res

  sale_order()

  class account_invoice(osv.osv):

      _inherit = 'account.invoice'

      def auto_reconcile(self, cr, uid, ids, context=None):
          # code to automatically reconcile my invoice with an existing payment

  account_invoice()

  
  Here is a use case :

   - I create a sale order in post-paid and confirm it -> delivery order is created
   - I create a payment for the amount of the sale order
   - I deliver the packing -> the invoice is created with action_invoice_create()
   - Within action_invoice_create, the invoice is opened and reconciled => it reaches the "paid" state
   - Now, the sale order is : 
      * delivered
      * paid
      * BUT, it is still "in progress" instead of "done". The workflow state is still "invoice"
   -> the transition invoice to invoice_end triggered by subflow.paid has not been triggered.
   -> the workflow is stuck in an intermediate state

  Here is a bug report on the module base_sale_multichannels where we
  encounter this issue :
  https://bugs.launchpad.net/magentoerpconnect/+bug/957136

  The only solution I've found yet is to deactivate the auto-
  reconciliation not to break the workflow.

  I really tried to dive in the workflow code to find why this happens,
  but I had have no success, I missed some keys to understand this
  complex machinery.

  If I can help to solve this problem, please ask.

  Thanks
  Guewen

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-server/+bug/961919/+subscriptions


Follow ups

References