Skip to content

Commit

Permalink
[MIG] account_check_deposit from v17 to v18
Browse files Browse the repository at this point in the history
  • Loading branch information
alexis-via committed Dec 20, 2024
1 parent 4390e44 commit f797600
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 40 deletions.
4 changes: 2 additions & 2 deletions account_check_deposit/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 10 additions & 4 deletions account_check_deposit/models/account_check_deposit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
2 changes: 1 addition & 1 deletion account_check_deposit/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions account_check_deposit/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,8 @@ <h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
<p>When you receive a check that pays a customer invoice, you can go to
that invoice and click on the button <em>Register Payment</em> and select the
<em>Checks Received</em> journal as <em>Journal</em>.</p>
that invoice and click on the button <em>Pay</em> and select the <em>Checks
Received</em> journal as <em>Journal</em>.</p>
<p>When you want to deposit checks to the bank, go to the menu <em>Invoicing &gt;
Customers &gt; Checks Deposits</em>, create a new check deposit and set the
journal <em>Checks Received</em> and select the bank account on which you want
Expand Down
13 changes: 7 additions & 6 deletions account_check_deposit/tests/test_check_deposit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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,
}
)
Expand Down Expand Up @@ -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
Expand All @@ -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)
40 changes: 15 additions & 25 deletions account_check_deposit/views/account_check_deposit_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
context="{'currency': currency_id,
'journal_id': journal_id}"
>
<tree>
<list>
<field name="date" />
<field name="date_maturity" optional="hide" />
<field name="journal_id" optional="hide" />
Expand All @@ -123,37 +123,32 @@
sum="1"
optional="hide"
/>
<field name="currency_id" invisible="1" />
<field name="company_currency_id" invisible="1" />
<field name="full_reconcile_id" optional="show" />
</tree>
<field name="currency_id" column_invisible="1" />
<field
name="company_currency_id"
column_invisible="1"
/>
<field name="matching_number" optional="show" />
</list>
</field>
</group>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers" />
<field name="activity_ids" widget="mail_activity" />
<field name="message_ids" widget="mail_thread" />
</div>
<chatter />
</form>
</field>
</record>
<record id="account_check_deposit_view_tree" model="ir.ui.view">
<field name="name">account.check.deposit.tree</field>
<field name="name">account.check.deposit.list</field>
<field name="model">account.check.deposit</field>
<field name="arch" type="xml">
<tree>
<list>
<field name="name" decoration-bf="1" />
<field name="deposit_date" />
<field name="journal_id" />
<field name="journal_id" optional="hide" />
<field name="bank_journal_id" />
<field name="check_count" />
<field name="total_amount" decoration-bf="1" />
<field
name="currency_id"
groups="base.group_multi_currency"
optional="show"
/>
<field name="currency_id" column_invisible="1" />
<field
name="company_id"
groups="base.group_multi_company"
Expand All @@ -165,7 +160,7 @@
decoration-info="state == 'draft'"
decoration-success="state == 'done'"
/>
</tree>
</list>
</field>
</record>
<record id="view_check_deposit_search" model="ir.ui.view">
Expand All @@ -192,11 +187,6 @@
string="Deposit Date"
context="{'group_by': 'deposit_date'}"
/>
<filter
name="journal_groupby"
string="Check Journal"
context="{'group_by': 'journal_id'}"
/>
<filter
name="bank_journal_id_groupby"
string="Bank Account"
Expand All @@ -219,7 +209,7 @@
<record id="action_check_deposit_tree" model="ir.actions.act_window">
<field name="name">Checks Deposits</field>
<field name="res_model">account.check.deposit</field>
<field name="view_mode">tree,form,pivot</field>
<field name="view_mode">list,form,pivot</field>
</record>
<menuitem
action="action_check_deposit_tree"
Expand Down

0 comments on commit f797600

Please sign in to comment.