Merge lp:~julie-w/unifield-server/US-3716 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 4724
Proposed branch: lp:~julie-w/unifield-server/US-3716
Merge into: lp:unifield-server
Diff against target: 59 lines (+28/-2)
2 files modified
bin/addons/register_accounting/report/cash_inventory.rml (+2/-2)
bin/addons/register_accounting/report/report_cash_inventory.py (+26/-0)
To merge this branch: bzr merge lp:~julie-w/unifield-server/US-3716
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+335835@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/addons/register_accounting/report/cash_inventory.rml'
2--- bin/addons/register_accounting/report/cash_inventory.rml 2016-04-27 17:48:12 +0000
3+++ bin/addons/register_accounting/report/cash_inventory.rml 2018-01-08 14:53:35 +0000
4@@ -150,9 +150,9 @@
5 <spacer length="5"/>
6
7 <para style="text"><b>Comments:</b></para>
8- <blockTable colWidths="180mm" rowHeights="15mm" style="table_comments">
9+ <blockTable colWidths="180mm" rowHeights="20mm" style="table_comments">
10 <tr>
11- <td>[[ format(o.notes or '') ]]</td>
12+ <td>[[ format(formatComments(o.notes or '')) ]]</td>
13 </tr>
14 </blockTable>
15
16
17=== modified file 'bin/addons/register_accounting/report/report_cash_inventory.py'
18--- bin/addons/register_accounting/report/report_cash_inventory.py 2015-10-22 12:37:32 +0000
19+++ bin/addons/register_accounting/report/report_cash_inventory.py 2018-01-08 14:53:35 +0000
20@@ -28,6 +28,7 @@
21 super(cash_inventory, self).__init__(cr, uid, name, context=context)
22 self.localcontext.update({
23 'getNow': self.get_now,
24+ 'formatComments': self._format_comments,
25 })
26
27 def get_now(self, show_datetime=False):
28@@ -36,6 +37,31 @@
29 return date_tools_obj.datetime2orm(res) if show_datetime \
30 else date_tools_obj.date2orm(res.date())
31
32+ def _format_comments(self, notes):
33+ """
34+ Formats the comments to print:
35+ - 4 lines max
36+ - 90 characters per line
37+ """
38+ res = ''
39+ nb_lines = 4
40+ strlimit = 90
41+ # remove the existing line breaks from the comments
42+ notes = notes.replace('\r\n', ' ').replace('\n', ' ')
43+ for i in range(nb_lines):
44+ begin = i * strlimit
45+ end = begin + strlimit
46+ is_last_line = i == nb_lines - 1
47+ eol = ''
48+ if not is_last_line:
49+ # add an hyphen if the cut is done in the middle of a word
50+ eol = len(notes) > end and notes[end-1].isalpha() and notes[end].isalpha() and '-\n-' or '\n'
51+ res = '%s%s%s' % (res, notes[begin:end], eol)
52+ # add an ellipsis if the comment is too long to be fully printed
53+ if len(notes) > strlimit * nb_lines:
54+ res = '%s%s' % (res, '...')
55+ return res
56+
57 report_sxw.report_sxw('report.cash.inventory', 'account.bank.statement', 'addons/register_accounting/report/cash_inventory.rml', parser=cash_inventory)
58
59 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

Subscribers

People subscribed via source and target branches