Add support for payment and payment_group on Statement Rule
issue7925 review45851002
This commit is contained in:
1 parent
6cc21ffed7
commit
febc431586
6 files changed
+42
-1
No files matched your search
@@ -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
|
||||
|
||||
@@ -18,6 +18,10 @@ def register():
|
||||
statement.StatementLine,
|
||||
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')
|
||||
@@ -53,6 +53,7 @@ requires.append(get_require_version('trytond'))
|
||||
|
||||
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:
|
||||
|
||||
@@ -160,3 +160,36 @@ class StatementLine(metaclass=PoolMeta):
|
||||
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
|
||||
@@ -11,7 +11,7 @@ from trytond.tests.test_tryton import doctest_checker
|
||||
class AccountPaymentTestCase(ModuleTestCase):
|
||||
'Test Account Payment module'
|
||||
module = 'account_payment_clearing'
|
||||
extras = ['account_statement']
|
||||
extras = ['account_statement', 'account_statement_rule']
|
||||
|
||||
|
||||
def suite():
|
||||
|
||||
@@ -5,6 +5,7 @@ depends:
|
||||
ir
|
||||
extras_depend:
|
||||
account_statement
|
||||
account_statement_rule
|
||||
xml:
|
||||
payment.xml
|
||||
statement.xml
|
||||
Reference in new issue
Block a user