Add a configuration parameter to use entry_posted journal setting. Add update_posted in journal items to display or not the button cancel.

This commit is contained in:
Laetitia Gangloff
2015-06-30 10:48:25 +02:00
committed by Stéphane Bidoul
parent 48385fbfeb
commit afe5a0e285
12 changed files with 231 additions and 37 deletions

View File

@@ -1,16 +1,8 @@
# -*- coding: utf-8 -*-
#
##############################################################################
#
# Authors: Adrien Peiffer
# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu)
# All Rights Reserved
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs.
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly advised to contact a Free Software
# Service Company.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@@ -25,6 +17,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
##############################################################################
from . import test_account_default_draft_move

View File

@@ -1,16 +1,8 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# Authors: Adrien Peiffer
# Authors: Adrien Peiffer, Laetitia Gangloff
# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu)
# All Rights Reserved
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs.
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly advised to contact a Free Software
# Service Company.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@@ -25,13 +17,15 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
##############################################################################
import openerp.tests.common as common
from datetime import datetime
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT
from openerp import workflow
import time
def create_simple_invoice(self):
partner_id = self.ref('base.res_partner_2')
@@ -58,13 +52,69 @@ def create_simple_invoice(self):
})
def create_simple_bank_statement(self):
return self.env['account.bank.statement'].create({
'journal_id': self.ref("account.bank_journal"),
'date': time.strftime('%Y') + '-07-15',
'balance_end_real': 42,
'line_ids': [(0, 0, {'name': 'my payment',
'partner_id': self.ref('base.res_partner_2'),
'amount': 42,
'date': time.strftime('%Y') + '-07-15',
'account_id': self.ref('account.bnk')
})]
})
class TestAccountDefaultDraftMove(common.TransactionCase):
def setUp(self):
super(TestAccountDefaultDraftMove, self).setUp()
def test_draft_move_invoice(self):
invoice = create_simple_invoice(self)
workflow.trg_validate(self.uid, 'account.invoice', invoice.id,
'invoice_open', self.cr)
self.assertEqual(invoice.move_id.state, 'draft', 'State error!')
invoice = create_simple_invoice(self)
workflow.trg_validate(self.uid, 'account.invoice', invoice.id,
'invoice_open', self.cr)
self.assertEqual(invoice.move_id.state, 'draft', 'State error!')
def test_draft_move_statement(self):
statement = create_simple_bank_statement(self)
statement.button_confirm_bank()
self.assertEqual(statement.move_line_ids[0].move_id.state,
'draft', 'State error!')
def test_config_move_invoice(self):
# update configuration to take account of the journal settings
self.env['ir.config_parameter'].set_param('use_journal_setting', True)
# set entry posted to False
journal = self.env['account.journal'].browse(
self.ref('account.sales_journal'))
journal.entry_posted = False
invoice = create_simple_invoice(self)
workflow.trg_validate(self.uid, 'account.invoice', invoice.id,
'invoice_open', self.cr)
self.assertEqual(invoice.move_id.state, 'draft', 'State error!')
journal.entry_posted = True
invoice = create_simple_invoice(self)
workflow.trg_validate(self.uid, 'account.invoice', invoice.id,
'invoice_open', self.cr)
self.assertEqual(invoice.move_id.state, 'posted', 'State error!')
def test_config_move_statement(self):
# update configuration to take account of the journal settings
self.env['ir.config_parameter'].set_param('use_journal_setting', True)
# set entry posted to False
journal = self.env['account.journal'].browse(
self.ref('account.bank_journal'))
journal.entry_posted = False
statement = create_simple_bank_statement(self)
statement.button_confirm_bank()
self.assertEqual(statement.move_line_ids[0].move_id.state,
'draft', 'State error!')
journal.entry_posted = True
statement = create_simple_bank_statement(self)
statement.button_confirm_bank()
self.assertEqual(statement.move_line_ids[0].move_id.state,
'posted', 'State error!')