diff --git a/line.py b/line.py
index 2333dd6..e12e19f 100644
--- a/line.py
+++ b/line.py
@@ -57,8 +57,10 @@ class Line(Workflow, ModelSQL, ModelView):
month = fields.Function(fields.Integer(string='Month', readonly=True),
'on_change_with_month', searcher='search_month')
number = fields.Char(string='Number', readonly=True)
- description = fields.Text(string='Description',
+ description = fields.Text(string='Description', select=True,
states=STATES, depends=DEPENDS)
+ descr_short = fields.Function(fields.Char(string='Description', readonly=True),
+ 'on_change_with_descr_short', searcher='search_descr_short')
category = fields.Many2One(string='Category',
model_name='cashbook.category', ondelete='RESTRICT',
states={
@@ -414,6 +416,13 @@ class Line(Workflow, ModelSQL, ModelView):
return [tab2]
+ @staticmethod
+ def order_descr_short(tables):
+ """ order by 'description'
+ """
+ table, _ = tables[None]
+ return [table.description]
+
@classmethod
def search_payee(cls, names, clause):
""" search in payee for party or cashbook
@@ -454,6 +463,12 @@ class Line(Workflow, ModelSQL, ModelView):
"""
return [('cashbook.state',) + tuple(clause[1:])]
+ @classmethod
+ def search_descr_short(cls, names, clause):
+ """ search in description
+ """
+ return [('description',) + tuple(clause[1:])]
+
@fields.depends('amount', 'splitlines')
def on_change_splitlines(self):
""" update amount if splitlines change
@@ -481,6 +496,13 @@ class Line(Workflow, ModelSQL, ModelView):
else :
self.splitlines = []
+ @fields.depends('description')
+ def on_change_with_descr_short(self, name=None):
+ """ to speed up list-view
+ """
+ if self.description:
+ return self.description[:25]
+
@fields.depends('party', 'booktransf', 'bookingtype')
def on_change_with_payee(self, name=None):
""" get party or cashbook
@@ -564,6 +586,7 @@ class Line(Workflow, ModelSQL, ModelView):
generate query
"""
query2 = []
+ end_amount = None
recons = Reconciliation.search([
('cashbook.id', '=', self.cashbook.id),
@@ -579,11 +602,8 @@ class Line(Workflow, ModelSQL, ModelView):
('reconciliation.id', '!=', recons[0]),
],
])
- return (query2, recons[0].end_amount)
-
- from datetime import datetime
- dt1 = datetime.now()
- print('\n## on_change_with_balance', dt1)
+ end_amount = recons[0].end_amount
+ return (query2, end_amount)
if self.cashbook:
query = [
@@ -601,22 +621,21 @@ class Line(Workflow, ModelSQL, ModelView):
)
balance = self.reconciliation.start_amount
else :
- (query2, balance) = get_from_last_recon(self)
+ (query2, balance2) = get_from_last_recon(self)
query.extend(query2)
+ if balance2 is not None:
+ balance = balance2
else :
- (query2, balance) = get_from_last_recon(self)
+ (query2, balance2) = get_from_last_recon(self)
query.extend(query2)
+ if balance2 is not None:
+ balance = balance2
- print('-- 1:', (datetime.now() - dt1))
-
- print('-- 2:', (datetime.now() - dt1), ', query:', query)
lines = Line.search(query)
- print('-- 3:', (datetime.now() - dt1), ', lines:',len(lines))
for line in lines:
balance += line.credit - line.debit
if line.id == self.id:
break
- print('-- 4:', (datetime.now() - dt1))
return balance
@classmethod
diff --git a/locale/de.po b/locale/de.po
index e67bd90..7faf37b 100644
--- a/locale/de.po
+++ b/locale/de.po
@@ -642,6 +642,10 @@ msgctxt "field:cashbook.line,description:"
msgid "Description"
msgstr "Beschreibung"
+msgctxt "field:cashbook.line,descr_short:"
+msgid "Description"
+msgstr "Beschreibung"
+
msgctxt "field:cashbook.line,state:"
msgid "State"
msgstr "Status"
diff --git a/locale/en.po b/locale/en.po
index 461bb3f..fa127f3 100644
--- a/locale/en.po
+++ b/locale/en.po
@@ -598,6 +598,10 @@ msgctxt "field:cashbook.line,description:"
msgid "Description"
msgstr "Description"
+msgctxt "field:cashbook.line,descr_short:"
+msgid "Description"
+msgstr "Description"
+
msgctxt "field:cashbook.line,state:"
msgid "State"
msgstr "State"
diff --git a/view/line_list.xml b/view/line_list.xml
index 355c450..aec30bb 100644
--- a/view/line_list.xml
+++ b/view/line_list.xml
@@ -7,8 +7,7 @@ full copyright notices and license terms. -->
-
-
+