changeset 69b733325048 in modules/account_payment:default
details:
https://hg.tryton.org/modules/account_payment?cmd=changeset&node=69b733325048
description:
Add succeed button for payment groups
issue10809
review369811002
diffstat:
CHANGELOG | 2 +
payment.py | 41 +++++++++++++++++++++++++++++++++++++-
payment.xml | 10 +++++++++
tests/scenario_account_payment.rst | 3 +-
view/payment_group_form.xml | 2 +
5 files changed, 56 insertions(+), 2 deletions(-)
diffs (125 lines):
diff -r 018a8ce3fb4e -r 69b733325048 CHANGELOG
--- a/CHANGELOG Sat Aug 21 09:09:55 2021 +0200
+++ b/CHANGELOG Mon Oct 11 18:22:19 2021 +0200
@@ -1,3 +1,5 @@
+* Add succeed button for payment groups
+
Version 6.0.0 - 2021-05-03
* Bug fixes (see mercurial logs for details)
* Add employee on payments for some states
diff -r 018a8ce3fb4e -r 69b733325048 payment.py
--- a/payment.py Sat Aug 21 09:09:55 2021 +0200
+++ b/payment.py Mon Oct 11 18:22:19 2021 +0200
@@ -75,8 +75,9 @@
'account.payment', 'group', 'Payments', readonly=True,
domain=[
('company', '=', Eval('company', -1)),
+ ('journal', '=', Eval('journal', -1)),
],
- depends=['company'])
+ depends=['company', 'journal'])
currency = fields.Function(fields.Many2One(
'currency.currency', "Currency"),
'on_change_with_currency')
@@ -97,6 +98,20 @@
help="All the payments in the group are complete."),
'get_payment_aggregated', searcher='search_complete')
+ process_method = fields.Function(
+ fields.Selection('get_process_methods', "Process Method"),
+ 'on_change_with_process_method', searcher='search_process_method')
+
+ @classmethod
+ def __setup__(cls):
+ super().__setup__()
+ cls._buttons.update(
+ succeed={
+ 'invisible': Eval('payment_complete', False),
+ 'depends': ['payment_complete', 'process_method'],
+ },
+ )
+
@classmethod
def __register__(cls, module_name):
table_h = cls.__table_handler__(module_name)
@@ -111,6 +126,22 @@
return Transaction().context.get('company')
@classmethod
+ def get_process_methods(cls):
+ pool = Pool()
+ Journal = pool.get('account.payment.journal')
+ field_name = 'process_method'
+ return Journal.fields_get([field_name])[field_name]['selection']
+
+ @fields.depends('journal')
+ def on_change_with_process_method(self, name=None):
+ if self.journal:
+ return self.journal.process_method
+
+ @classmethod
+ def search_process_method(cls, name, clause):
+ return [('journal.' + clause[0],) + tuple(clause[1:])]
+
+ @classmethod
def create(cls, vlist):
pool = Pool()
Config = pool.get('account.configuration')
@@ -135,6 +166,14 @@
return super(Group, cls).copy(groups, default=default)
@classmethod
+ @ModelView.button
+ def succeed(cls, groups):
+ pool = Pool()
+ Payment = pool.get('account.payment')
+ payments = sum((g.payments for g in groups), ())
+ Payment.succeed(payments)
+
+ @classmethod
def _get_complete_states(cls):
return ['succeeded', 'failed']
diff -r 018a8ce3fb4e -r 69b733325048 payment.xml
--- a/payment.xml Sat Aug 21 09:09:55 2021 +0200
+++ b/payment.xml Mon Oct 11 18:22:19 2021 +0200
@@ -171,6 +171,16 @@
<field name="perm_delete" eval="True"/>
</record>
+ <record model="ir.model.button" id="payment_group_succeed_button">
+ <field name="name">succeed</field>
+ <field name="string">Succeed</field>
+ <field name="model" search="[('model', '=',
'account.payment.group')]"/>
+ </record>
+ <record model="ir.model.button-res.group"
id="payment_group_succeed_button_group_payment">
+ <field name="button" ref="payment_group_succeed_button"/>
+ <field name="group" ref="group_payment"/>
+ </record>
+
<record model="ir.sequence.type"
id="sequence_type_account_payment_group">
<field name="name">Account Payment Group</field>
diff -r 018a8ce3fb4e -r 69b733325048 tests/scenario_account_payment.rst
--- a/tests/scenario_account_payment.rst Sat Aug 21 09:09:55 2021 +0200
+++ b/tests/scenario_account_payment.rst Mon Oct 11 18:22:19 2021 +0200
@@ -120,7 +120,8 @@
Success the payment and recheck the payment group::
- >>> payment.click('succeed')
+ >>> group.click('succeed')
+ >>> payment.reload()
>>> payment.succeeded_by == employee
True
>>> payment.state
diff -r 018a8ce3fb4e -r 69b733325048 view/payment_group_form.xml
--- a/view/payment_group_form.xml Sat Aug 21 09:09:55 2021 +0200
+++ b/view/payment_group_form.xml Mon Oct 11 18:22:19 2021 +0200
@@ -19,4 +19,6 @@
<field name="payment_amount_succeeded"/>
<label name="payment_complete" string="Complete"/>
<field name="payment_complete"/>
+
+ <button name="succeed" colspan="4"/>
</form>