Skip to content

Commit 8627284

Browse files
committed
[FIX] account_payment_order: Permissions of default users in accounting tests
1 parent 311be5c commit 8627284

File tree

7 files changed

+109
-53
lines changed

7 files changed

+109
-53
lines changed

account_payment_order/README.rst

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
.. image:: https://odoo-community.org/readme-banner-image
2-
:target: https://odoo-community.org/get-involved?utm_source=readme
3-
:alt: Odoo Community Association
4-
51
=====================
62
Account Payment Order
73
=====================
@@ -17,7 +13,7 @@ Account Payment Order
1713
.. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png
1814
:target: https://odoo-community.org/page/development-status
1915
:alt: Mature
20-
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
2117
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
2218
:alt: License: AGPL-3
2319
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fbank--payment-lightgray.png?logo=github
@@ -44,9 +40,9 @@ Installation
4440

4541
This module depends on:
4642

47-
- account_payment_partner
48-
- base_iban
49-
- document
43+
- account_payment_partner
44+
- base_iban
45+
- document
5046

5147
This modules is part of the OCA/bank-payment suite.
5248

@@ -95,41 +91,42 @@ Authors
9591
Contributors
9692
------------
9793

98-
- Stéphane Bidoul <stephane.bidoul@acsone.eu>
99-
- Alexis de Lattre <alexis.delattre@akretion.com>
100-
- Adrien Peiffer <adrien.peiffer@acsone.eu>
101-
- Stefan Rijnhart
102-
- Laurent Mignon <laurent.mignon@acsone.eu>
103-
- Alexandre Fayolle
104-
- Danimar Ribeiro
105-
- Erwin van der Ploeg
106-
- Raphaël Valyi
107-
- Sandy Carter
108-
- Angel Moya <angel.moya@domatix.com>
109-
- Jose María Alzaga <jose.alzaga@aselcis.com>
110-
- Meyomesse Gilles <meyomesse.gilles@gmail.com>
111-
- Denis Roussel <denis.roussel@acsone.eu>
112-
- `DynApps <https://www.dynapps.be>`__:
94+
- Stéphane Bidoul <stephane.bidoul@acsone.eu>
95+
- Alexis de Lattre <alexis.delattre@akretion.com>
96+
- Adrien Peiffer <adrien.peiffer@acsone.eu>
97+
- Stefan Rijnhart
98+
- Laurent Mignon <laurent.mignon@acsone.eu>
99+
- Alexandre Fayolle
100+
- Danimar Ribeiro
101+
- Erwin van der Ploeg
102+
- Raphaël Valyi
103+
- Sandy Carter
104+
- Angel Moya <angel.moya@domatix.com>
105+
- Jose María Alzaga <jose.alzaga@aselcis.com>
106+
- Meyomesse Gilles <meyomesse.gilles@gmail.com>
107+
- Denis Roussel <denis.roussel@acsone.eu>
108+
- `DynApps <https://www.dynapps.be>`__:
113109

114-
- Raf Ven <raf.ven@dynapps.be>
110+
- Raf Ven <raf.ven@dynapps.be>
115111

116-
- Andrea Stirpe <a.stirpe@onestein.nl>
117-
- `Jarsa <https://www.jarsa.com.mx>`__:
112+
- Andrea Stirpe <a.stirpe@onestein.nl>
113+
- `Jarsa <https://www.jarsa.com.mx>`__:
118114

119-
- Alan Ramos <alan.ramos@jarsa.com.mx>
115+
- Alan Ramos <alan.ramos@jarsa.com.mx>
120116

121-
- `Tecnativa <https://www.tecnativa.com>`__:
117+
- `Tecnativa <https://www.tecnativa.com>`__:
122118

123-
- Pedro M. Baeza
124-
- Carlos Dauden
125-
- Carlos Roca
126-
- Carlos Lopez
119+
- Pedro M. Baeza
120+
- Carlos Dauden
121+
- Carlos Roca
122+
- Carlos Lopez
127123

128-
- `Open Source Integrators <https://www.opensourceintegrators.com>`__:
124+
- `Open Source Integrators <https://www.opensourceintegrators.com>`__:
129125

130-
- Ammar Officewala <aofficewala@opensourceintegrators.com>
126+
- Ammar Officewala <aofficewala@opensourceintegrators.com>
131127

132-
- Marçal Isern <marsal.isern@qubiq.es>
128+
- Marçal Isern <marsal.isern@qubiq.es>
129+
- Simone Rubino <simone.rubino88@gmail.com>
133130

134131
Maintainers
135132
-----------

