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

Proposed by jftempo
Status: Merged
Merged at revision: 5620
Proposed branch: lp:~julie-w/unifield-server/US-6554
Merge into: lp:unifield-server
Diff against target: 203 lines (+44/-20)
6 files modified
bin/addons/account/report/account_balance_sheet.py (+3/-1)
bin/addons/account/report/account_general_ledger.py (+10/-6)
bin/addons/account/report/account_partner_ledger.py (+6/-6)
bin/addons/account/report/account_profit_loss.py (+4/-1)
bin/addons/finance/report/account_partner_balance_tree.py (+10/-6)
bin/addons/msf_tools/msf_tools.py (+11/-0)
To merge this branch: bzr merge lp:~julie-w/unifield-server/US-6554
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+378505@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/account/report/account_balance_sheet.py'
2--- bin/addons/account/report/account_balance_sheet.py 2017-06-08 16:00:51 +0000
3+++ bin/addons/account/report/account_balance_sheet.py 2020-02-04 10:20:46 +0000
4@@ -285,6 +285,7 @@
5 return self.result.get(group, [])
6
7 def get_display_info(self, data):
8+ # reminder: in case other items are added in the "Display" col., truncate the text with the truncate_list method
9 info_data = []
10 all_str = _('All')
11
12@@ -325,6 +326,7 @@
13 return infos and ", \n".join(infos) or _('No Filter')
14
15 def get_prop_instances(self, data):
16+ data_tools_obj = self.pool.get('data.tools')
17 instances = []
18 if data.get('form', False):
19 if data['form'].get('instance_ids', False):
20@@ -335,7 +337,7 @@
21 # US-1166: mission only instances if none provided
22 instances = self._get_instances(get_code=True,
23 mission_filter=True)
24- return ', '.join(instances)
25+ return data_tools_obj.truncate_list(instances)
26
27 report_sxw.report_sxw('report.account.balancesheet.horizontal', 'account.account',
28 'addons/account/report/account_balance_sheet_horizontal.rml',parser=report_balancesheet_horizontal,
29
30=== modified file 'bin/addons/account/report/account_general_ledger.py'
31--- bin/addons/account/report/account_general_ledger.py 2019-07-31 15:26:10 +0000
32+++ bin/addons/account/report/account_general_ledger.py 2020-02-04 10:20:46 +0000
33@@ -495,15 +495,18 @@
34 return amount
35
36 def _get_prop_instances_str(self):
37- return ', '.join([ i.code \
38- for i in self.pool.get('msf.instance').browse(self.cr, self.uid, self.selected_instance_ids) \
39- if i.code ])
40+ data_tools_obj = self.pool.get('data.tools')
41+ inst_list = [ i.code \
42+ for i in self.pool.get('msf.instance').browse(self.cr, self.uid, self.selected_instance_ids) \
43+ if i.code ]
44+ return data_tools_obj.truncate_list(inst_list)
45
46 def _get_journals_str(self, data):
47+ data_tools_obj = self.pool.get('data.tools')
48 if 'all_journals' in data['form']:
49 return _('All Journals')
50- return ', '.join(list(set(self._get_journal(data,
51- instance_ids=self.selected_instance_ids))))
52+ journal_list = list(set(self._get_journal(data, instance_ids=self.selected_instance_ids)))
53+ return data_tools_obj.truncate_list(journal_list)
54
55 # internal filter functions
56 def _get_data_form(self, data, key, default=False):
57@@ -512,6 +515,7 @@
58 return data['form'].get(key, default)
59
60 def _get_display_info(self, data):
61+ data_tools_obj = self.pool.get('data.tools')
62 info_data = []
63 yes_str = _('Yes')
64 no_str = _('No')
65@@ -550,7 +554,7 @@
66 if a.type != 'view' ], )))
67
68 res = [ "%s: %s" % (label, val, ) for label, val in info_data ]
69- return ', \n'.join(res)
70+ return data_tools_obj.truncate_list(res, separator=', \n')
71
72 def _get_open_items_selection(self, data):
73 """
74
75=== modified file 'bin/addons/account/report/account_partner_ledger.py'
76--- bin/addons/account/report/account_partner_ledger.py 2018-08-20 09:13:59 +0000
77+++ bin/addons/account/report/account_partner_ledger.py 2020-02-04 10:20:46 +0000
78@@ -484,22 +484,22 @@
79 """
80 Returns the list of journals as a String (cut if > 300 characters)
81 """
82- journals_str = ', '.join([journal or '' for journal in self._get_journal(data)])
83- return (len(journals_str) <= 300) and journals_str or ("%s%s" % (journals_str[:297], '...'))
84+ data_tools_obj = self.pool.get('data.tools')
85+ return data_tools_obj.truncate_list(self._get_journal(data))
86
87 def _get_instances_str(self, data):
88 """
89 Returns the list of instances as a String (cut if > 300 characters)
90 """
91- instances_str = ', '.join([inst or '' for inst in self._get_instances_from_data(data)])
92- return (len(instances_str) <= 300) and instances_str or ("%s%s" % (instances_str[:297], '...'))
93+ data_tools_obj = self.pool.get('data.tools')
94+ return data_tools_obj.truncate_list(self._get_instances_from_data(data))
95
96 def _get_accounts_str(self, data):
97 """
98 Returns the list of accounts as a String (cut if > 300 characters)
99 """
100- accounts_str = ', '.join([acc or '' for acc in self._get_accounts(data)])
101- return (len(accounts_str) <= 300) and accounts_str or ("%s%s" % (accounts_str[:297], '...'))
102+ data_tools_obj = self.pool.get('data.tools')
103+ return data_tools_obj.truncate_list(self._get_accounts(data))
104
105 # PDF report with one partner per page
106 report_sxw.report_sxw('report.account.third_party_ledger', 'res.partner',
107
108=== modified file 'bin/addons/account/report/account_profit_loss.py'
109--- bin/addons/account/report/account_profit_loss.py 2017-04-19 12:44:30 +0000
110+++ bin/addons/account/report/account_profit_loss.py 2020-02-04 10:20:46 +0000
111@@ -192,6 +192,7 @@
112 return self.result.get(group, [])
113
114 def get_display_info(self, data):
115+ # reminder: in case other items are added in the "Display" col., truncate the text with the truncate_list method
116 info_data = []
117 all_str = _('All')
118
119@@ -232,6 +233,7 @@
120 return infos and ", \n".join(infos) or _('No Filter')
121
122 def get_prop_instances(self, data):
123+ data_tools_obj = self.pool.get('data.tools')
124 instances = []
125 if data.get('form', False):
126 if data['form'].get('instance_ids', False):
127@@ -242,7 +244,8 @@
128 # US-1166: mission only instances if none provided
129 instances = self._get_instances(get_code=True,
130 mission_filter=True)
131- return ', '.join(instances)
132+ return data_tools_obj.truncate_list(instances)
133+
134
135 report_sxw.report_sxw('report.pl.account.horizontal', 'account.account',
136 'addons/account/report/account_profit_horizontal.rml',parser=report_pl_account_horizontal, header='internal landscape')
137
138=== modified file 'bin/addons/finance/report/account_partner_balance_tree.py'
139--- bin/addons/finance/report/account_partner_balance_tree.py 2018-08-09 08:19:38 +0000
140+++ bin/addons/finance/report/account_partner_balance_tree.py 2020-02-04 10:20:46 +0000
141@@ -192,8 +192,8 @@
142 """
143 Returns the list of accounts as a String (cut if > 300 characters)
144 """
145- accounts_str = ', '.join([acc or '' for acc in self._get_accounts(data)])
146- return (len(accounts_str) <= 300) and accounts_str or ("%s%s" % (accounts_str[:297], '...'))
147+ data_tools_obj = self.pool.get('data.tools')
148+ return data_tools_obj.truncate_list(self._get_accounts(data))
149
150 def _get_filter(self, data):
151 if data.get('form', False) and data['form'].get('filter', False):
152@@ -229,8 +229,8 @@
153 """
154 Returns the list of journals as a String (cut if > 300 characters)
155 """
156- journals_str = ', '.join([journal or '' for journal in self._get_journal(data)])
157- return (len(journals_str) <= 300) and journals_str or ("%s%s" % (journals_str[:297], '...'))
158+ data_tools_obj = self.pool.get('data.tools')
159+ return data_tools_obj.truncate_list(self._get_journal(data))
160
161 def _get_prop_instances(self, data):
162 """
163@@ -245,14 +245,18 @@
164 """
165 Returns the list of instances as a String (cut if > 300 characters)
166 """
167+ display_limit = 300
168 if pdf:
169 # in the PDF version instances are listed one below the other and instance names are cut if > 20 characters
170 instances_str = ',\n'.join([(len(inst) <= 20) and inst or ("%s%s" % (inst[:17], '...'))
171 for inst in self._get_prop_instances(data)])
172+ if len(instances_str) > display_limit:
173+ instances_str = "%s%s" % (instances_str[:display_limit-3], '...')
174 else:
175 # otherwise instances are simply separated by a comma
176- instances_str = ', '.join([inst or '' for inst in self._get_prop_instances(data)])
177- return (len(instances_str) <= 300) and instances_str or ("%s%s" % (instances_str[:297], '...'))
178+ data_tools_obj = self.pool.get('data.tools')
179+ instances_str = data_tools_obj.truncate_list(self._get_prop_instances(data), limit=display_limit)
180+ return instances_str
181
182
183 class account_partner_balance_tree_xls(SpreadsheetReport):
184
185=== modified file 'bin/addons/msf_tools/msf_tools.py'
186--- bin/addons/msf_tools/msf_tools.py 2019-09-10 08:41:23 +0000
187+++ bin/addons/msf_tools/msf_tools.py 2020-02-04 10:20:46 +0000
188@@ -329,6 +329,17 @@
189
190 return True
191
192+ def truncate_list(self, item_list, limit=300, separator=', '):
193+ """
194+ Returns a string corresponding to the list of items in parameter, separated by the "separator".
195+ If the string > "limit", cuts it and adds "..." at the end.
196+ """
197+ list_str = separator.join([item for item in item_list if item]) or ''
198+ if len(list_str) > limit:
199+ list_str = "%s%s" % (list_str[:limit-3], '...')
200+ return list_str
201+
202+
203 data_tools()
204
205

Subscribers

People subscribed via source and target branches