changeset 9962ae2940e6 in modules/account_payment:default
details: 
https://hg.tryton.org/modules/account_payment?cmd=changeset&node=9962ae2940e6
description:
        Permit to edit amount for manual payment in processing

        Payment processed manually can have mistakes in the amount.
        So by going back to processing, the user can edit the amount.

        issue11176
        review387791003
diffstat:

 CHANGELOG             |   1 +
 payment.py            |  16 +++++++++++++++-
 payment.xml           |  10 ++++++++++
 view/payment_form.xml |   1 +
 4 files changed, 27 insertions(+), 1 deletions(-)

diffs (79 lines):

diff -r cbca58c85330 -r 9962ae2940e6 CHANGELOG
--- a/CHANGELOG Wed Feb 23 00:01:17 2022 +0100
+++ b/CHANGELOG Sat Mar 19 22:31:21 2022 +0100
@@ -1,3 +1,4 @@
+* Permit to edit amount for manual payment in processing
 * Use reference field for statement line relation
 * Do not create dunning for line with pending payment
 * Add support for Python 3.10
diff -r cbca58c85330 -r 9962ae2940e6 payment.py
--- a/payment.py        Wed Feb 23 00:01:17 2022 +0100
+++ b/payment.py        Sat Mar 19 22:31:21 2022 +0100
@@ -305,7 +305,13 @@
     date = fields.Date('Date', required=True, states=_STATES, depends=_DEPENDS)
     amount = Monetary(
         "Amount", currency='currency', digits='currency', required=True,
-        states=_STATES, depends=_DEPENDS)
+        states={
+            'readonly': ~Eval('state').in_(
+                If(Eval('process_method') == 'manual',
+                    ['draft', 'processing'],
+                    ['draft'])),
+            },
+        depends=['state', 'process_method'])
     line = fields.Many2One('account.move.line', 'Line', ondelete='RESTRICT',
         domain=[
             ('move.company', '=', Eval('company', -1)),
@@ -405,6 +411,13 @@
                     'icon': 'tryton-forward',
                     'depends': ['state'],
                     },
+                'proceed': {
+                    'invisible': (
+                        ~Eval('state').in_(['succeeded', 'failed'])
+                        | (Eval('process_method') != 'manual')),
+                    'icon': 'tryton-back',
+                    'depends': ['state', 'process_method'],
+                    },
                 'succeed': {
                     'invisible': ~Eval('state').in_(
                         ['processing', 'failed']),
@@ -559,6 +572,7 @@
             return group
 
     @classmethod
+    @ModelView.button
     @Workflow.transition('processing')
     def proceed(cls, payments):
         assert all(p.group for p in payments)
diff -r cbca58c85330 -r 9962ae2940e6 payment.xml
--- a/payment.xml       Wed Feb 23 00:01:17 2022 +0100
+++ b/payment.xml       Sat Mar 19 22:31:21 2022 +0100
@@ -390,6 +390,16 @@
             <field name="group" ref="group_payment_approval"/>
         </record>
 
+        <record model="ir.model.button" id="payment_proceed_button">
+            <field name="name">proceed</field>
+            <field name="string">Processing</field>
+            <field name="model" search="[('model', '=', 'account.payment')]"/>
+        </record>
+        <record model="ir.model.button-res.group" 
id="payment_proceed_button_group_payment">
+            <field name="button" ref="payment_proceed_button"/>
+            <field name="group" ref="group_payment"/>
+        </record>
+
         <record model="ir.model.button" id="payment_succeed_button">
             <field name="name">succeed</field>
             <field name="string">Succeed</field>
diff -r cbca58c85330 -r 9962ae2940e6 view/payment_form.xml
--- a/view/payment_form.xml     Wed Feb 23 00:01:17 2022 +0100
+++ b/view/payment_form.xml     Sat Mar 19 22:31:21 2022 +0100
@@ -41,6 +41,7 @@
         <group col="-1" colspan="2" id="buttons">
             <button name="draft"/>
             <button name="approve"/>
+            <button name="proceed"/>
             <button name="fail"/>
             <button name="succeed"/>
         </group>

Reply via email to