Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to Override to confirm the sale order, if defined and if the transaction is done in openerp

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 123
    Comment on it

    If define Payment Transaction in sale order in sale module then first override the function and inherit to the view from sale and add fields acquirer_name in sale order model and set default draft method and use this function in your own module. Use this below code in .py file.

    def form_feedback(self, cr, uid, data, acquirer_name, context=None):
            """ Override to confirm the sale order, if defined, and if the transaction
            is done. """
            tx = None
            res = super(PaymentTransaction, self).form_feedback(cr, uid, data, acquirer_name, context=context)
    
            # fetch the tx, check its state, confirm the potential SO
            tx_find_method_name = '_%s_form_get_tx_from_data' % acquirer_name
            if hasattr(self, tx_find_method_name):
                tx = getattr(self, tx_find_method_name)(cr, uid, data, context=context)
            if tx and tx.state == 'done' and tx.acquirer_id.auto_confirm == 'at_pay_confirm' and tx.sale_order_id and tx.sale_order_id.state in ['draft', 'sent']:
                self.pool['sale.order'].action_confirm(cr, SUPERUSER_ID, [tx.sale_order_id.id], context=dict(context, send_email=True))
            elif tx and tx.state not in ['cancel'] and tx.sale_order_id and tx.sale_order_id.state in ['draft']:
                self.pool['sale.order'].force_quotation_send(cr, SUPERUSER_ID, [tx.sale_order_id.id], context=context)
    
            return res
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: