Add button to reconcile statement

issue6917
review43741002
This commit is contained in:
Cédric Krier
2017-12-26 17:41:30 +01:00
parent 237360ecb5
commit 0e03c8e259
5 changed files with 55 additions and 1 deletions
+2
View File
@@ -1,3 +1,5 @@
* Add button to reconcile statement
Version 4.6.0 - 2017-10-30
* Bug fixes (see mercurial logs for details)
* Add generic wizard to import statement from files
+1
View File
@@ -22,6 +22,7 @@ def register():
Pool.register(
PartyReplace,
ImportStatement,
ReconcileStatement,
module='account_statement', type_='wizard')
Pool.register(
StatementReport,
+44 -1
View File
@@ -20,7 +20,9 @@ from trytond.modules.company import CompanyReport
__all__ = ['Statement', 'Line', 'LineGroup',
'Origin', 'OriginInformation',
'ImportStatementStart', 'ImportStatement', 'StatementReport']
'ImportStatementStart', 'ImportStatement',
'ReconcileStatement',
'StatementReport']
_STATES = {'readonly': Eval('state') != 'draft'}
_DEPENDS = ['state']
@@ -131,6 +133,8 @@ class Statement(Workflow, ModelSQL, ModelView):
state = fields.Selection(STATES, 'State', readonly=True, select=True)
validation = fields.Function(fields.Char('Validation'),
'on_change_with_validation')
to_reconcile = fields.Function(
fields.Boolean("To Reconcile"), 'get_to_reconcile')
@classmethod
def __setup__(cls):
@@ -170,6 +174,10 @@ class Statement(Workflow, ModelSQL, ModelView):
'cancel': {
'invisible': ~Eval('state').in_(['draft', 'validated']),
},
'reconcile': {
'invisible': Eval('state').in_(['draft', 'cancel']),
'readonly': ~Eval('to_reconcile'),
},
})
@classmethod
@@ -321,6 +329,20 @@ class Statement(Workflow, ModelSQL, ModelView):
if self.journal:
return self.journal.validation
def get_to_reconcile(self, name=None):
return bool(self.lines_to_reconcile)
@property
def lines_to_reconcile(self):
lines = []
for line in self.lines:
if line.move:
for move_line in line.move.lines:
if (move_line.account.reconcile
and not move_line.reconciliation):
lines.append(move_line)
return lines
def _group_key(self, line):
key = (
('number', line.number or Unequal()),
@@ -559,6 +581,11 @@ class Statement(Workflow, ModelSQL, ModelView):
lines = [l for s in statements for l in s.lines]
StatementLine.delete_move(lines)
@classmethod
@ModelView.button_action('account_statement.act_reconcile')
def reconcile(cls, statements):
pass
def origin_mixin(_states, _depends):
class Mixin:
@@ -1055,5 +1082,21 @@ class ImportStatement(Wizard):
return action, data
class ReconcileStatement(Wizard):
"Statement Reconcile"
__name__ = 'account.statement.reconcile'
start = StateAction('account.act_reconcile')
def do_start(self, action):
pool = Pool()
Statement = pool.get('account.statement')
statements = Statement.browse(Transaction().context['active_ids'])
lines = sum((map(int, s.lines_to_reconcile) for s in statements), [])
return action, {
'model': 'account.move.line',
'ids': lines,
}
class StatementReport(CompanyReport):
__name__ = 'account.statement'
+5
View File
@@ -466,6 +466,11 @@ this repository contains the full copyright notices and license terms. -->
<field name="group" ref="group_statement"/>
</record>
<record model="ir.action.wizard" id="act_reconcile">
<field name="name">Reconcile Statements</field>
<field name="wiz_name">account.statement.reconcile</field>
</record>
<record model="ir.action.act_window" id="act_move_lines_form">
<field name="name">Move Lines</field>
<field name="res_model">account.move.line</field>
+3
View File
@@ -32,6 +32,8 @@ this repository contains the full copyright notices and license terms. -->
<button string="Draft" name="draft" icon="tryton-clear"/>
<button string="Validate" name="validate_statement"
icon="tryton-go-next"/>
<button string="Reconcile" name="reconcile"
icon="tryton-find-replace"/>
<button string="Post" name="post" icon="tryton-ok"/>
</group>
</group>
@@ -46,4 +48,5 @@ this repository contains the full copyright notices and license terms. -->
<field name="company"/>
</page>
</notebook>
<field name="to_reconcile" colspan="4" invisible="1"/>
</form>