account_move_line: uninitialized period_id

Bug #783994 reported by Stéphane Bidoul (Acsone)
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Low
OpenERP R&D Addons Team 3

Bug Description

Hi,

We obtained the following stack trace while creating a journal entry. Although I'm not sure of the root cause, there is indeed a code path where period_id may be uninitialized. I attach a proposed patch.

Best regards,

-sbi

Environment Information :
System : Windows-32bit-SP2
OS Name : nt
Operating System Release :
Operating System Version : 32bit
Operating System Architecture : 32bit
Operating System Locale : fr_BE.cp1252
Python Version : 2.5.2
OpenERP-Client Version : 6.0.2
Last revision No. & ID :Bazaar Package not Found !Traceback (most recent call last):
  File "/usr/local/bin/openerp6/lib/python2.6/site-packages/openerp-server/netsvc.py", line 489, in dispatch
    result = ExportService.getService(service_name).dispatch(method, auth, params)
  File "/usr/local/bin/openerp6/lib/python2.6/site-packages/openerp-server/service/web_services.py", line 599, in dispatch
    res = fn(db, uid, *params)
  File "/usr/local/bin/openerp6/lib/python2.6/site-packages/openerp-server/osv/osv.py", line 122, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/usr/local/bin/openerp6/lib/python2.6/site-packages/openerp-server/osv/osv.py", line 176, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/usr/local/bin/openerp6/lib/python2.6/site-packages/openerp-server/osv/osv.py", line 167, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/usr/local/src/openerp6/addons-fixes/account/account_move_line.py", line 1221, in create
    self._check_date(cr, uid, vals, context, check)
  File "/usr/local/src/openerp6/addons-fixes/account/account_move_line.py", line 1123, in _check_date
    if journal.allow_date and period_id:
UnboundLocalError: local variable 'period_id' referenced before assignment

Tags: maintenance

Related branches

Revision history for this message
Stéphane Bidoul (Acsone) (sbi) wrote :
Revision history for this message
Amit Parik (amit-parik) wrote :

Hello Stephane,

I have checked your issue at my end.
But all are working fine and I am not able to faced any traceback.

See the _check_date function and print the vals it gives o/p like this

 {'analytic_lines': [], 'statement_id': False, 'currency_id': False, 'date_maturity': False, 'narration': False, 'partner_id': 7, 'blocked': 0, 'analytic_account_id': False, 'journal_id': 1, 'tax_code_id': False, 'debit': False, 'ref': False, 'account_id': 9, 'period_id': 2, 'date_created': '2011-05-19', 'date': '2011-01-24', 'move_id': 8, 'tax_amount': False, 'name': 'eeee', 'account_tax_id': False, 'credit': False, 'amount_currency': False, 'quantity': False}

Which have the period_id because the "period_id" is required field in account.move.line so no need to assign it again as a False.

That's why in any case I am not faced any traceback so would you please provide your side example or proper steps in which you have faced the traceback.

Thanks and Waiting for your reply!

Changed in openobject-addons:
status: New → Incomplete
Revision history for this message
Stéphane Bidoul (Acsone) (sbi) wrote :

Hello Amit,

Our accountant encountered this exception once. Unfortunately, I could not reproduce the exact conditions yet and the problem did not occur again since.

Still, the stack trace was real :)

Maybe its related to one of Bug #713539, Bug #720808, Bug #777640?

Best regards,

-sbi

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

Hello Stephane,

First of all Thanks for your quick reply.

In comment #3 you have described three bugs but these three are totally different with your bug's traceback.

As you say "you could not produce this yet and problem did not occur again".

And I have trace the whole code of _check_date method but period_id is already passed in values of vals, So according to your patch no need to declare it again.

So currently I am closing this bug If you still faced the problem then you can reopen this with proper steps.

Thanks for the understanding!

Changed in openobject-addons:
status: Incomplete → Invalid
Revision history for this message
Stéphane Bidoul (Acsone) (sbi) wrote :

