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
=== modified file 'bin/addons/account/report/account_balance_sheet.py'
--- bin/addons/account/report/account_balance_sheet.py 2017-06-08 16:00:51 +0000
+++ bin/addons/account/report/account_balance_sheet.py 2020-02-04 10:20:46 +0000
@@ -285,6 +285,7 @@
285 return self.result.get(group, [])285 return self.result.get(group, [])
286286
287 def get_display_info(self, data):287 def get_display_info(self, data):
288 # reminder: in case other items are added in the "Display" col., truncate the text with the truncate_list method
288 info_data = []289 info_data = []
289 all_str = _('All')290 all_str = _('All')
290291
@@ -325,6 +326,7 @@
325 return infos and ", \n".join(infos) or _('No Filter')326 return infos and ", \n".join(infos) or _('No Filter')
326327
327 def get_prop_instances(self, data):328 def get_prop_instances(self, data):
329 data_tools_obj = self.pool.get('data.tools')
328 instances = []330 instances = []
329 if data.get('form', False):331 if data.get('form', False):
330 if data['form'].get('instance_ids', False):332 if data['form'].get('instance_ids', False):
@@ -335,7 +337,7 @@
335 # US-1166: mission only instances if none provided337 # US-1166: mission only instances if none provided
336 instances = self._get_instances(get_code=True,338 instances = self._get_instances(get_code=True,
337 mission_filter=True)339 mission_filter=True)
338 return ', '.join(instances)340 return data_tools_obj.truncate_list(instances)
339341
340report_sxw.report_sxw('report.account.balancesheet.horizontal', 'account.account',342report_sxw.report_sxw('report.account.balancesheet.horizontal', 'account.account',
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,
342344
=== modified file 'bin/addons/account/report/account_general_ledger.py'
--- bin/addons/account/report/account_general_ledger.py 2019-07-31 15:26:10 +0000
+++ bin/addons/account/report/account_general_ledger.py 2020-02-04 10:20:46 +0000
@@ -495,15 +495,18 @@
495 return amount495 return amount
496496
497 def _get_prop_instances_str(self):497 def _get_prop_instances_str(self):
498 return ', '.join([ i.code \498 data_tools_obj = self.pool.get('data.tools')
499 for i in self.pool.get('msf.instance').browse(self.cr, self.uid, self.selected_instance_ids) \499 inst_list = [ i.code \
500 if i.code ])500 for i in self.pool.get('msf.instance').browse(self.cr, self.uid, self.selected_instance_ids) \
501 if i.code ]
502 return data_tools_obj.truncate_list(inst_list)
501503
502 def _get_journals_str(self, data):504 def _get_journals_str(self, data):
505 data_tools_obj = self.pool.get('data.tools')
503 if 'all_journals' in data['form']:506 if 'all_journals' in data['form']:
504 return _('All Journals')507 return _('All Journals')
505 return ', '.join(list(set(self._get_journal(data,508 journal_list = list(set(self._get_journal(data, instance_ids=self.selected_instance_ids)))
506 instance_ids=self.selected_instance_ids))))509 return data_tools_obj.truncate_list(journal_list)
507510
508 # internal filter functions511 # internal filter functions
509 def _get_data_form(self, data, key, default=False):512 def _get_data_form(self, data, key, default=False):
@@ -512,6 +515,7 @@
512 return data['form'].get(key, default)515 return data['form'].get(key, default)
513516
514 def _get_display_info(self, data):517 def _get_display_info(self, data):
518 data_tools_obj = self.pool.get('data.tools')
515 info_data = []519 info_data = []
516 yes_str = _('Yes')520 yes_str = _('Yes')
517 no_str = _('No')521 no_str = _('No')
@@ -550,7 +554,7 @@
550 if a.type != 'view' ], )))554 if a.type != 'view' ], )))
551555
552 res = [ "%s: %s" % (label, val, ) for label, val in info_data ]556 res = [ "%s: %s" % (label, val, ) for label, val in info_data ]
553 return ', \n'.join(res)557 return data_tools_obj.truncate_list(res, separator=', \n')
554558
555 def _get_open_items_selection(self, data):559 def _get_open_items_selection(self, data):
556 """560 """
557561
=== modified file 'bin/addons/account/report/account_partner_ledger.py'
--- bin/addons/account/report/account_partner_ledger.py 2018-08-20 09:13:59 +0000
+++ bin/addons/account/report/account_partner_ledger.py 2020-02-04 10:20:46 +0000
@@ -484,22 +484,22 @@
484 """484 """
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)
486 """486 """
487 journals_str = ', '.join([journal or '' for journal in self._get_journal(data)])487 data_tools_obj = self.pool.get('data.tools')
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))
489489
490 def _get_instances_str(self, data):490 def _get_instances_str(self, data):
491 """491 """
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)
493 """493 """
494 instances_str = ', '.join([inst or '' for inst in self._get_instances_from_data(data)])494 data_tools_obj = self.pool.get('data.tools')
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))
496496
497 def _get_accounts_str(self, data):497 def _get_accounts_str(self, data):
498 """498 """
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)
500 """500 """
501 accounts_str = ', '.join([acc or '' for acc in self._get_accounts(data)])501 data_tools_obj = self.pool.get('data.tools')
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))
503503
504# PDF report with one partner per page504# PDF report with one partner per page
505report_sxw.report_sxw('report.account.third_party_ledger', 'res.partner',505report_sxw.report_sxw('report.account.third_party_ledger', 'res.partner',
506506
=== modified file 'bin/addons/account/report/account_profit_loss.py'
--- bin/addons/account/report/account_profit_loss.py 2017-04-19 12:44:30 +0000
+++ bin/addons/account/report/account_profit_loss.py 2020-02-04 10:20:46 +0000
@@ -192,6 +192,7 @@
192 return self.result.get(group, [])192 return self.result.get(group, [])
193193
194 def get_display_info(self, data):194 def get_display_info(self, data):
195 # reminder: in case other items are added in the "Display" col., truncate the text with the truncate_list method
195 info_data = []196 info_data = []
196 all_str = _('All')197 all_str = _('All')
197198
@@ -232,6 +233,7 @@
232 return infos and ", \n".join(infos) or _('No Filter')233 return infos and ", \n".join(infos) or _('No Filter')
233234
234 def get_prop_instances(self, data):235 def get_prop_instances(self, data):
236 data_tools_obj = self.pool.get('data.tools')
235 instances = []237 instances = []
236 if data.get('form', False):238 if data.get('form', False):
237 if data['form'].get('instance_ids', False):239 if data['form'].get('instance_ids', False):
@@ -242,7 +244,8 @@
242 # US-1166: mission only instances if none provided244 # US-1166: mission only instances if none provided
243 instances = self._get_instances(get_code=True,245 instances = self._get_instances(get_code=True,
244 mission_filter=True)246 mission_filter=True)
245 return ', '.join(instances)247 return data_tools_obj.truncate_list(instances)
248
246249
247report_sxw.report_sxw('report.pl.account.horizontal', 'account.account',250report_sxw.report_sxw('report.pl.account.horizontal', 'account.account',
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')
249252
=== modified file 'bin/addons/finance/report/account_partner_balance_tree.py'
--- bin/addons/finance/report/account_partner_balance_tree.py 2018-08-09 08:19:38 +0000
+++ bin/addons/finance/report/account_partner_balance_tree.py 2020-02-04 10:20:46 +0000
@@ -192,8 +192,8 @@
192 """192 """
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)
194 """194 """
195 accounts_str = ', '.join([acc or '' for acc in self._get_accounts(data)])195 data_tools_obj = self.pool.get('data.tools')
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))
197197
198 def _get_filter(self, data):198 def _get_filter(self, data):
199 if data.get('form', False) and data['form'].get('filter', False):199 if data.get('form', False) and data['form'].get('filter', False):
@@ -229,8 +229,8 @@
229 """229 """
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)
231 """231 """
232 journals_str = ', '.join([journal or '' for journal in self._get_journal(data)])232 data_tools_obj = self.pool.get('data.tools')
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))
234234
235 def _get_prop_instances(self, data):235 def _get_prop_instances(self, data):
236 """236 """
@@ -245,14 +245,18 @@
245 """245 """
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)
247 """247 """
248 display_limit = 300
248 if pdf:249 if pdf:
249 # in the PDF version instances are listed one below the other and instance names are cut if > 20 characters250 # in the PDF version instances are listed one below the other and instance names are cut if > 20 characters
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], '...'))
251 for inst in self._get_prop_instances(data)])252 for inst in self._get_prop_instances(data)])
253 if len(instances_str) > display_limit:
254 instances_str = "%s%s" % (instances_str[:display_limit-3], '...')
252 else:255 else:
253 # otherwise instances are simply separated by a comma256 # otherwise instances are simply separated by a comma
254 instances_str = ', '.join([inst or '' for inst in self._get_prop_instances(data)])257 data_tools_obj = self.pool.get('data.tools')
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)
259 return instances_str
256260
257261
258class account_partner_balance_tree_xls(SpreadsheetReport):262class account_partner_balance_tree_xls(SpreadsheetReport):
259263
=== modified file 'bin/addons/msf_tools/msf_tools.py'
--- bin/addons/msf_tools/msf_tools.py 2019-09-10 08:41:23 +0000
+++ bin/addons/msf_tools/msf_tools.py 2020-02-04 10:20:46 +0000
@@ -329,6 +329,17 @@
329329
330 return True330 return True
331331
332 def truncate_list(self, item_list, limit=300, separator=', '):
333 """
334 Returns a string corresponding to the list of items in parameter, separated by the "separator".
335 If the string > "limit", cuts it and adds "..." at the end.
336 """
337 list_str = separator.join([item for item in item_list if item]) or ''
338 if len(list_str) > limit:
339 list_str = "%s%s" % (list_str[:limit-3], '...')
340 return list_str
341
342
332data_tools()343data_tools()
333344
334345

Subscribers

People subscribed via source and target branches