account_payment_order/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
from . import models
33
from . import report
44
from . import wizard
5+
6+
from . import patch_tests
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright 2025 Simone Rubino
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
"""
5+
Some test classes inheriting from AccountTestInvoicingCommon
6+
assume that the default users can create `res.partner.bank` records.
7+
One example is the core module `l10n_it_edi`
8+
in https://github.com/odoo/odoo/blob/
9+
b1a91bac849871ec37510fa97747285fe373bd22/addons/l10n_it_edi/tests/common.py#L59.
10+
Due to Odoo's modular architecture, these test classes' module
11+
might not even have `account_payment_order` in their dependencies.
12+
13+
With this patch, default users in
14+
test classes inheriting from AccountTestInvoicingCommon
15+
are able to create `res.partner.bank` records.
16+
"""
17+
18+
from odoo.tools import config
19+
20+
if config["test_enable"] or config["test_file"]:
21+
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
22+
23+
original_get_default_groups = AccountTestInvoicingCommon.get_default_groups
24+
25+
@classmethod
26+
def patched_default_groups(cls):
27+
groups = original_get_default_groups.__func__(cls)
28+
if new_group := cls.env.ref(
29+
"account_payment_order.group_account_payment",
30+
raise_if_not_found=False,
31+
):
32+
groups |= new_group
33+
return groups
34+
35+
AccountTestInvoicingCommon.get_default_groups = patched_default_groups