Hello again,

I can reproduce it now.

- openerp 6.0 series with demo data and gtk client
- Accounting > Configuration > Journals > Purchase Journal
- Enable "check date not in period" (this is important to reproduce the bug)
- Account > Journal Items > New
- in the new line:
  * select any account
  * name = /
  * journal = Purchase Journal
- click Save and you get the stack trace below

Best regards,

-sbi

Environment Information :
System : Windows-XP-5.1.2600-SP3
OS Name : nt
Operating System Release : XP
Operating System Version : 5.1.2600
Operating System Architecture : 32bit
Operating System Locale : fr_BE.cp1252
Python Version : 2.5.2
OpenERP-Client Version : 6.0.2
Last revision No. & ID :Bazaar Package not Found !Traceback (most recent call last):
  File "D:\Project\OpenErp6\server\bin\netsvc.py", line 489, in dispatch
    result = ExportService.getService(service_name).dispatch(method, auth, params)
  File "D:\Project\OpenErp6\server\bin\service\web_services.py", line 599, in dispatch
    res = fn(db, uid, *params)
  File "D:\Project\OpenErp6\server\bin\osv\osv.py", line 122, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "D:\Project\OpenErp6\server\bin\osv\osv.py", line 176, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "D:\Project\OpenErp6\server\bin\osv\osv.py", line 167, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "D:\Project\OpenErp6\addons\account\account_move_line.py", line 1221, in create
    self._check_date(cr, uid, vals, context, check)
  File "D:\Project\OpenErp6\addons\account\account_move_line.py", line 1123, in _check_date
    if journal.allow_date and period_id:
UnboundLocalError: local variable 'period_id' referenced before assignment

Changed in openobject-addons:
status: Invalid → New
Revision history for this message
Amit Parik (amit-parik) wrote :

Hello Stephane,

Thanks for your quick reply and producible steps.

Now I faced the traceback.

Thanks again!

summary: - [6.0] account_move_line: uninitialized period_id
+ account_move_line: uninitialized period_id
Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 3 (openerp-dev-addons3)
importance: Undecided → Low
status: New → Confirmed
Changed in openobject-addons:
status: Confirmed → In Progress
Revision history for this message
Ashvin Rathod (OpenERP) (ara-tinyerp) wrote :

Hello Stephane,

I have tested as your description and get the same problem.
And your attached patch is working fine for this.
It will be merged soon in trunk addons.

Revision ID: <email address hidden>
Revision No: 4715

Thanks for participation !

Changed in openobject-addons:
status: In Progress → Fix Committed
Revision history for this message
Stéphane Bidoul (Acsone) (sbi) wrote :

Hello,

Please note that my patch only makes the symptom go away, but It might be hiding a more serious error, since, as Amit mentioned above, period_id is mandatory and therefore should always be present.

Best regards,

-sbi

Revision history for this message
Mustufa Rangwala (Open ERP) (mra-tinyerp) wrote :

Hello,

Yes we are getting period_id in vals and we should use it.
so defining period_id at begining of the method seems ok but at the time of condition:

journal = journal_obj.browse(cr, uid, journal_id, context=context)
if journal.allow_date and period_id:

we should use period_id from vals.
can you please check

thanks,
mra

Changed in openobject-addons:
status: Fix Committed → Confirmed
Changed in openobject-addons:
milestone: none → 6.1
Changed in openobject-addons:
status: Confirmed → In Progress
Changed in openobject-addons:
status: In Progress → Fix Committed
qdp (OpenERP) (qdp)
Changed in openobject-addons:
status: Fix Committed → Fix Released
tags: added: maintenance
Revision history for this message
Alexis de Lattre (alexis-via) wrote :

Just for the history of the bug report :
the fix landed in the addons/6.0 branch with this commit :
<email address hidden>
dated 2011-12-06

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.