Amit Dodiya (OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/6.0-opw-50934-ado into
lp:openobject-addons/6.0.
Requested reviews:
Priyesh (OpenERP) (pso-openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-50934-ado/+merge/84565
Hello,
[FIX] : UnboundLocalError: local variable 'period_id' referenced before
assignment while creating a journal items.
Thanks,
Amit
--
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-50934-ado/+merge/84565
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/6.0-opw-50934-ado.
=== modified file 'account/account_move_line.py'
--- account/account_move_line.py 2011-11-22 10:49:26 +0000
+++ account/account_move_line.py 2011-12-06 05:17:24 +0000
@@ -590,11 +590,19 @@
if l.company_id != l.account_id.company_id or l.company_id != l.period_id.company_id:
return False
return True
+
+ def _check_date(self, cr, uid, ids, context=None):
+ for l in self.browse(cr, uid, ids, context=context):
+ if l.journal_id.allow_date:
+ if not time.strptime(l.date[:10],'%Y-%m-%d') >= time.strptime(l.period_id.date_start, '%Y-%m-%d') or not time.strptime(l.date[:10], '%Y-%m-%d') <= time.strptime(l.period_id.date_stop, '%Y-%m-%d'):
+ return False
+ return True
_constraints = [
(_check_no_view, 'You can not create move line on view account.', ['account_id']),
(_check_no_closed, 'You can not create move line on closed account.', ['account_id']),
(_check_company_id, 'Company must be same for its related account and period.',['company_id'] ),
+ (_check_date, 'The date of your Journal Entry is not in the defined period!', ['date']),
]
#TODO: ONCHANGE_ACCOUNT_ID: set account_tax_id
@@ -1099,35 +1107,6 @@
move_obj.validate(cr, uid, [line.move_id.id], context=context)
return result
- def _check_date(self, cr, uid, vals, context=None, check=True):
- if context is None:
- context = {}
- move_obj = self.pool.get('account.move')
- journal_obj = self.pool.get('account.journal')
- period_obj = self.pool.get('account.period')
- journal_id = False
- if 'date' in vals.keys():
- if 'journal_id' in vals and 'journal_id' not in context:
- journal_id = vals['journal_id']
- if 'period_id' in vals and 'period_id' not in context:
- period_id = vals['period_id']
- elif 'journal_id' not in context and 'move_id' in vals:
- if vals.get('move_id', False):
- m = move_obj.browse(cr, uid, vals['move_id'])
- journal_id = m.journal_id.id
- period_id = m.period_id.id
- else:
- journal_id = context.get('journal_id', False)
- period_id = context.get('period_id', False)
- if journal_id:
- journal = journal_obj.browse(cr, uid, journal_id, context=context)
- if journal.allow_date and period_id:
- period = period_obj.browse(cr, uid, period_id, context=context)
- if not time.strptime(vals['date'][:10],'%Y-%m-%d') >= time.strptime(period.date_start, '%Y-%m-%d') or not time.strptime(vals['date'][:10], '%Y-%m-%d') <= time.strptime(period.date_stop, '%Y-%m-%d'):
- raise osv.except_osv(_('Error'),_('The date of your Journal Entry is not in the defined period!'))
- else:
- return True
-
def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True):
if context is None:
context={}
@@ -1136,7 +1115,6 @@
journal_obj = self.pool.get('account.journal')
if vals.get('account_tax_id', False):
raise osv.except_osv(_('Unable to change tax !'), _('You can not change the tax, you should remove and recreate lines !'))
- self._check_date(cr, uid, vals, context, check)
if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['active']:
raise osv.except_osv(_('Bad account!'), _('You can not use an inactive account!'))
if update_check:
@@ -1219,7 +1197,6 @@
company_id = self.pool.get('account.move').read(cr, uid, vals['move_id'], ['company_id']).get('company_id', False)
if company_id:
vals['company_id'] = company_id[0]
- self._check_date(cr, uid, vals, context, check)
if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['active']:
raise osv.except_osv(_('Bad account!'), _('You can not use an inactive account!'))
if 'journal_id' in vals:
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp