Merge lp:~jfb-tempo-consulting/unifield-server/US-6078 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 5392
Proposed branch: lp:~jfb-tempo-consulting/unifield-server/US-6078
Merge into: lp:unifield-server
Diff against target: 213 lines (+59/-20)
4 files modified
bin/addons/account_override/account.py (+6/-1)
bin/addons/msf_doc_import/msf_import_export.py (+38/-11)
bin/addons/msf_doc_import/msf_import_export_conf.py (+13/-8)
bin/addons/msf_doc_import/report/import_generic_template.py (+2/-0)
To merge this branch: bzr merge lp:~jfb-tempo-consulting/unifield-server/US-6078
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+367975@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_override/account.py'
--- bin/addons/account_override/account.py 2019-05-14 14:58:02 +0000
+++ bin/addons/account_override/account.py 2019-05-28 09:09:44 +0000
@@ -418,6 +418,8 @@
418 """418 """
419 Use "-" instead of " " between name and code for account's default name419 Use "-" instead of " " between name and code for account's default name
420 """420 """
421 if context is None:
422 context = {}
421 if not ids:423 if not ids:
422 return []424 return []
423 reads = self.read(cr, uid, ids, ['name', 'code'], context=context)425 reads = self.read(cr, uid, ids, ['name', 'code'], context=context)
@@ -425,7 +427,10 @@
425 for record in reads:427 for record in reads:
426 name = record['name']428 name = record['name']
427 if record['code']:429 if record['code']:
428 name = record['code'] + ' - '+name430 if context.get('account_only_code'):
431 name = record['code']
432 else:
433 name = record['code'] + ' - '+name
429 res.append((record['id'], name))434 res.append((record['id'], name))
430 return res435 return res
431436
432437
=== modified file 'bin/addons/msf_doc_import/msf_import_export.py'
--- bin/addons/msf_doc_import/msf_import_export.py 2019-05-14 15:12:35 +0000
+++ bin/addons/msf_doc_import/msf_import_export.py 2019-05-28 09:09:44 +0000
@@ -648,6 +648,9 @@
648 acc_analytic_obj = self.pool.get('account.analytic.account')648 acc_analytic_obj = self.pool.get('account.analytic.account')
649 acc_dest_obj = self.pool.get('account.destination.link')649 acc_dest_obj = self.pool.get('account.destination.link')
650650
651 cost_centers_cache = {}
652 gl_account_cache = {}
653 parent_ok_cache = {}
651 import_data_obj = self.pool.get('import_data')654 import_data_obj = self.pool.get('import_data')
652 prod_nomenclature_obj = self.pool.get('product.nomenclature')655 prod_nomenclature_obj = self.pool.get('product.nomenclature')
653656
@@ -725,6 +728,16 @@
725 fields_def = impobj.fields_get(cr, uid, context=context)728 fields_def = impobj.fields_get(cr, uid, context=context)
726 i = 0729 i = 0
727730
731 # custom process to retrieve CC, Destination_ids
732 custom_m2m = []
733 if import_brw.model_list_selection == 'destinations':
734 custom_m2m = ['dest_cc_ids', 'destination_ids']
735 elif import_brw.model_list_selection == 'funding_pools':
736 custom_m2m = ['cost_center_ids', 'tuple_destination_account_ids']
737 for c_m2m in custom_m2m:
738 if c_m2m in fields_def:
739 fields_def[c_m2m]['type'] = 'many2many_custom'
740
728 def _get_obj(header, value, fields_def):741 def _get_obj(header, value, fields_def):
729 list_obj = header.split('.')742 list_obj = header.split('.')
730 relation = fields_def[list_obj[0]]['relation']743 relation = fields_def[list_obj[0]]['relation']
@@ -964,6 +977,7 @@
964977
965 # Funding Pools978 # Funding Pools
966 if import_brw.model_list_selection == 'funding_pools':979 if import_brw.model_list_selection == 'funding_pools':
980 ids_to_update = acc_analytic_obj.search(cr, uid, [('code', '=ilike', data.get('code')), ('category', '=', 'FUNDING')])
967 context['from_import_menu'] = True981 context['from_import_menu'] = True
968 data['category'] = 'FUNDING'982 data['category'] = 'FUNDING'
969 # Parent Analytic Account983 # Parent Analytic Account
@@ -1016,10 +1030,13 @@
1016 data['category'] = 'DEST'1030 data['category'] = 'DEST'
1017 # Parent Analytic Account1031 # Parent Analytic Account
1018 if data.get('parent_id'):1032 if data.get('parent_id'):
1019 parent_id = acc_analytic_obj.browse(cr, uid, data['parent_id'], fields_to_fetch=['type', 'category'], context=context)1033 if data['parent_id'] not in parent_ok_cache:
1020 parent_type = parent_id.type or ''1034 parent_id = acc_analytic_obj.browse(cr, uid, data['parent_id'], fields_to_fetch=['type', 'category'], context=context)
1021 parent_category = parent_id.category or ''1035 parent_type = parent_id.type or ''
1022 if parent_type != 'view' or parent_category != 'DEST':1036 parent_category = parent_id.category or ''
1037 if parent_type == 'view' and parent_category == 'DEST':
1038 parent_ok_cache[data['parent_id']] = True
1039 if not parent_ok_cache.get(data['parent_id']):
1023 raise Exception(_('The Parent Analytic Account must be a View type Destination.'))1040 raise Exception(_('The Parent Analytic Account must be a View type Destination.'))
1024 # Type1041 # Type
1025 if data['type'] not in ['normal', 'view']:1042 if data['type'] not in ['normal', 'view']:
@@ -1029,11 +1046,15 @@
1029 if data.get('allow_all_cc'):1046 if data.get('allow_all_cc'):
1030 raise Exception(_("Please either list the Cost Centers to allow, or allow all Cost Centers."))1047 raise Exception(_("Please either list the Cost Centers to allow, or allow all Cost Centers."))
1031 dest_cc_list = []1048 dest_cc_list = []
1032 for cost_center in data.get('dest_cc_ids').split(','):1049 split_char = ';'
1050 if split_char not in data.get('dest_cc_ids'):
1051 split_char = ','
1052 for cost_center in data.get('dest_cc_ids').split(split_char):
1033 cc = cost_center.strip()1053 cc = cost_center.strip()
1034 cc_dom = [('category', '=', 'OC'), ('type', '=', 'normal'),1054 if cc not in cost_centers_cache:
1035 '|', ('code', '=', cc), ('name', '=', cc)]1055 cc_dom = [('category', '=', 'OC'), ('type', '=', 'normal'), ('code', '=', cc)]
1036 cc_ids = impobj.search(cr, uid, cc_dom, order='id', limit=1, context=context)1056 cost_centers_cache[cc] = impobj.search(cr, uid, cc_dom, order='id', limit=1, context=context)
1057 cc_ids = cost_centers_cache.get(cc)
1037 if cc_ids:1058 if cc_ids:
1038 dest_cc_list.append(cc_ids[0])1059 dest_cc_list.append(cc_ids[0])
1039 else:1060 else:
@@ -1044,10 +1065,15 @@
1044 # Accounts1065 # Accounts
1045 if data.get('destination_ids'): # "destinations_ids" corresponds to G/L accounts...1066 if data.get('destination_ids'): # "destinations_ids" corresponds to G/L accounts...
1046 acc_list = []1067 acc_list = []
1047 for account in data.get('destination_ids').split(','):1068 split_char = ';'
1069 if split_char not in data.get('destination_ids'):
1070 split_char = ','
1071 for account in data.get('destination_ids').split(split_char):
1048 acc = account.strip()1072 acc = account.strip()
1049 acc_dom = [('type', '!=', 'view'), ('is_analytic_addicted', '=', True), ('code', '=', acc)]1073 if acc not in gl_account_cache:
1050 acc_ids = acc_obj.search(cr, uid, acc_dom, order='id', limit=1, context=context)1074 acc_dom = [('type', '!=', 'view'), ('is_analytic_addicted', '=', True), ('code', '=', acc)]
1075 gl_account_cache[acc] = acc_obj.search(cr, uid, acc_dom, order='id', limit=1, context=context)
1076 acc_ids = gl_account_cache.get(acc)
1051 if acc_ids:1077 if acc_ids:
1052 acc_list.append(acc_ids[0])1078 acc_list.append(acc_ids[0])
1053 else:1079 else:
@@ -1082,6 +1108,7 @@
10821108
1083 # Cost Centers1109 # Cost Centers
1084 if import_brw.model_list_selection == 'cost_centers':1110 if import_brw.model_list_selection == 'cost_centers':
1111 ids_to_update = acc_analytic_obj.search(cr, uid, [('code', '=ilike', data.get('code')), ('category', '=', 'OC')])
1085 context['from_import_menu'] = True1112 context['from_import_menu'] = True
1086 data['category'] = 'OC'1113 data['category'] = 'OC'
1087 # Parent Analytic Account1114 # Parent Analytic Account
10881115
=== modified file 'bin/addons/msf_doc_import/msf_import_export_conf.py'
--- bin/addons/msf_doc_import/msf_import_export_conf.py 2019-05-14 15:12:35 +0000
+++ bin/addons/msf_doc_import/msf_import_export_conf.py 2019-05-28 09:09:44 +0000
@@ -98,27 +98,32 @@
98 'funding_pools': {98 'funding_pools': {
99 'name': 'Funding Pools',99 'name': 'Funding Pools',
100 'domain_type': 'finance',100 'domain_type': 'finance',
101 'model': 'account.analytic.account'101 'model': 'account.analytic.account',
102 'domain': [('category', '=', 'FUNDING'), ('parent_id', '!=', False)]
102 },103 },
103 'destinations': {104 'destinations': {
104 'name': 'Destinations',105 'name': 'Destinations',
105 'domain_type': 'finance',106 'domain_type': 'finance',
106 'model': 'account.analytic.account'107 'model': 'account.analytic.account',
108 'domain': [('category', '=', 'DEST'), ('parent_id', '!=', False)]
107 },109 },
108 'cost_centers': {110 'cost_centers': {
109 'name': 'Cost Centers',111 'name': 'Cost Centers',
110 'domain_type': 'finance',112 'domain_type': 'finance',
111 'model': 'account.analytic.account'113 'model': 'account.analytic.account',
114 'domain': [('category', '=', 'OC'), ('parent_id', '!=', False)]
112 },115 },
113 'free1': {116 'free1': {
114 'name': 'Free 1',117 'name': 'Free 1',
115 'domain_type': 'finance',118 'domain_type': 'finance',
116 'model': 'account.analytic.account'119 'model': 'account.analytic.account',
120 'domain': [('category', '=', 'FREE1'), ('parent_id', '!=', False)]
117 },121 },
118 'free2': {122 'free2': {
119 'name': 'Free 2',123 'name': 'Free 2',
120 'domain_type': 'finance',124 'domain_type': 'finance',
121 'model': 'account.analytic.account'125 'model': 'account.analytic.account',
126 'domain': [('category', '=', 'FREE2'), ('parent_id', '!=', False)]
122 },127 },
123 'analytic_journals': {128 'analytic_journals': {
124 'name': 'Analytic Journals',129 'name': 'Analytic Journals',
@@ -503,8 +508,8 @@
503 },508 },
504 'funding_pools': {509 'funding_pools': {
505 'header_list': [510 'header_list': [
511 'code',
506 'name',512 'name',
507 'code',
508 'parent_id.code',513 'parent_id.code',
509 'type',514 'type',
510 'date_start',515 'date_start',
@@ -522,8 +527,8 @@
522 },527 },
523 'cost_centers': {528 'cost_centers': {
524 'header_list': [529 'header_list': [
530 'code',
525 'name',531 'name',
526 'code',
527 'parent_id.code',532 'parent_id.code',
528 'type',533 'type',
529 'date_start',534 'date_start',
@@ -538,8 +543,8 @@
538 },543 },
539 'destinations': {544 'destinations': {
540 'header_list': [545 'header_list': [
546 'code',
541 'name',547 'name',
542 'code',
543 'parent_id.code',548 'parent_id.code',
544 'type',549 'type',
545 'date_start',550 'date_start',
546551
=== modified file 'bin/addons/msf_doc_import/report/import_generic_template.py'
--- bin/addons/msf_doc_import/report/import_generic_template.py 2019-05-06 09:49:19 +0000
+++ bin/addons/msf_doc_import/report/import_generic_template.py 2019-05-28 09:09:44 +0000
@@ -147,6 +147,8 @@
147 new_ctx = context.copy()147 new_ctx = context.copy()
148 if 'lang' in MODEL_DICT.get(data['selection'], {}):148 if 'lang' in MODEL_DICT.get(data['selection'], {}):
149 new_ctx['lang'] = MODEL_DICT[data['selection']]['lang']149 new_ctx['lang'] = MODEL_DICT[data['selection']]['lang']
150 if data['selection'] == 'destinations':
151 new_ctx['account_only_code'] = True
150 for i in range(0, len(ids), chunk_size):152 for i in range(0, len(ids), chunk_size):
151 ids_chunk = ids[i:i + chunk_size]153 ids_chunk = ids[i:i + chunk_size]
152 context['translate_selection_field'] = True154 context['translate_selection_field'] = True

Subscribers

People subscribed via source and target branches