[FIX] account: the readonly fields aren't send to the server at the record creation

bzr revid: qdp-launchpad@openerp.com-20121019133050-7h8gx3beir992xlw
This commit is contained in:
Quentin (OpenERP) 2012-10-19 15:30:50 +02:00
parent 5d315fac34
commit 5b4fde2485
3 changed files with 11 additions and 8 deletions

View File

@ -1431,6 +1431,9 @@ class account_move(osv.osv):
if 'line_id' in vals:
c = context.copy()
c['novalidate'] = True
c['period_id'] = vals['period_id']
c['journal_id'] = vals['journal_id']
c['date'] = vals['date']
result = super(account_move, self).create(cr, uid, vals, c)
self.validate(cr, uid, [result], context)
else:

View File

@ -1234,16 +1234,16 @@ class account_move_line(osv.osv):
vals['company_id'] = company_id[0]
if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['active']:
raise osv.except_osv(_('Bad Account!'), _('You cannot use an inactive account.'))
if 'journal_id' in vals:
if 'journal_id' in vals and vals['journal_id']:
context['journal_id'] = vals['journal_id']
if 'period_id' in vals:
if 'period_id' in vals and vals['period_id']:
context['period_id'] = vals['period_id']
if ('journal_id' not in context) and ('move_id' in vals) and vals['move_id']:
m = move_obj.browse(cr, uid, vals['move_id'])
context['journal_id'] = m.journal_id.id
context['period_id'] = m.period_id.id
#we need to treat the case where a value is given in the context for period_id as a string
if 'period_id' not in context or not isinstance(context.get('period_id', ''), (int, long)):
if 'period_id' in context and not isinstance(context.get('period_id', ''), (int, long)):
period_candidate_ids = self.pool.get('account.period').name_search(cr, uid, name=context.get('period_id',''))
if len(period_candidate_ids) != 1:
raise osv.except_osv(_('Error!'), _('No period found or more than one period found for the given date.'))
@ -1253,6 +1253,9 @@ class account_move_line(osv.osv):
self._update_journal_check(cr, uid, context['journal_id'], context['period_id'], context)
move_id = vals.get('move_id', False)
journal = journal_obj.browse(cr, uid, context['journal_id'], context=context)
vals['journal_id'] = vals.get('journal_id') or context.get('journal_id')
vals['period_id'] = vals.get('period_id') or context.get('period_id')
vals['date'] = vals.get('date') or context.get('date')
if not move_id:
if journal.centralisation:
#Check for centralisation

View File

@ -11,21 +11,18 @@
-
!record {model: account.move, id: account_move_0}:
date: !eval time.strftime('%Y-%m-%d')
period_id: account.period_6
journal_id: account.bank_journal
line_id:
- account_id: account.cash
amount_currency: 0.0
credit: 2000.0
date: !eval time.strftime('%Y-%m-%d')
debit: 0.0
journal_id: account.bank_journal
name: Basic Computer
partner_id: base.res_partner_12
period_id: account.period_6
ref: '2011010'
tax_amount: 0.0
name: /
period_id: account.period_6
ref: '2011010'
state: draft
-
@ -110,4 +107,4 @@
partial_reconcile = self.trans_rec_reconcile_partial_reconcile(cr, uid, [ref('account_move_line_reconcile0')], {'lang': u'en_US',
'active_model': 'account.move.line', 'active_ids': ids, 'tz': False, 'active_id': ids[0]})
move_line = move_line_obj.browse(cr, uid, ids)
assert move_line[0].reconcile_partial_id, "Partial reconcilation is not done"
assert move_line[0].reconcile_partial_id, "Partial reconcilation is not done"