Cédric Krier pushed to branch branch/default at Tryton / Tryton


Commits:
d11513ca by Cédric Krier at 2023-03-14T00:15:47+01:00
Deactivate numbers when bank account is deactivated
- - - - -
0532d49c by Cédric Krier at 2023-03-14T00:16:54+01:00
Do not consider as valid mandate linked to an inactive account number

Closes #8065
- - - - -


4 changed files:

- modules/account_payment_sepa/payment.py
- modules/bank/CHANGELOG
- modules/bank/bank.py
- modules/bank/view/bank_account_number_form.xml


Changes:

=====================================
modules/account_payment_sepa/payment.py
=====================================
@@ -685,7 +685,7 @@
 
     @property
     def is_valid(self):
-        if self.state == 'validated':
+        if self.state == 'validated' and self.account_number.active:
             if self.type == 'one-off':
                 if not self.has_payments:
                     return True


=====================================
modules/bank/CHANGELOG
=====================================
@@ -1,3 +1,4 @@
+* Deactivate numbers when account is deactivated
 * Remove support for Python 3.7
 * Add support for Python 3.11
 


=====================================
modules/bank/bank.py
=====================================
@@ -14,6 +14,7 @@
 from trytond.model import (
     DeactivableMixin, Exclude, ModelSQL, ModelView, fields, sequence_ordered)
 from trytond.pool import Pool
+from trytond.pyson import Eval, If
 from trytond.tools import is_full_text, lstrip_wildcard
 
 from .exceptions import AccountValidationError, IBANValidationError, InvalidBIC
@@ -94,7 +95,11 @@
     owners = fields.Many2Many('bank.account-party.party', 'account', 'owner',
         'Owners')
     currency = fields.Many2One('currency.currency', 'Currency')
-    numbers = fields.One2Many('bank.account.number', 'account', 'Numbers',
+    numbers = fields.One2Many(
+        'bank.account.number', 'account', 'Numbers',
+        domain=[
+            If(~Eval('active'), ('active', '=', False), ()),
+            ],
         help="Add the numbers which identify the bank account.")
 
     def get_rec_name(self, name):
@@ -171,9 +176,9 @@
                 return Bank.from_bic(iban.bic)
 
 
-class AccountNumber(sequence_ordered(), ModelSQL, ModelView):
+class AccountNumber(DeactivableMixin, sequence_ordered(), ModelSQL, ModelView):
     'Bank Account Number'
     __name__ = 'bank.account.number'
     _rec_name = 'number'
     account = fields.Many2One(
         'bank.account', "Account", required=True, ondelete='CASCADE',
@@ -175,8 +180,11 @@
     'Bank Account Number'
     __name__ = 'bank.account.number'
     _rec_name = 'number'
     account = fields.Many2One(
         'bank.account', "Account", required=True, ondelete='CASCADE',
+        domain=[
+            If(Eval('active'), ('active', '=', True), ()),
+            ],
         help="The bank account which is identified by the number.")
     type = fields.Selection([
             ('iban', 'IBAN'),


=====================================
modules/bank/view/bank_account_number_form.xml
=====================================
@@ -4,8 +4,13 @@
 <form cursor="number">
     <label name="account"/>
     <field name="account"/>
-    <label name="sequence"/>
-    <field name="sequence"/>
+    <group col="-1" colspan="2" id="checkboxes">
+        <label name="active"/>
+        <field name="active" xexpand="0" width="25"/>
+        <label name="sequence"/>
+        <field name="sequence"/>
+    </group>
+
     <label name="type"/>
     <field name="type"/>
     <label name="number"/>



View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/compare/b5d20cfccdd707721c1465f5b8ca0262d7c9c5db...0532d49cd438ceba1d09c82892a937e0427fd3d0

-- 
View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/compare/b5d20cfccdd707721c1465f5b8ca0262d7c9c5db...0532d49cd438ceba1d09c82892a937e0427fd3d0
You're receiving this email because of your account on foss.heptapod.net.


Reply via email to