Allow to set a description to cancel move
issue4304 review6631002
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
* Allow to set a description to cancel move
|
||||
|
||||
Version 3.4.0 - 2014-10-20
|
||||
* Bug fixes (see mercurial logs for details)
|
||||
* Add option on Account for party required
|
||||
|
||||
@@ -47,6 +47,7 @@ def register():
|
||||
OpenJournalAsk,
|
||||
ReconcileLinesWriteOff,
|
||||
ReconcileShow,
|
||||
CancelMovesDefault,
|
||||
FiscalYearLine,
|
||||
FiscalYear2,
|
||||
PrintGeneralJournalStart,
|
||||
|
||||
@@ -30,7 +30,7 @@ __all__ = ['Move', 'Reconciliation', 'Line', 'OpenJournalAsk',
|
||||
'ReconcileLinesWriteOff', 'ReconcileLines',
|
||||
'UnreconcileLines',
|
||||
'Reconcile', 'ReconcileShow',
|
||||
'CancelMoves',
|
||||
'CancelMoves', 'CancelMovesDefault',
|
||||
'FiscalYearLine', 'FiscalYear2',
|
||||
'PrintGeneralJournalStart', 'PrintGeneralJournal', 'GeneralJournal']
|
||||
__metaclass__ = PoolMeta
|
||||
@@ -366,9 +366,11 @@ class Move(ModelSQL, ModelView):
|
||||
})
|
||||
return default
|
||||
|
||||
def cancel(self):
|
||||
def cancel(self, default=None):
|
||||
'Return a cancel move'
|
||||
default = self._cancel_default()
|
||||
if default is None:
|
||||
default = {}
|
||||
default.update(self._cancel_default())
|
||||
cancel_move, = self.copy([self], default=default)
|
||||
for line in cancel_move.lines:
|
||||
line.debit *= -1
|
||||
@@ -1892,9 +1894,20 @@ class ReconcileShow(ModelView):
|
||||
class CancelMoves(Wizard):
|
||||
'Cancel Moves'
|
||||
__name__ = 'account.move.cancel'
|
||||
start_state = 'cancel'
|
||||
start_state = 'default'
|
||||
default = StateView('account.move.cancel.default',
|
||||
'account.move_cancel_default_view_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Ok', 'cancel', 'tryton-ok', default=True),
|
||||
])
|
||||
cancel = StateTransition()
|
||||
|
||||
def default_cancel(self, move):
|
||||
default = {}
|
||||
if self.default.description:
|
||||
default['description'] = self.default.description
|
||||
return default
|
||||
|
||||
def transition_cancel(self):
|
||||
pool = Pool()
|
||||
Move = pool.get('account.move')
|
||||
@@ -1902,7 +1915,8 @@ class CancelMoves(Wizard):
|
||||
|
||||
moves = Move.browse(Transaction().context['active_ids'])
|
||||
for move in moves:
|
||||
cancel_move = move.cancel()
|
||||
default = self.default_cancel(move)
|
||||
cancel_move = move.cancel(default=default)
|
||||
to_reconcile = defaultdict(list)
|
||||
for line in move.lines + cancel_move.lines:
|
||||
if line.account.reconcile:
|
||||
@@ -1912,6 +1926,12 @@ class CancelMoves(Wizard):
|
||||
return 'end'
|
||||
|
||||
|
||||
class CancelMovesDefault(ModelView):
|
||||
'Cancel Moves'
|
||||
__name__ = 'account.move.cancel.default'
|
||||
description = fields.Char('Description')
|
||||
|
||||
|
||||
class FiscalYearLine(ModelSQL):
|
||||
'Fiscal Year - Move Line'
|
||||
__name__ = 'account.fiscalyear-account.move.line'
|
||||
|
||||
@@ -310,6 +310,12 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="action" ref="act_cancel_moves"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="move_cancel_default_view_form">
|
||||
<field name="model">account.move.cancel.default</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">move_cancel_default_form</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="print_general_journal_start_view_form">
|
||||
<field name="model">account.move.print_general_journal.start</field>
|
||||
<field name="type">form</field>
|
||||
|
||||
@@ -84,6 +84,8 @@ Create Move to cancel::
|
||||
Cancel Move::
|
||||
|
||||
>>> cancel_move = Wizard('account.move.cancel', [move])
|
||||
>>> cancel_move.form.description = 'Cancel'
|
||||
>>> cancel_move.execute('cancel')
|
||||
>>> cancel_move.state
|
||||
'end'
|
||||
>>> move.reload()
|
||||
@@ -94,6 +96,8 @@ Cancel Move::
|
||||
... if l.move != move]
|
||||
>>> cancel_move.origin == move
|
||||
True
|
||||
>>> cancel_move.description
|
||||
u'Cancel'
|
||||
>>> revenue.reload()
|
||||
>>> revenue.credit
|
||||
Decimal('0.00')
|
||||
|
||||
@@ -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 string="Cancel Moves">
|
||||
<label name="description"/>
|
||||
<field name="description" colspan="3"/>
|
||||
</form>
|
||||
Reference in New Issue
Block a user