Merge lp:~mmakonnen/openobject-addons/openobject-addons into lp:openobject-addons

Proposed by Michael Telahun Makonnen
Status: Merged
Merged at revision: 8181
Proposed branch: lp:~mmakonnen/openobject-addons/openobject-addons
Merge into: lp:openobject-addons
Diff against target: 15 lines (+2/-2)
1 file modified
account/account.py (+2/-2)
To merge this branch: bzr merge lp:~mmakonnen/openobject-addons/openobject-addons
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+135702@code.launchpad.net

Description of the change

This change fixes a bug I encountered when trying to create a physical inventory from the last nightly build. I configured the warehouse module to keep accounting valuations of my stock and then tried to create an initial inventory. When I reached the validation step I got the following error:
  File "/home/mtm/code/openerp/vendor/openerp-6.2dev-20121122-000101/openerp/addons/account/account.py", line 1442, in create
    c['period_id'] = vals['period_id']
KeyError: 'period_id'

Basically, the problem is that the stock module doesn't specify a financial period or date for the account move line, which then promptly falls flat on its face. If either of these values are not provided it should provide its own values: period_id should default to the current period, date already has a _defaults line which uses the current date so if one isn't specified don't try to set it.

To post a comment you must log in.
Revision history for this message
Andre van Rooyen (klaasvortex) wrote :

Tried your patch/diff. Same result.

File "/opt/openerp/server/openerp/addons/account/account.py", line 1442, in create
    c['period_id'] = vals['period_id'] if 'period_id' in vals else self._get_period(cr, uid, context)
KeyError: 'period_id'

I don't know Python, but is it possible that c['period_id'] does not exists ?
Maybe something (a row) has to be created after setting the realtime option ?

Revision history for this message
Michael Telahun Makonnen (mmakonnen) wrote :

Hmmm, I'm not sure what to make of this. The problem is not c['period_id'] as Python will create the key if it does not exist, and the rest of the line is phrased such that vals['period_id'] gets evaluated only if it exists. Can you double check this again and post the full backtrace? Thanks so much for trying out the patch.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account/account.py'
2--- account/account.py 2012-11-15 12:38:51 +0000
3+++ account/account.py 2012-11-22 14:28:40 +0000
4@@ -1439,9 +1439,9 @@
5 if 'line_id' in vals:
6 c = context.copy()
7 c['novalidate'] = True
8- c['period_id'] = vals['period_id']
9+ c['period_id'] = vals['period_id'] if 'period_id' in vals else self._get_period(cr, uid, context)
10 c['journal_id'] = vals['journal_id']
11- c['date'] = vals['date']
12+ if 'date' in vals: c['date'] = vals['date']
13 result = super(account_move, self).create(cr, uid, vals, c)
14 self.validate(cr, uid, [result], context)
15 else:

Subscribers

People subscribed via source and target branches

to all changes: