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

Subscribers

People subscribed via source and target branches