Rationalize accounting moves and lines

issue2056
review503006
This commit is contained in:
Cédric Krier
2012-09-29 15:34:37 +02:00
parent 0741cb488d
commit 7ee6249bd2
4 changed files with 25 additions and 3 deletions
+2
View File
@@ -4,6 +4,7 @@
from trytond.pool import Pool
from .journal import *
from .statement import *
from .account import *
def register():
@@ -11,4 +12,5 @@ def register():
Journal,
Statement,
Line,
Move,
module='account_statement', type_='model')
+14
View File
@@ -0,0 +1,14 @@
#This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
from trytond.pool import PoolMeta
__all__ = ['Move']
__metaclass__ = PoolMeta
class Move:
__name__ = 'account.move'
@classmethod
def _get_origin(cls):
return super(Move, cls)._get_origin() + ['account.statement.line']
+7 -3
View File
@@ -173,6 +173,7 @@ class Statement(Workflow, ModelSQL, ModelView):
res[statement.id] = (statement.journal.name + ' '
+ Lang.currency(lang, statement.start_balance,
statement.journal.currency, symbol=False, grouping=True)
+ ' - '
+ Lang.currency(lang, statement.end_balance,
statement.journal.currency, symbol=False, grouping=True))
return res
@@ -444,6 +445,9 @@ class Line(ModelSQL, ModelView):
res['invoice'] = None
return res
def get_rec_name(self, name):
return self.statement.rec_name
@classmethod
def copy(cls, lines, default=None):
if default is None:
@@ -472,10 +476,10 @@ class Line(ModelSQL, ModelView):
move_lines = self._get_move_lines()
move = Move(
name=unicode(self.date),
period=period_id,
journal=self.statement.journal.journal,
date=self.date,
origin=self,
lines=move_lines,
)
move.save()
@@ -547,7 +551,7 @@ class Line(ModelSQL, ModelView):
move_lines = []
move_lines.append(MoveLine(
name=unicode(self.date),
description=self.description,
debit=amount < zero and -amount or zero,
credit=amount >= zero and amount or zero,
account=self.account,
@@ -566,7 +570,7 @@ class Line(ModelSQL, ModelView):
if self.account == account:
self.raise_user_error('same_debit_credit_account')
move_lines.append(MoveLine(
name=unicode(self.date),
description=self.description,
debit=amount >= zero and amount or zero,
credit=amount < zero and -amount or zero,
account=account,
+2
View File
@@ -166,6 +166,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="arch" type="xml">
<![CDATA[
<form string="Statement Line">
<label name="statement"/>
<field name="statement" colspan="3"/>
<label name="date"/>
<field name="date"/>
<label name="amount"/>