Merge lp:~julie-w/unifield-server/US-6554 into lp:unifield-server
- US-6554
- Merge into trunk
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
UniField Reviewer Team | Pending | ||
Review via email: mp+378505@code.launchpad.net |
Commit message
Description of the change
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 | 285 | return self.result.get(group, []) | 285 | return self.result.get(group, []) |
6 | 286 | 286 | ||
7 | 287 | def get_display_info(self, data): | 287 | def get_display_info(self, data): |
8 | 288 | # reminder: in case other items are added in the "Display" col., truncate the text with the truncate_list method | ||
9 | 288 | info_data = [] | 289 | info_data = [] |
10 | 289 | all_str = _('All') | 290 | all_str = _('All') |
11 | 290 | 291 | ||
12 | @@ -325,6 +326,7 @@ | |||
13 | 325 | return infos and ", \n".join(infos) or _('No Filter') | 326 | return infos and ", \n".join(infos) or _('No Filter') |
14 | 326 | 327 | ||
15 | 327 | def get_prop_instances(self, data): | 328 | def get_prop_instances(self, data): |
16 | 329 | data_tools_obj = self.pool.get('data.tools') | ||
17 | 328 | instances = [] | 330 | instances = [] |
18 | 329 | if data.get('form', False): | 331 | if data.get('form', False): |
19 | 330 | if data['form'].get('instance_ids', False): | 332 | if data['form'].get('instance_ids', False): |
20 | @@ -335,7 +337,7 @@ | |||
21 | 335 | # US-1166: mission only instances if none provided | 337 | # US-1166: mission only instances if none provided |
22 | 336 | instances = self._get_instances(get_code=True, | 338 | instances = self._get_instances(get_code=True, |
23 | 337 | mission_filter=True) | 339 | mission_filter=True) |
25 | 338 | return ', '.join(instances) | 340 | return data_tools_obj.truncate_list(instances) |
26 | 339 | 341 | ||
27 | 340 | report_sxw.report_sxw('report.account.balancesheet.horizontal', 'account.account', | 342 | report_sxw.report_sxw('report.account.balancesheet.horizontal', 'account.account', |
28 | 341 | 'addons/account/report/account_balance_sheet_horizontal.rml',parser=report_balancesheet_horizontal, | 343 | 'addons/account/report/account_balance_sheet_horizontal.rml',parser=report_balancesheet_horizontal, |
29 | 342 | 344 | ||
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 | 495 | return amount | 495 | return amount |
35 | 496 | 496 | ||
36 | 497 | def _get_prop_instances_str(self): | 497 | def _get_prop_instances_str(self): |
40 | 498 | return ', '.join([ i.code \ | 498 | data_tools_obj = self.pool.get('data.tools') |
41 | 499 | for i in self.pool.get('msf.instance').browse(self.cr, self.uid, self.selected_instance_ids) \ | 499 | inst_list = [ i.code \ |
42 | 500 | if i.code ]) | 500 | for i in self.pool.get('msf.instance').browse(self.cr, self.uid, self.selected_instance_ids) \ |
43 | 501 | if i.code ] | ||
44 | 502 | return data_tools_obj.truncate_list(inst_list) | ||
45 | 501 | 503 | ||
46 | 502 | def _get_journals_str(self, data): | 504 | def _get_journals_str(self, data): |
47 | 505 | data_tools_obj = self.pool.get('data.tools') | ||
48 | 503 | if 'all_journals' in data['form']: | 506 | if 'all_journals' in data['form']: |
49 | 504 | return _('All Journals') | 507 | return _('All Journals') |
52 | 505 | return ', '.join(list(set(self._get_journal(data, | 508 | journal_list = list(set(self._get_journal(data, instance_ids=self.selected_instance_ids))) |
53 | 506 | instance_ids=self.selected_instance_ids)))) | 509 | return data_tools_obj.truncate_list(journal_list) |
54 | 507 | 510 | ||
55 | 508 | # internal filter functions | 511 | # internal filter functions |
56 | 509 | def _get_data_form(self, data, key, default=False): | 512 | def _get_data_form(self, data, key, default=False): |
57 | @@ -512,6 +515,7 @@ | |||
58 | 512 | return data['form'].get(key, default) | 515 | return data['form'].get(key, default) |
59 | 513 | 516 | ||
60 | 514 | def _get_display_info(self, data): | 517 | def _get_display_info(self, data): |
61 | 518 | data_tools_obj = self.pool.get('data.tools') | ||
62 | 515 | info_data = [] | 519 | info_data = [] |
63 | 516 | yes_str = _('Yes') | 520 | yes_str = _('Yes') |
64 | 517 | no_str = _('No') | 521 | no_str = _('No') |
65 | @@ -550,7 +554,7 @@ | |||
66 | 550 | if a.type != 'view' ], ))) | 554 | if a.type != 'view' ], ))) |
67 | 551 | 555 | ||
68 | 552 | res = [ "%s: %s" % (label, val, ) for label, val in info_data ] | 556 | res = [ "%s: %s" % (label, val, ) for label, val in info_data ] |
70 | 553 | return ', \n'.join(res) | 557 | return data_tools_obj.truncate_list(res, separator=', \n') |
71 | 554 | 558 | ||
72 | 555 | def _get_open_items_selection(self, data): | 559 | def _get_open_items_selection(self, data): |
73 | 556 | """ | 560 | """ |
74 | 557 | 561 | ||
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 | 484 | """ | 484 | """ |
80 | 485 | Returns the list of journals as a String (cut if > 300 characters) | 485 | Returns the list of journals as a String (cut if > 300 characters) |
81 | 486 | """ | 486 | """ |
84 | 487 | journals_str = ', '.join([journal or '' for journal in self._get_journal(data)]) | 487 | data_tools_obj = self.pool.get('data.tools') |
85 | 488 | return (len(journals_str) <= 300) and journals_str or ("%s%s" % (journals_str[:297], '...')) | 488 | return data_tools_obj.truncate_list(self._get_journal(data)) |
86 | 489 | 489 | ||
87 | 490 | def _get_instances_str(self, data): | 490 | def _get_instances_str(self, data): |
88 | 491 | """ | 491 | """ |
89 | 492 | Returns the list of instances as a String (cut if > 300 characters) | 492 | Returns the list of instances as a String (cut if > 300 characters) |
90 | 493 | """ | 493 | """ |
93 | 494 | instances_str = ', '.join([inst or '' for inst in self._get_instances_from_data(data)]) | 494 | data_tools_obj = self.pool.get('data.tools') |
94 | 495 | return (len(instances_str) <= 300) and instances_str or ("%s%s" % (instances_str[:297], '...')) | 495 | return data_tools_obj.truncate_list(self._get_instances_from_data(data)) |
95 | 496 | 496 | ||
96 | 497 | def _get_accounts_str(self, data): | 497 | def _get_accounts_str(self, data): |
97 | 498 | """ | 498 | """ |
98 | 499 | Returns the list of accounts as a String (cut if > 300 characters) | 499 | Returns the list of accounts as a String (cut if > 300 characters) |
99 | 500 | """ | 500 | """ |
102 | 501 | accounts_str = ', '.join([acc or '' for acc in self._get_accounts(data)]) | 501 | data_tools_obj = self.pool.get('data.tools') |
103 | 502 | return (len(accounts_str) <= 300) and accounts_str or ("%s%s" % (accounts_str[:297], '...')) | 502 | return data_tools_obj.truncate_list(self._get_accounts(data)) |
104 | 503 | 503 | ||
105 | 504 | # PDF report with one partner per page | 504 | # PDF report with one partner per page |
106 | 505 | report_sxw.report_sxw('report.account.third_party_ledger', 'res.partner', | 505 | report_sxw.report_sxw('report.account.third_party_ledger', 'res.partner', |
107 | 506 | 506 | ||
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 | 192 | return self.result.get(group, []) | 192 | return self.result.get(group, []) |
113 | 193 | 193 | ||
114 | 194 | def get_display_info(self, data): | 194 | def get_display_info(self, data): |
115 | 195 | # reminder: in case other items are added in the "Display" col., truncate the text with the truncate_list method | ||
116 | 195 | info_data = [] | 196 | info_data = [] |
117 | 196 | all_str = _('All') | 197 | all_str = _('All') |
118 | 197 | 198 | ||
119 | @@ -232,6 +233,7 @@ | |||
120 | 232 | return infos and ", \n".join(infos) or _('No Filter') | 233 | return infos and ", \n".join(infos) or _('No Filter') |
121 | 233 | 234 | ||
122 | 234 | def get_prop_instances(self, data): | 235 | def get_prop_instances(self, data): |
123 | 236 | data_tools_obj = self.pool.get('data.tools') | ||
124 | 235 | instances = [] | 237 | instances = [] |
125 | 236 | if data.get('form', False): | 238 | if data.get('form', False): |
126 | 237 | if data['form'].get('instance_ids', False): | 239 | if data['form'].get('instance_ids', False): |
127 | @@ -242,7 +244,8 @@ | |||
128 | 242 | # US-1166: mission only instances if none provided | 244 | # US-1166: mission only instances if none provided |
129 | 243 | instances = self._get_instances(get_code=True, | 245 | instances = self._get_instances(get_code=True, |
130 | 244 | mission_filter=True) | 246 | mission_filter=True) |
132 | 245 | return ', '.join(instances) | 247 | return data_tools_obj.truncate_list(instances) |
133 | 248 | |||
134 | 246 | 249 | ||
135 | 247 | report_sxw.report_sxw('report.pl.account.horizontal', 'account.account', | 250 | report_sxw.report_sxw('report.pl.account.horizontal', 'account.account', |
136 | 248 | 'addons/account/report/account_profit_horizontal.rml',parser=report_pl_account_horizontal, header='internal landscape') | 251 | 'addons/account/report/account_profit_horizontal.rml',parser=report_pl_account_horizontal, header='internal landscape') |
137 | 249 | 252 | ||
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 | 192 | """ | 192 | """ |
143 | 193 | Returns the list of accounts as a String (cut if > 300 characters) | 193 | Returns the list of accounts as a String (cut if > 300 characters) |
144 | 194 | """ | 194 | """ |
147 | 195 | accounts_str = ', '.join([acc or '' for acc in self._get_accounts(data)]) | 195 | data_tools_obj = self.pool.get('data.tools') |
148 | 196 | return (len(accounts_str) <= 300) and accounts_str or ("%s%s" % (accounts_str[:297], '...')) | 196 | return data_tools_obj.truncate_list(self._get_accounts(data)) |
149 | 197 | 197 | ||
150 | 198 | def _get_filter(self, data): | 198 | def _get_filter(self, data): |
151 | 199 | if data.get('form', False) and data['form'].get('filter', False): | 199 | if data.get('form', False) and data['form'].get('filter', False): |
152 | @@ -229,8 +229,8 @@ | |||
153 | 229 | """ | 229 | """ |
154 | 230 | Returns the list of journals as a String (cut if > 300 characters) | 230 | Returns the list of journals as a String (cut if > 300 characters) |
155 | 231 | """ | 231 | """ |
158 | 232 | journals_str = ', '.join([journal or '' for journal in self._get_journal(data)]) | 232 | data_tools_obj = self.pool.get('data.tools') |
159 | 233 | return (len(journals_str) <= 300) and journals_str or ("%s%s" % (journals_str[:297], '...')) | 233 | return data_tools_obj.truncate_list(self._get_journal(data)) |
160 | 234 | 234 | ||
161 | 235 | def _get_prop_instances(self, data): | 235 | def _get_prop_instances(self, data): |
162 | 236 | """ | 236 | """ |
163 | @@ -245,14 +245,18 @@ | |||
164 | 245 | """ | 245 | """ |
165 | 246 | Returns the list of instances as a String (cut if > 300 characters) | 246 | Returns the list of instances as a String (cut if > 300 characters) |
166 | 247 | """ | 247 | """ |
167 | 248 | display_limit = 300 | ||
168 | 248 | if pdf: | 249 | if pdf: |
169 | 249 | # in the PDF version instances are listed one below the other and instance names are cut if > 20 characters | 250 | # in the PDF version instances are listed one below the other and instance names are cut if > 20 characters |
170 | 250 | instances_str = ',\n'.join([(len(inst) <= 20) and inst or ("%s%s" % (inst[:17], '...')) | 251 | instances_str = ',\n'.join([(len(inst) <= 20) and inst or ("%s%s" % (inst[:17], '...')) |
171 | 251 | for inst in self._get_prop_instances(data)]) | 252 | for inst in self._get_prop_instances(data)]) |
172 | 253 | if len(instances_str) > display_limit: | ||
173 | 254 | instances_str = "%s%s" % (instances_str[:display_limit-3], '...') | ||
174 | 252 | else: | 255 | else: |
175 | 253 | # otherwise instances are simply separated by a comma | 256 | # otherwise instances are simply separated by a comma |
178 | 254 | instances_str = ', '.join([inst or '' for inst in self._get_prop_instances(data)]) | 257 | data_tools_obj = self.pool.get('data.tools') |
179 | 255 | return (len(instances_str) <= 300) and instances_str or ("%s%s" % (instances_str[:297], '...')) | 258 | instances_str = data_tools_obj.truncate_list(self._get_prop_instances(data), limit=display_limit) |
180 | 259 | return instances_str | ||
181 | 256 | 260 | ||
182 | 257 | 261 | ||
183 | 258 | class account_partner_balance_tree_xls(SpreadsheetReport): | 262 | class account_partner_balance_tree_xls(SpreadsheetReport): |
184 | 259 | 263 | ||
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 | 329 | 329 | ||
190 | 330 | return True | 330 | return True |
191 | 331 | 331 | ||
192 | 332 | def truncate_list(self, item_list, limit=300, separator=', '): | ||
193 | 333 | """ | ||
194 | 334 | Returns a string corresponding to the list of items in parameter, separated by the "separator". | ||
195 | 335 | If the string > "limit", cuts it and adds "..." at the end. | ||
196 | 336 | """ | ||
197 | 337 | list_str = separator.join([item for item in item_list if item]) or '' | ||
198 | 338 | if len(list_str) > limit: | ||
199 | 339 | list_str = "%s%s" % (list_str[:limit-3], '...') | ||
200 | 340 | return list_str | ||
201 | 341 | |||
202 | 342 | |||
203 | 332 | data_tools() | 343 | data_tools() |
204 | 333 | 344 | ||
205 | 334 | 345 |