Allow to set the date of the clearing move
issue6080 review32851002
This commit is contained in:
1 parent
bebc92aaf8
commit
694025b019
10 files changed
+110
-9
No files matched your search
@@ -1,3 +1,5 @@
|
||||
* Allow to set the date of the clearing move
|
||||
|
||||
Version 4.2.0 - 2016-11-28
|
||||
* Bug fixes (see mercurial logs for details)
|
||||
* Mark Payment as succeded or failed when imported in statement
|
||||
|
||||
@@ -10,7 +10,11 @@ def register():
|
||||
Pool.register(
|
||||
Journal,
|
||||
Payment,
|
||||
SucceedStart,
|
||||
Move,
|
||||
Statement,
|
||||
StatementLine,
|
||||
module='account_payment_clearing', type_='model')
|
||||
Pool.register(
|
||||
Succeed,
|
||||
module='account_payment_clearing', type_='wizard')
|
||||
+48
-2
@@ -6,8 +6,9 @@ from trytond.pool import PoolMeta, Pool
|
||||
from trytond.model import ModelView, Workflow, fields
|
||||
from trytond.pyson import Eval, Bool
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.wizard import Wizard, StateView, StateTransition, Button
|
||||
|
||||
__all__ = ['Journal', 'Payment']
|
||||
__all__ = ['Journal', 'Payment', 'Succeed', 'SucceedStart']
|
||||
|
||||
|
||||
class Journal:
|
||||
@@ -32,6 +33,18 @@ class Payment:
|
||||
clearing_move = fields.Many2One('account.move', 'Clearing Move',
|
||||
readonly=True)
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(Payment, cls).__setup__()
|
||||
cls._buttons.update({
|
||||
'succeed_wizard': cls._buttons['succeed'],
|
||||
})
|
||||
|
||||
@classmethod
|
||||
@ModelView.button_action('account_payment_clearing.wizard_succeed')
|
||||
def succeed_wizard(cls, payments):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
@Workflow.transition('succeeded')
|
||||
@@ -44,7 +57,8 @@ class Payment:
|
||||
|
||||
moves = []
|
||||
for payment in payments:
|
||||
move = payment.create_clearing_move()
|
||||
move = payment.create_clearing_move(
|
||||
date=Transaction().context.get('clearing_date'))
|
||||
if move:
|
||||
moves.append(move)
|
||||
if moves:
|
||||
@@ -157,3 +171,35 @@ class Payment:
|
||||
Line.reconcile(lines)
|
||||
|
||||
cls.write(payments, {'clearing_move': None})
|
||||
|
||||
|
||||
class Succeed(Wizard):
|
||||
"Succeed Payment"
|
||||
__name__ = 'account.payment.succeed'
|
||||
start = StateView('account.payment.succeed.start',
|
||||
'account_payment_clearing.succeed_start_view_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Succeed', 'succeed', 'tryton-ok', default=True),
|
||||
])
|
||||
succeed = StateTransition()
|
||||
|
||||
def transition_succeed(self):
|
||||
pool = Pool()
|
||||
Payment = pool.get('account.payment')
|
||||
payments = Payment.browse(Transaction().context['active_ids'])
|
||||
|
||||
with Transaction().set_context(clearing_date=self.start.date):
|
||||
Payment.succeed(payments)
|
||||
return 'end'
|
||||
|
||||
|
||||
class SucceedStart(ModelView):
|
||||
"Succeed Payment"
|
||||
__name__ = 'account.payment.succeed.start'
|
||||
date = fields.Date("Date", required=True)
|
||||
|
||||
@classmethod
|
||||
def default_date(cls):
|
||||
pool = Pool()
|
||||
Date = pool.get('ir.date')
|
||||
return Date.today()
|
||||
+18
@@ -15,5 +15,23 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="inherit" ref="account_payment.payment_view_form"/>
|
||||
<field name="name">payment_form</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="payment_view_list">
|
||||
<field name="model">account.payment</field>
|
||||
<field name="inherit" ref="account_payment.payment_view_list"/>
|
||||
<field name="name">payment_list</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.action.wizard" id="wizard_succeed">
|
||||
<field name="name">Succeed Payments"</field>
|
||||
<field name="wiz_name">account.payment.succeed</field>
|
||||
<field name="model">account.payment</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="succeed_start_view_form">
|
||||
<field name="model">account.payment.succeed.start</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">succeed_start_form</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
@@ -54,7 +54,8 @@ for dep in info.get('depends', []):
|
||||
requires.append(get_require_version('trytond'))
|
||||
|
||||
tests_require = [get_require_version('proteus'),
|
||||
get_require_version('trytond_account_statement')]
|
||||
get_require_version('trytond_account_statement'),
|
||||
'python-dateutil']
|
||||
dependency_links = []
|
||||
if minor_version % 2:
|
||||
# Add development index for testing with proteus
|
||||
|
||||
@@ -99,7 +99,8 @@ Pay the line::
|
||||
|
||||
Succeed payment::
|
||||
|
||||
>>> payment.click('succeed')
|
||||
>>> succeed = Wizard('account.payment.succeed', [payment])
|
||||
>>> succeed.execute('succeed')
|
||||
>>> payment.state
|
||||
u'succeeded'
|
||||
>>> payment.clearing_move.state
|
||||
|
||||
@@ -16,6 +16,7 @@ Imports::
|
||||
>>> from trytond.modules.account_invoice.tests.tools import \
|
||||
... set_fiscalyear_invoice_sequences
|
||||
>>> today = datetime.date.today()
|
||||
>>> first = today + relativedelta(day=1)
|
||||
|
||||
Install account_payment_clearing and account_statement::
|
||||
|
||||
@@ -99,9 +100,15 @@ Partially pay the line::
|
||||
|
||||
Succeed payment::
|
||||
|
||||
>>> payment.click('succeed')
|
||||
>>> succeed = Wizard('account.payment.succeed', [payment])
|
||||
>>> succeed.form.date == today
|
||||
True
|
||||
>>> succeed.form.date = first
|
||||
>>> succeed.execute('succeed')
|
||||
>>> payment.state
|
||||
u'succeeded'
|
||||
>>> payment.clearing_move.date == first
|
||||
True
|
||||
>>> payment.clearing_move.state
|
||||
u'draft'
|
||||
>>> payable.reload()
|
||||
@@ -146,7 +153,8 @@ Pay the line::
|
||||
|
||||
Succeed payment::
|
||||
|
||||
>>> payment.click('succeed')
|
||||
>>> succeed = Wizard('account.payment.succeed', [payment])
|
||||
>>> succeed.execute('succeed')
|
||||
>>> payment.state
|
||||
u'succeeded'
|
||||
>>> payment.clearing_move.state
|
||||
@@ -170,7 +178,8 @@ Fail payment::
|
||||
|
||||
Succeed payment and post clearing::
|
||||
|
||||
>>> payment.click('succeed')
|
||||
>>> succeed = Wizard('account.payment.succeed', [payment])
|
||||
>>> succeed.execute('succeed')
|
||||
>>> payment.state
|
||||
u'succeeded'
|
||||
>>> clearing_move = payment.clearing_move
|
||||
@@ -193,7 +202,8 @@ Fail payment with posted clearing::
|
||||
|
||||
Succeed payment to use on statement::
|
||||
|
||||
>>> payment.click('succeed')
|
||||
>>> succeed = Wizard('account.payment.succeed', [payment])
|
||||
>>> succeed.execute('succeed')
|
||||
>>> payment.state
|
||||
u'succeeded'
|
||||
|
||||
@@ -332,7 +342,8 @@ Pay the line::
|
||||
|
||||
Succeed payment::
|
||||
|
||||
>>> payment.click('succeed')
|
||||
>>> succeed = Wizard('account.payment.succeed', [payment])
|
||||
>>> succeed.execute('succeed')
|
||||
>>> debit_line, = [l for l in payment.clearing_move.lines if l.debit > 0]
|
||||
>>> debit_line.debit
|
||||
Decimal('20.00')
|
||||
|
||||
@@ -7,4 +7,7 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<label name="clearing_move"/>
|
||||
<field name="clearing_move"/>
|
||||
</xpath>
|
||||
<xpath expr="//button[@name='succeed']" position="replace_attributes">
|
||||
<button name="succeed_wizard"/>
|
||||
</xpath>
|
||||
</data>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath expr="//button[@name='succeed']" position="replace_attributes">
|
||||
<button name="succeed_wizard"/>
|
||||
</xpath>
|
||||
</data>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<form>
|
||||
<label name="date"/>
|
||||
<field name="date"/>
|
||||
</form>
|
||||
Reference in new issue
Block a user