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


Commits:
f01efcd5 by Cédric Krier at 2023-02-15T23:06:35+01:00
Use generic name for warning exception when deleting account reconciliation
- - - - -
900d8e24 by Cédric Krier at 2023-02-15T23:08:06+01:00
Use format for the warning key when deleting reconciliation with delegated
- - - - -
b9d13b0d by Cédric Krier at 2023-02-15T23:08:53+01:00
Add warning when deleting account reconciliation with write-off line

Closes #4685
- - - - -


3 changed files:

- modules/account/exceptions.py
- modules/account/message.xml
- modules/account/move.py


Changes:

=====================================
modules/account/exceptions.py
=====================================
@@ -85,7 +85,7 @@
     pass
 
 
-class DeleteDelegatedWarning(UserWarning):
+class ReconciliationDeleteWarning(UserWarning):
     pass
 
 


=====================================
modules/account/message.xml
=====================================
@@ -151,6 +151,10 @@
             <field name="text">The reconciliation "%(reconciliation)s" is 
delegated to the line "%(line)s".
 You may need to cancel its move "%(move)s".</field>
         </record>
+        <record model="ir.message" id="msg_reconciliation_delete_write_off">
+            <field name="text">The reconciliation "%(reconciliation)s" is 
linked to the write-off line "%(line)s".
+You may need to cancel its move "%(move)s".</field>
+        </record>
         <record model="ir.message" id="msg_reconciliation_line_not_valid">
             <field name="text">You cannot reconcile non-valid line 
"%(line)s".</field>
         </record>


=====================================
modules/account/move.py
=====================================
@@ -28,8 +28,8 @@
     Button, StateAction, StateTransition, StateView, Wizard)
 
 from .exceptions import (
-    CancelDelegatedWarning, CancelWarning, DelegateLineError,
-    DeleteDelegatedWarning, GroupLineError, MoveDatesError, PostError,
+    CancelDelegatedWarning, CancelWarning, DelegateLineError, GroupLineError,
+    MoveDatesError, PostError, ReconciliationDeleteWarning,
     ReconciliationError, RescheduleLineError)
 
 _MOVE_STATES = {
@@ -602,5 +602,5 @@
         Warning = pool.get('res.user.warning')
         for reconciliation in reconciliations:
             if reconciliation.delegate_to:
-                key = '%s.delete.delegated' % reconciliation
+                key = Warning.format('delete.delegated', [reconciliation])
                 if Warning.check(key):
@@ -606,6 +606,6 @@
                 if Warning.check(key):
-                    raise DeleteDelegatedWarning(key,
+                    raise ReconciliationDeleteWarning(key,
                         gettext('account.msg_reconciliation_delete_delegated',
                             reconciliation=reconciliation.rec_name,
                             line=reconciliation.delegate_to.rec_name,
                             move=reconciliation.delegate_to.move.rec_name))
@@ -608,7 +608,17 @@
                         gettext('account.msg_reconciliation_delete_delegated',
                             reconciliation=reconciliation.rec_name,
                             line=reconciliation.delegate_to.rec_name,
                             move=reconciliation.delegate_to.move.rec_name))
+            for line in reconciliation.lines:
+                if line.move.journal.type == 'write-off':
+                    key = Warning.format('delete.write-off', [reconciliation])
+                    if Warning.check(key):
+                        raise ReconciliationDeleteWarning(key,
+                            gettext(
+                                'account.msg_reconciliation_delete_write_off',
+                                reconciliation=reconciliation.rec_name,
+                                line=line.rec_name,
+                                move=line.move.rec_name))
         super().delete(reconciliations)
 
     @classmethod



View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/compare/7ed22d87e7ae50c046386676ac4d39228c9b086b...b9d13b0df6f3f3faff06ddd12d2c141a3aee1185

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


Reply via email to