diff --git a/account_check_deposit/README.rst b/account_check_deposit/README.rst index 9ac55044116..fc046bcdde8 100644 --- a/account_check_deposit/README.rst +++ b/account_check_deposit/README.rst @@ -73,8 +73,8 @@ Usage ===== When you receive a check that pays a customer invoice, you can go to -that invoice and click on the button *Register Payment* and select the -*Checks Received* journal as *Journal*. +that invoice and click on the button *Pay* and select the *Checks +Received* journal as *Journal*. When you want to deposit checks to the bank, go to the menu *Invoicing > Customers > Checks Deposits*, create a new check deposit and set the diff --git a/account_check_deposit/models/account_check_deposit.py b/account_check_deposit/models/account_check_deposit.py index 0e7b2fbcf6e..d006a90b5da 100644 --- a/account_check_deposit/models/account_check_deposit.py +++ b/account_check_deposit/models/account_check_deposit.py @@ -247,13 +247,19 @@ def _prepare_move_vals(self): if line.payment_method_id.code == "manual" and line.payment_account_id: counterpart_account_id = line.payment_account_id.id break + # inspired by _get_outstanding_account() on account.payment if not counterpart_account_id: - counterpart_account_id = ( - self.company_id.account_journal_payment_debit_account_id.id - ) + chart_template = self.with_context( + allowed_company_ids=self.company_id.root_id.ids + ).env["account.chart.template"] + counterpart_account_id = chart_template.ref( + "account_journal_payment_debit_account_id", raise_if_not_found=False + ).id + if not counterpart_account_id: + counterpart_account_id = self.company_id.transfer_account_id.id if not counterpart_account_id: raise UserError( - _("Missing 'Outstanding Receipts Account' on the company '%s'.") + _("Missing 'Internal Transfer' account on the company '%s'.") % self.company_id.display_name ) diff --git a/account_check_deposit/readme/USAGE.md b/account_check_deposit/readme/USAGE.md index f47ef5b93cd..b0d27f6aa73 100644 --- a/account_check_deposit/readme/USAGE.md +++ b/account_check_deposit/readme/USAGE.md @@ -1,5 +1,5 @@ When you receive a check that pays a customer invoice, you can go to -that invoice and click on the button *Register Payment* and select the +that invoice and click on the button *Pay* and select the *Checks Received* journal as *Journal*. When you want to deposit checks to the bank, go to the menu *Invoicing diff --git a/account_check_deposit/static/description/index.html b/account_check_deposit/static/description/index.html index 0786b62af91..544964d49a8 100644 --- a/account_check_deposit/static/description/index.html +++ b/account_check_deposit/static/description/index.html @@ -419,8 +419,8 @@

Configuration

Usage

When you receive a check that pays a customer invoice, you can go to -that invoice and click on the button Register Payment and select the -Checks Received journal as Journal.

+that invoice and click on the button Pay and select the Checks +Received journal as Journal.

When you want to deposit checks to the bank, go to the menu Invoicing > Customers > Checks Deposits, create a new check deposit and set the journal Checks Received and select the bank account on which you want diff --git a/account_check_deposit/tests/test_check_deposit.py b/account_check_deposit/tests/test_check_deposit.py index 5d19e11c3c6..ad9f9029c78 100644 --- a/account_check_deposit/tests/test_check_deposit.py +++ b/account_check_deposit/tests/test_check_deposit.py @@ -12,8 +12,8 @@ @tagged("post_install", "-at_install") class TestAccountCheckDeposit(AccountTestInvoicingCommon): @classmethod - def setUpClass(cls, chart_template_ref=None): - super().setUpClass(chart_template_ref=chart_template_ref) + def setUpClass(cls): + super().setUpClass() cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) cls.company = cls.company_data["company"] cls.user.write( @@ -26,13 +26,14 @@ def setUpClass(cls, chart_template_ref=None): cls.account_model = cls.env["account.account"] cls.partner = cls.env["res.partner"].create({"name": "Test partner"}) cls.currency = cls.company.currency_id + cls.iban_acc_number = "FR62 1234 5678 9012 3456 7890 A98" cls.received_check_account = cls.account_model.create( { "code": "5112ZZ", "name": "Received check - (test)", "reconcile": True, "account_type": "asset_current", - "company_id": cls.company.id, + "company_ids": [Command.set([cls.company.id])], } ) cls.check_journal = cls.env["account.journal"].create( @@ -59,7 +60,7 @@ def setUpClass(cls, chart_template_ref=None): "res.partner.bank" ].create( { - "acc_number": "SI56 1910 0000 0123 438 584", + "acc_number": cls.iban_acc_number, "partner_id": cls.company.partner_id.id, } ) @@ -117,7 +118,7 @@ def test_full_payment_process(self): ) payment = register_payments._create_payments() self.assertAlmostEqual(payment.amount, 300) - self.assertEqual(payment.state, "posted") + self.assertEqual(payment.state, "paid") check_deposit = self.create_check_deposit() self.assertEqual( check_deposit.in_hand_check_account_id, self.received_check_account @@ -132,4 +133,4 @@ def test_full_payment_process(self): res = self.env["ir.actions.report"]._render_qweb_text( "account_check_deposit.report_checkdeposit", check_deposit.ids ) - self.assertRegex(str(res[0]), "SI56 1910 0000 0123 438 584") + self.assertRegex(str(res[0]), self.iban_acc_number) diff --git a/account_check_deposit/views/account_check_deposit_view.xml b/account_check_deposit/views/account_check_deposit_view.xml index d6cfe00bcb2..0275bce4502 100644 --- a/account_check_deposit/views/account_check_deposit_view.xml +++ b/account_check_deposit/views/account_check_deposit_view.xml @@ -108,7 +108,7 @@ context="{'currency': currency_id, 'journal_id': journal_id}" > - + @@ -123,37 +123,32 @@ sum="1" optional="hide" /> - - - - + + + + -

- - - -
+ - account.check.deposit.tree + account.check.deposit.list account.check.deposit - + - + - + - + @@ -192,11 +187,6 @@ string="Deposit Date" context="{'group_by': 'deposit_date'}" /> - Checks Deposits account.check.deposit - tree,form,pivot + list,form,pivot