diff --git a/addons/account/account.py b/addons/account/account.py index ebc1f23a44d..46e7b3457ec 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -1213,22 +1213,10 @@ class account_move(osv.osv): return False return True - def _check_period_journal(self, cursor, user, ids, context=None): - for move in self.browse(cursor, user, ids, context=context): - for line in move.line_id: - if line.period_id.id != move.period_id.id: - return False - if line.journal_id.id != move.journal_id.id: - return False - return True - _constraints = [ (_check_centralisation, 'You can not create more than one move per period on centralized journal', ['journal_id']), - (_check_period_journal, - 'You can not create journal items on different periods/journals in the same journal entry', - ['line_id']), ] def post(self, cr, uid, ids, context=None): @@ -1511,8 +1499,6 @@ class account_move(osv.osv): # Update the move lines (set them as valid) obj_move_line.write(cr, uid, line_draft_ids, { - 'journal_id': move.journal_id.id, - 'period_id': move.period_id.id, 'state': 'valid' }, context, check=False) @@ -1553,8 +1539,6 @@ class account_move(osv.osv): # We can't validate it (it's unbalanced) # Setting the lines as draft obj_move_line.write(cr, uid, line_ids, { - 'journal_id': move.journal_id.id, - 'period_id': move.period_id.id, 'state': 'draft' }, context, check=False) # Create analytic lines for the valid moves diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index e105765a31c..5de7fed2428 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -494,8 +494,14 @@ class account_move_line(osv.osv): 'amount_residual_currency': fields.function(_amount_residual, string='Residual Amount', multi="residual", help="The residual amount on a receivable or payable of a journal entry expressed in its currency (maybe different of the company currency)."), 'amount_residual': fields.function(_amount_residual, string='Residual Amount', multi="residual", help="The residual amount on a receivable or payable of a journal entry expressed in the company currency."), 'currency_id': fields.many2one('res.currency', 'Currency', help="The optional other currency if it is a multi-currency entry."), - 'period_id': fields.many2one('account.period', 'Period', required=True, select=2), - 'journal_id': fields.many2one('account.journal', 'Journal', required=True, select=1), + 'journal_id': fields.related('move_id', 'journal_id', string='Journal', type='many2one', relation='account.journal', required=True, select=True, readonly=True, + store = { + 'account.move': (_get_move_lines, ['journal_id'], 20) + }), + 'period_id': fields.related('move_id', 'period_id', string='Period', type='many2one', relation='account.period', required=True, select=True, readonly=True, + store = { + 'account.move': (_get_move_lines, ['period_id'], 20) + }), 'blocked': fields.boolean('Litigation', help="You can check this box to mark this journal item as a litigation with the associated partner"), 'partner_id': fields.many2one('res.partner', 'Partner', select=1, ondelete='restrict'), 'date_maturity': fields.date('Due date', select=True ,help="This field is used for payable and receivable journal entries. You can put the limit date for the payment of this line."),