changeset f8b0419dc351 in modules/account_payment_sepa:default
details: 
https://hg.tryton.org/modules/account_payment_sepa?cmd=changeset;node=f8b0419dc351
description:
        Allow the sepa mandate to be set on draft payments

        Also include account number on mandate rec_name

        issue8990
        review260831007
diffstat:

 CHANGELOG             |   3 +++
 payment.py            |  35 +++++++++++++++++++++++++++++++----
 view/payment_form.xml |   8 +++++---
 3 files changed, 39 insertions(+), 7 deletions(-)

diffs (97 lines):

diff -r 00a53d5e615e -r f8b0419dc351 CHANGELOG
--- a/CHANGELOG Sun Feb 16 00:21:45 2020 +0100
+++ b/CHANGELOG Mon Feb 17 11:18:54 2020 +0100
@@ -1,3 +1,6 @@
+* Include bank account number on mandate rec_name
+* Allow sepa_mandate to be set on draft payments
+
 Version 5.4.0 - 2019-11-04
 * Bug fixes (see mercurial logs for details)
 * Add initiator identifiers on journal
diff -r 00a53d5e615e -r f8b0419dc351 payment.py
--- a/payment.py        Sun Feb 16 00:21:45 2020 +0100
+++ b/payment.py        Mon Feb 17 11:18:54 2020 +0100
@@ -264,11 +264,20 @@
 
     sepa_mandate = fields.Many2One('account.payment.sepa.mandate', 'Mandate',
         ondelete='RESTRICT',
+        states={
+            'readonly': Eval('state') != 'draft',
+            'invisible': ((Eval('process_method') != 'sepa')
+                | (Eval('kind') != 'receivable')),
+            },
         domain=[
             ('party', '=', Eval('party', -1)),
             ('company', '=', Eval('company', -1)),
+            If(Eval('state') == 'draft',
+                ('state', '=', 'validated'),
+                (),
+                )
             ],
-        depends=['party', 'company'])
+        depends=['party', 'company', 'state', 'process_method', 'kind'])
     sepa_mandate_sequence_type = fields.Char('Mandate Sequence Type',
         readonly=True)
     sepa_return_reason_code = fields.Char('Return Reason Code', readonly=True,
@@ -361,6 +370,14 @@
             date = Transaction().context.get('date_value')
         return super(Payment, self).create_clearing_move(date=date)
 
+    @classmethod
+    def view_attributes(cls):
+        return super().view_attributes() + [
+            ('//separator[@id="sepa_return_reason"]', 'states', {
+                    'invisible': Eval('state') != 'failed',
+                    }),
+            ]
+
 
 class Mandate(Workflow, ModelSQL, ModelView):
     'SEPA Mandate'
@@ -505,13 +522,23 @@
         return bool(self.identification)
 
     def get_rec_name(self, name):
+        name = '(%s)' % self.id
         if self.identification:
-            return self.identification
-        return '(%s)' % self.id
+            name = self.identification
+        if self.account_number:
+            name += ' @ %s' % self.account_number.rec_name
+        return name
 
     @classmethod
     def search_rec_name(cls, name, clause):
-        return [tuple(('identification',)) + tuple(clause[1:])]
+        if clause[1].startswith('!') or clause[1].startswith('not '):
+            bool_op = 'AND'
+        else:
+            bool_op = 'OR'
+        return [bool_op,
+            ('identification',) + tuple(clause[1:]),
+            ('account_number',) + tuple(clause[1:]),
+            ]
 
     @classmethod
     def create(cls, vlist):
diff -r 00a53d5e615e -r f8b0419dc351 view/payment_form.xml
--- a/view/payment_form.xml     Sun Feb 16 00:21:45 2020 +0100
+++ b/view/payment_form.xml     Mon Feb 17 11:18:54 2020 +0100
@@ -3,11 +3,13 @@
 this repository contains the full copyright notices and license terms. -->
 <data>
     <xpath expr="//notebook/page[@id='info']" position="inside">
-        <newline/>
-        <label name="sepa_return_reason_code"/>
+        <label name="sepa_mandate"/>
+        <field name="sepa_mandate"/>
+        <separator id="sepa_return_reason" string="Return Reason" colspan="4"/>
+        <label name="sepa_return_reason_code" string="Code"/>
         <field name="sepa_return_reason_code"/>
         <newline/>
-        <label name="sepa_return_reason_information"/>
+        <label name="sepa_return_reason_information" string="Information"/>
         <field name="sepa_return_reason_information" yexpand="0" colspan="3"/>
     </xpath>
 </data>

Reply via email to