← Back to team overview

openerp-india team mailing list archive

[Bug 1028077] [NEW] Problem with invoice numbers when "Skip draft state for manual entries" is True

 

Public bug reported:

Here is the scenario to reproduce the bug on OpenERP 6.1 and OpenERP
trunk :

1. create a new DB ; install the modules account_accountant and account_cancel
2. go to the financial journal "Sale" and activate the options "Allow cancelling entries" and "Skip draft state for manual entries".
3. create a new customer invoice (check that it is linked to the "Sale" financial journal that you just configured) and validate it. It should get an invoice number such as SAJ/2012/001
4. On the same invoice, Click on "cancel", then "back to draft" and "validate" again
-> you will see that the invoice number is now SAJ/2012/002. That's the bug ; it should have kept the original invoice number.

The bug is caused by the fact that, when the option "Skip draft state
for manual entries" is active, the function post() of the object
account.move is called twice :

1. the first time, it is called by the function button_validate() of the object account.move without the 'invoice' key in the context
-> this will increment the sequence of the sale journal and will write this value of the 'name' field of account.move (since OpenERP v6, the field 'number' of account.invoice is a field.related of the 'name' field of account.move)

2. the second time, it is called by the function action_move_create() of
account.invoice with the 'invoice' key in the context : but, as the
'name' field of account.move is now different from '/', it won't change
the 'name' field of account.move

If the option "Skip draft state for manual entries" is NOT active, then
the post() function of account.move is called only once by the function
action_move_create() of account.invoice and it works fine : the sequence
is not incremented and the field internal_number of account.invoice is
used as the 'name' field of the account.move.

The root cause of this is in the function create() of account.move.line
(cf addons/account/account_move_line.py). At the end of the create()
function, you have this code :

if check and ((not context.get('no_store_function')) or journal.entry_posted):
            tmp = move_obj.validate(cr, uid, [vals['move_id']], context)
            if journal.entry_posted and tmp:
                move_obj.button_validate(cr,uid, [vals['move_id']], context)

That's the code that call's the button_validate() function of
account.move, which explains the first (bad) call of the function
post().

I don't know what's the good method to fix this bug...

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

-- 
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/1028077

Title:
  Problem with invoice numbers when "Skip draft state for manual
  entries" is True

Status in OpenERP Addons (modules):
  New

Bug description:
  Here is the scenario to reproduce the bug on OpenERP 6.1 and OpenERP
  trunk :

  1. create a new DB ; install the modules account_accountant and account_cancel
  2. go to the financial journal "Sale" and activate the options "Allow cancelling entries" and "Skip draft state for manual entries".
  3. create a new customer invoice (check that it is linked to the "Sale" financial journal that you just configured) and validate it. It should get an invoice number such as SAJ/2012/001
  4. On the same invoice, Click on "cancel", then "back to draft" and "validate" again
  -> you will see that the invoice number is now SAJ/2012/002. That's the bug ; it should have kept the original invoice number.

  The bug is caused by the fact that, when the option "Skip draft state
  for manual entries" is active, the function post() of the object
  account.move is called twice :

  1. the first time, it is called by the function button_validate() of the object account.move without the 'invoice' key in the context
  -> this will increment the sequence of the sale journal and will write this value of the 'name' field of account.move (since OpenERP v6, the field 'number' of account.invoice is a field.related of the 'name' field of account.move)

  2. the second time, it is called by the function action_move_create()
  of account.invoice with the 'invoice' key in the context : but, as the
  'name' field of account.move is now different from '/', it won't
  change the 'name' field of account.move

  If the option "Skip draft state for manual entries" is NOT active,
  then the post() function of account.move is called only once by the
  function action_move_create() of account.invoice and it works fine :
  the sequence is not incremented and the field internal_number of
  account.invoice is used as the 'name' field of the account.move.

  The root cause of this is in the function create() of
  account.move.line (cf addons/account/account_move_line.py). At the end
  of the create() function, you have this code :

  if check and ((not context.get('no_store_function')) or journal.entry_posted):
              tmp = move_obj.validate(cr, uid, [vals['move_id']], context)
              if journal.entry_posted and tmp:
                  move_obj.button_validate(cr,uid, [vals['move_id']], context)

  That's the code that call's the button_validate() function of
  account.move, which explains the first (bad) call of the function
  post().

  I don't know what's the good method to fix this bug...

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


Follow ups

References