diff --git a/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_period_workflow/scripts/checkTransactionsState.py b/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_period_workflow/scripts/checkTransactionsState.py
index fb632a299305562f45999d4b97d0003bc3bbad54..80c0f9834b7d0dda3700107f35c50b859c0c75ce 100644
--- a/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_period_workflow/scripts/checkTransactionsState.py
+++ b/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_period_workflow/scripts/checkTransactionsState.py
@@ -73,6 +73,10 @@ movement_list = portal.portal_simulation.getMovementHistoryList(
       from_date=period.getStartDate().earliestTime(),
       at_date=period.getStopDate().latestTime(),
       simulation_state=invalid_simulation_state_list,
+      # We only consider accounting movements really using accounts as node.
+      # There could be a line in stock table because the node is an organisation acquired
+      # from parent invoice.
+      node_uid=[node.uid for node in portal.portal_catalog(portal_type='Account')],
       portal_type=portal.getPortalAccountingMovementTypeList(),
       limit=1)
 
diff --git a/product/ERP5/tests/testAccounting.py b/product/ERP5/tests/testAccounting.py
index 88a06a02174905b5a33487e717d17b1a780030be..3bb78cefb29980398fbca19005c38fbf8240252e 100644
--- a/product/ERP5/tests/testAccounting.py
+++ b/product/ERP5/tests/testAccounting.py
@@ -3024,10 +3024,70 @@ class TestClosingPeriod(AccountingTestCase):
            period, 'stop_action',
            profit_and_loss_account=pl.getRelativeUrl())
 
-    self.assertRaises(ValidationFailed,
-          self.getPortal().portal_workflow.doActionFor,
-          period2, 'stop_action' )
+    with self.assertRaisesRegexp(ValidationFailed,
+        '.*Previous accounting periods has to be closed first.*'):
+      self.getPortal().portal_workflow.doActionFor(
+        period2, 'stop_action')
+
+  def test_PeriodClosingRefusedWhenTransactionAreNotStopped(self):
+    organisation_module = self.organisation_module
+    period = self.section.newContent(portal_type='Accounting Period')
+    period.setStartDate(DateTime(2006, 1, 1))
+    period.setStopDate(DateTime(2006, 12, 31))
+    period.start()
+
+    pl = self.portal.account_module.newContent(
+      portal_type='Account',
+      account_type='equity')
 
+    transaction1 = self._makeOne(
+      start_date=DateTime(2006, 1, 1),
+      destination_section_value=organisation_module.client_1,
+      portal_type='Sale Invoice Transaction',
+      simulation_state='stopped',
+      lines=(dict(source_value=self.account_module.goods_sales,
+                  source_credit=100),
+             dict(source_value=self.account_module.receivable,
+                  source_debit=100)))
+
+    with self.assertRaisesRegexp(
+        ValidationFailed,
+       'All Accounting Transactions for this organisation during'
+       ' the period have to be closed first'):
+      self.portal.portal_workflow.doActionFor(
+        period,
+        'stop_action')
+
+  def test_PeriodClosingRefusedWhenTransactionAreNotStoppedIgnoreInternalLine(self):
+    period = self.section.newContent(portal_type='Accounting Period')
+    period.setStartDate(DateTime(2006, 1, 1))
+    period.setStopDate(DateTime(2006, 12, 31))
+    period.start()
+
+    pl = self.portal.account_module.newContent(
+      portal_type='Account',
+      account_type='equity')
+
+    # This transaction has lines that should block closing for `main_section`,
+    # but not for `section` because from `section` side there are no accounting lines.
+    transaction1 = self._makeOne(
+      start_date=DateTime(2006, 1, 1),
+      source_section_value=self.main_section,
+      source_value=self.main_section,
+      destination_section_value=self.section,
+      destination_value=self.section,
+      portal_type='Sale Invoice Transaction',
+      simulation_state='stopped',
+      lines=(dict(source_value=self.account_module.goods_sales,
+                  source_credit=100),
+             dict(source_value=self.account_module.receivable,
+                  source_debit=100)))
+
+    self.portal.portal_workflow.doActionFor(
+      period,
+      'stop_action',
+      profit_and_loss_account=pl.getRelativeUrl())
+    self.tic()
 
 
 class TestAccountingExport(AccountingTestCase):