changeset 69e9919e5311 in modules/account_payment_clearing:default
details:
https://hg.tryton.org/modules/account_payment_clearing?cmd=changeset;node=69e9919e5311
description:
Add support for payment and payment_group on Statement Rule
issue7925
review45851002
diffstat:
CHANGELOG | 2 ++
__init__.py | 4 ++++
setup.py | 1 +
statement.py | 33 +++++++++++++++++++++++++++++++++
tests/test_account_payment_clearing.py | 2 +-
tryton.cfg | 1 +
6 files changed, 42 insertions(+), 1 deletions(-)
diffs (96 lines):
diff -r 9636a78b4415 -r 69e9919e5311 CHANGELOG
--- a/CHANGELOG Thu Jan 17 17:22:22 2019 +0100
+++ b/CHANGELOG Thu Jan 17 17:34:50 2019 +0100
@@ -1,3 +1,5 @@
+* Add support for payment and payment_group on Statement Rule
+
Version 5.0.0 - 2018-10-01
* Bug fixes (see mercurial logs for details)
* Remove support for Python 2.7
diff -r 9636a78b4415 -r 69e9919e5311 __init__.py
--- a/__init__.py Thu Jan 17 17:22:22 2019 +0100
+++ b/__init__.py Thu Jan 17 17:34:50 2019 +0100
@@ -19,5 +19,9 @@
module='account_payment_clearing', type_='model',
depends=['account_statement'])
Pool.register(
+ statement.StatementRuleLine,
+ module='account_payment_clearing', type_='model',
+ depends=['account_statement_rule'])
+ Pool.register(
payment.Succeed,
module='account_payment_clearing', type_='wizard')
diff -r 9636a78b4415 -r 69e9919e5311 setup.py
--- a/setup.py Thu Jan 17 17:22:22 2019 +0100
+++ b/setup.py Thu Jan 17 17:34:50 2019 +0100
@@ -53,6 +53,7 @@
tests_require = [get_require_version('proteus'),
get_require_version('trytond_account_statement'),
+ get_require_version('trytond_account_statement_rule'),
'python-dateutil']
dependency_links = []
if minor_version % 2:
diff -r 9636a78b4415 -r 69e9919e5311 statement.py
--- a/statement.py Thu Jan 17 17:22:22 2019 +0100
+++ b/statement.py Thu Jan 17 17:34:50 2019 +0100
@@ -160,3 +160,36 @@
if l.payment
and l.payment.clearing_move
and l.payment.clearing_move.state == 'draft'])
+
+
+class StatementRuleLine(metaclass=PoolMeta):
+ __name__ = 'account.statement.rule.line'
+
+ def get_line(self, origin, keywords, **context):
+ line = super().get_line(origin, keywords, **context)
+ if line:
+ line.payment = self._get_payment(origin, keywords)
+ if (line.payment and line.party
+ and line.payment.party != line.party):
+ return
+ line.payment_group = self._get_payment_group(origin, keywords)
+ return line
+
+ def _get_payment(self, origin, keywords):
+ pool = Pool()
+ Payment = pool.get('account.payment')
+ if keywords.get('payment'):
+ payments = Payment.search([('rec_name', '=', keywords['payment'])])
+ if len(payments) == 1:
+ payment, = payments
+ return payment
+
+ def _get_payment_group(self, origin, keywords):
+ pool = Pool()
+ Payment = pool.get('account.payment.group')
+ if keywords.get('payment_group'):
+ groups, = Payment.search(
+ [('rec_name', '=', keywords['payment_group'])])
+ if len(groups) == 1:
+ group, = groups
+ return group
diff -r 9636a78b4415 -r 69e9919e5311 tests/test_account_payment_clearing.py
--- a/tests/test_account_payment_clearing.py Thu Jan 17 17:22:22 2019 +0100
+++ b/tests/test_account_payment_clearing.py Thu Jan 17 17:34:50 2019 +0100
@@ -11,7 +11,7 @@
class AccountPaymentTestCase(ModuleTestCase):
'Test Account Payment module'
module = 'account_payment_clearing'
- extras = ['account_statement']
+ extras = ['account_statement', 'account_statement_rule']
def suite():
diff -r 9636a78b4415 -r 69e9919e5311 tryton.cfg
--- a/tryton.cfg Thu Jan 17 17:22:22 2019 +0100
+++ b/tryton.cfg Thu Jan 17 17:34:50 2019 +0100
@@ -5,6 +5,7 @@
ir
extras_depend:
account_statement
+ account_statement_rule
xml:
payment.xml
statement.xml