account_payment_order/readme/CONTRIBUTORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@
2525
- [Open Source Integrators](https://www.opensourceintegrators.com):
2626
- Ammar Officewala \<<aofficewala@opensourceintegrators.com>\>
2727
- Marçal Isern \<<marsal.isern@qubiq.es>\>
28+
- Simone Rubino \<<simone.rubino88@gmail.com>\>

account_payment_order/static/description/index.html

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
55
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6-
<title>README.rst</title>
6+
<title>Account Payment Order</title>
77
<style type="text/css">
88

99
/*
@@ -360,21 +360,16 @@
360360
</style>
361361
</head>
362362
<body>
363-
<div class="document">
363+
<div class="document" id="account-payment-order">
364+
<h1 class="title">Account Payment Order</h1>
364365

365-
366-
<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
367-
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
368-
</a>
369-
<div class="section" id="account-payment-order">
370-
<h1>Account Payment Order</h1>
371366
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
372367
!! This file is generated by oca-gen-addon-readme !!
373368
!! changes will be overwritten. !!
374369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375370
!! source digest: sha256:72673b3679b6a9a9174d5a3d91206868d924cdcfde7226b60ede0f21b20f590d
376371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Mature" src="https://img.shields.io/badge/maturity-Mature-brightgreen.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/bank-payment/tree/18.0/account_payment_order"><img alt="OCA/bank-payment" src="https://img.shields.io/badge/github-OCA%2Fbank--payment-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/bank-payment-18-0/bank-payment-18-0-account_payment_order"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/bank-payment&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
372+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Mature" src="https://img.shields.io/badge/maturity-Mature-brightgreen.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/bank-payment/tree/18.0/account_payment_order"><img alt="OCA/bank-payment" src="https://img.shields.io/badge/github-OCA%2Fbank--payment-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/bank-payment-18-0/bank-payment-18-0-account_payment_order"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/bank-payment&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378373
<p>This module adds support for payment orders and debit orders.</p>
379374
<p><strong>Table of contents</strong></p>
380375
<div class="contents local topic" id="contents">
@@ -392,7 +387,7 @@ <h1>Account Payment Order</h1>
392387
</ul>
393388
</div>
394389
<div class="section" id="installation">
395-
<h2><a class="toc-backref" href="#toc-entry-1">Installation</a></h2>
390+
<h1><a class="toc-backref" href="#toc-entry-1">Installation</a></h1>
396391
<p>This module depends on:</p>
397392
<ul class="simple">
398393
<li>account_payment_partner</li>
@@ -402,12 +397,12 @@ <h2><a class="toc-backref" href="#toc-entry-1">Installation</a></h2>
402397
<p>This modules is part of the OCA/bank-payment suite.</p>
403398
</div>
404399
<div class="section" id="configuration">
405-
<h2><a class="toc-backref" href="#toc-entry-2">Configuration</a></h2>
400+
<h1><a class="toc-backref" href="#toc-entry-2">Configuration</a></h1>
406401
<p>This module adds several options on Payment Modes, cf
407402
Invoicing/Accounting &gt; Configuration &gt; Management &gt; Payment Modes.</p>
408403
</div>
409404
<div class="section" id="usage">
410-
<h2><a class="toc-backref" href="#toc-entry-3">Usage</a></h2>
405+
<h1><a class="toc-backref" href="#toc-entry-3">Usage</a></h1>
411406
<p>You can create a Payment order via the menu Invoicing/Accounting &gt;
412407
Vendors &gt; Payment Orders and then select the move lines to pay.</p>
413408
<p>You can create a Debit order via the menu Invoicing/Accounting &gt;
@@ -418,17 +413,17 @@ <h2><a class="toc-backref" href="#toc-entry-3">Usage</a></h2>
418413
Vendors &gt; Payment Orders and then select the payment oder to print.</p>
419414
</div>
420415
<div class="section" id="bug-tracker">
421-
<h2><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h2>
416+
<h1><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h1>
422417
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/bank-payment/issues">GitHub Issues</a>.
423418
In case of trouble, please check there if your issue has already been reported.
424419
If you spotted it first, help us to smash it by providing a detailed and welcomed
425420
<a class="reference external" href="https://github.com/OCA/bank-payment/issues/new?body=module:%20account_payment_order%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
426421
<p>Do not contact contributors directly about support or help with technical issues.</p>
427422
</div>
428423
<div class="section" id="credits">
429-
<h2><a class="toc-backref" href="#toc-entry-5">Credits</a></h2>
424+
<h1><a class="toc-backref" href="#toc-entry-5">Credits</a></h1>
430425
<div class="section" id="authors">
431-
<h3><a class="toc-backref" href="#toc-entry-6">Authors</a></h3>
426+
<h2><a class="toc-backref" href="#toc-entry-6">Authors</a></h2>
432427
<ul class="simple">
433428
<li>ACSONE SA/NV</li>
434429
<li>Therp BV</li>
@@ -437,7 +432,7 @@ <h3><a class="toc-backref" href="#toc-entry-6">Authors</a></h3>
437432
</ul>
438433
</div>
439434
<div class="section" id="contributors">
440-
<h3><a class="toc-backref" href="#toc-entry-7">Contributors</a></h3>
435+
<h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
441436
<ul class="simple">
442437
<li>Stéphane Bidoul &lt;<a class="reference external" href="mailto:stephane.bidoul&#64;acsone.eu">stephane.bidoul&#64;acsone.eu</a>&gt;</li>
443438
<li>Alexis de Lattre &lt;<a class="reference external" href="mailto:alexis.delattre&#64;akretion.com">alexis.delattre&#64;akretion.com</a>&gt;</li>
@@ -474,10 +469,11 @@ <h3><a class="toc-backref" href="#toc-entry-7">Contributors</a></h3>
474469
</ul>
475470
</li>
476471
<li>Marçal Isern &lt;<a class="reference external" href="mailto:marsal.isern&#64;qubiq.es">marsal.isern&#64;qubiq.es</a>&gt;</li>
472+
<li>Simone Rubino &lt;<a class="reference external" href="mailto:simone.rubino88&#64;gmail.com">simone.rubino88&#64;gmail.com</a>&gt;</li>
477473
</ul>
478474
</div>
479475
<div class="section" id="maintainers">
480-
<h3><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h3>
476+
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
481477
<p>This module is maintained by the OCA.</p>
482478
<a class="reference external image-reference" href="https://odoo-community.org">
483479
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
@@ -490,6 +486,5 @@ <h3><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h3>
490486
</div>
491487
</div>
492488
</div>
493-
</div>
494489
</body>
495490
</html>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from . import test_payment_mode
22
from . import test_bank
3+
from . import test_partner_bank
34
from . import test_payment_order_inbound
45
from . import test_payment_order_outbound
56
from . import test_account_payment
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2025 Simone Rubino
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo.tests import Form, tagged
5+
6+
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
7+
8+
9+
@tagged("post_install", "-at_install")
10+
class TestPartnerBank(AccountTestInvoicingCommon):
11+
def test_default_user_create(self):
12+
"""The default user in tests can create partner bank accounts."""
13+
# Arrange
14+
partner_form = Form(self.env["res.partner"])
15+
partner_form.name = "Test Partner"
16+
partner = partner_form.save()
17+
18+
# Act
19+
partner_bank_form = Form(self.env["res.partner.bank"])
20+
partner_bank_form.acc_number = "Test Account Number"
21+
partner_bank_form.partner_id = partner
22+
partner_bank = partner_bank_form.save()
23+
24+
# Assert
25+
self.assertTrue(partner_bank)

0 commit comments

Comments
 (0)