← Back to team overview

openerp-india team mailing list archive

[Bug 1193393] Re: Cancel invoice can broke DB integrity

 

[Expired for OpenERP Addons because there has been no activity for 60
days.]

** Changed in: openobject-addons
       Status: Incomplete => Expired

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

Title:
  Cancel invoice can broke DB integrity

Status in OpenERP Addons (modules):
  Expired

Bug description:
  I found this issue:

  1 Make and validate purchase invoice
  2 Make payment (only 50% of invoice amount, the invoice still open)
  3 Now modify invoice
  3.1 Cancel payment voucher
  3.2 Cancel, set to draft and validate original invoice
  4 Refresh the payment
  5 Crash!

  This happens because the account_voucher_line.move_line_id points to
  account_invoice_line. When I cancel any invoice, the account_move_line
  is deleted, but the account voucher_line still pointing to original
  account_move_line.id.

  This issue can be solved adding a "ondelete='restrict'" to field
  account_voucher_line.move_line_id or a better approach:

  class account_move_line(osv.osv):
      _inherit = "account.move.line"

      def unlink(self, cr, uid, ids, context=None):
          obj_vou = self.pool.get('account.voucher.line')
          move_line_ids = obj_vou.search(cr, uid, [('move_line_id', 'in', ids)])
          if move_line_ids:
              vou_lines = obj_vou.browse(cr,uid,move_line_ids,context=context)
              lst_vous = []
              for v in vou_lines:
                  lst_vous.append(v.voucher_id.reference or v.voucher_id.name or v.voucher_id.date)
              vous = ', '.join(lst_vous)
              raise osv.except_osv(_('Error!'),_('Can\'t cancel an invoice while is referenced in payments: %s'%vous))
          res = super(account_move_line, self).unlink(cr, uid, ids, context)
          return res

  account_move_line()

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