Merge lp:~jfb-tempo-consulting/unifield-server/US-6078 into lp:unifield-server
- US-6078
- Merge into trunk
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
UniField Reviewer Team | Pending | ||
Review via email: mp+367975@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_override/account.py' | |||
2 | --- bin/addons/account_override/account.py 2019-05-14 14:58:02 +0000 | |||
3 | +++ bin/addons/account_override/account.py 2019-05-28 09:09:44 +0000 | |||
4 | @@ -418,6 +418,8 @@ | |||
5 | 418 | """ | 418 | """ |
6 | 419 | Use "-" instead of " " between name and code for account's default name | 419 | Use "-" instead of " " between name and code for account's default name |
7 | 420 | """ | 420 | """ |
8 | 421 | if context is None: | ||
9 | 422 | context = {} | ||
10 | 421 | if not ids: | 423 | if not ids: |
11 | 422 | return [] | 424 | return [] |
12 | 423 | reads = self.read(cr, uid, ids, ['name', 'code'], context=context) | 425 | reads = self.read(cr, uid, ids, ['name', 'code'], context=context) |
13 | @@ -425,7 +427,10 @@ | |||
14 | 425 | for record in reads: | 427 | for record in reads: |
15 | 426 | name = record['name'] | 428 | name = record['name'] |
16 | 427 | if record['code']: | 429 | if record['code']: |
18 | 428 | name = record['code'] + ' - '+name | 430 | if context.get('account_only_code'): |
19 | 431 | name = record['code'] | ||
20 | 432 | else: | ||
21 | 433 | name = record['code'] + ' - '+name | ||
22 | 429 | res.append((record['id'], name)) | 434 | res.append((record['id'], name)) |
23 | 430 | return res | 435 | return res |
24 | 431 | 436 | ||
25 | 432 | 437 | ||
26 | === modified file 'bin/addons/msf_doc_import/msf_import_export.py' | |||
27 | --- bin/addons/msf_doc_import/msf_import_export.py 2019-05-14 15:12:35 +0000 | |||
28 | +++ bin/addons/msf_doc_import/msf_import_export.py 2019-05-28 09:09:44 +0000 | |||
29 | @@ -648,6 +648,9 @@ | |||
30 | 648 | acc_analytic_obj = self.pool.get('account.analytic.account') | 648 | acc_analytic_obj = self.pool.get('account.analytic.account') |
31 | 649 | acc_dest_obj = self.pool.get('account.destination.link') | 649 | acc_dest_obj = self.pool.get('account.destination.link') |
32 | 650 | 650 | ||
33 | 651 | cost_centers_cache = {} | ||
34 | 652 | gl_account_cache = {} | ||
35 | 653 | parent_ok_cache = {} | ||
36 | 651 | import_data_obj = self.pool.get('import_data') | 654 | import_data_obj = self.pool.get('import_data') |
37 | 652 | prod_nomenclature_obj = self.pool.get('product.nomenclature') | 655 | prod_nomenclature_obj = self.pool.get('product.nomenclature') |
38 | 653 | 656 | ||
39 | @@ -725,6 +728,16 @@ | |||
40 | 725 | fields_def = impobj.fields_get(cr, uid, context=context) | 728 | fields_def = impobj.fields_get(cr, uid, context=context) |
41 | 726 | i = 0 | 729 | i = 0 |
42 | 727 | 730 | ||
43 | 731 | # custom process to retrieve CC, Destination_ids | ||
44 | 732 | custom_m2m = [] | ||
45 | 733 | if import_brw.model_list_selection == 'destinations': | ||
46 | 734 | custom_m2m = ['dest_cc_ids', 'destination_ids'] | ||
47 | 735 | elif import_brw.model_list_selection == 'funding_pools': | ||
48 | 736 | custom_m2m = ['cost_center_ids', 'tuple_destination_account_ids'] | ||
49 | 737 | for c_m2m in custom_m2m: | ||
50 | 738 | if c_m2m in fields_def: | ||
51 | 739 | fields_def[c_m2m]['type'] = 'many2many_custom' | ||
52 | 740 | |||
53 | 728 | def _get_obj(header, value, fields_def): | 741 | def _get_obj(header, value, fields_def): |
54 | 729 | list_obj = header.split('.') | 742 | list_obj = header.split('.') |
55 | 730 | relation = fields_def[list_obj[0]]['relation'] | 743 | relation = fields_def[list_obj[0]]['relation'] |
56 | @@ -964,6 +977,7 @@ | |||
57 | 964 | 977 | ||
58 | 965 | # Funding Pools | 978 | # Funding Pools |
59 | 966 | if import_brw.model_list_selection == 'funding_pools': | 979 | if import_brw.model_list_selection == 'funding_pools': |
60 | 980 | ids_to_update = acc_analytic_obj.search(cr, uid, [('code', '=ilike', data.get('code')), ('category', '=', 'FUNDING')]) | ||
61 | 967 | context['from_import_menu'] = True | 981 | context['from_import_menu'] = True |
62 | 968 | data['category'] = 'FUNDING' | 982 | data['category'] = 'FUNDING' |
63 | 969 | # Parent Analytic Account | 983 | # Parent Analytic Account |
64 | @@ -1016,10 +1030,13 @@ | |||
65 | 1016 | data['category'] = 'DEST' | 1030 | data['category'] = 'DEST' |
66 | 1017 | # Parent Analytic Account | 1031 | # Parent Analytic Account |
67 | 1018 | if data.get('parent_id'): | 1032 | if data.get('parent_id'): |
72 | 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: |
73 | 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) |
74 | 1021 | parent_category = parent_id.category or '' | 1035 | parent_type = parent_id.type or '' |
75 | 1022 | if parent_type != 'view' or parent_category != 'DEST': | 1036 | parent_category = parent_id.category or '' |
76 | 1037 | if parent_type == 'view' and parent_category == 'DEST': | ||
77 | 1038 | parent_ok_cache[data['parent_id']] = True | ||
78 | 1039 | if not parent_ok_cache.get(data['parent_id']): | ||
79 | 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.')) |
80 | 1024 | # Type | 1041 | # Type |
81 | 1025 | if data['type'] not in ['normal', 'view']: | 1042 | if data['type'] not in ['normal', 'view']: |
82 | @@ -1029,11 +1046,15 @@ | |||
83 | 1029 | if data.get('allow_all_cc'): | 1046 | if data.get('allow_all_cc'): |
84 | 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.")) |
85 | 1031 | dest_cc_list = [] | 1048 | dest_cc_list = [] |
87 | 1032 | for cost_center in data.get('dest_cc_ids').split(','): | 1049 | split_char = ';' |
88 | 1050 | if split_char not in data.get('dest_cc_ids'): | ||
89 | 1051 | split_char = ',' | ||
90 | 1052 | for cost_center in data.get('dest_cc_ids').split(split_char): | ||
91 | 1033 | cc = cost_center.strip() | 1053 | cc = cost_center.strip() |
95 | 1034 | cc_dom = [('category', '=', 'OC'), ('type', '=', 'normal'), | 1054 | if cc not in cost_centers_cache: |
96 | 1035 | '|', ('code', '=', cc), ('name', '=', cc)] | 1055 | cc_dom = [('category', '=', 'OC'), ('type', '=', 'normal'), ('code', '=', cc)] |
97 | 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) |
98 | 1057 | cc_ids = cost_centers_cache.get(cc) | ||
99 | 1037 | if cc_ids: | 1058 | if cc_ids: |
100 | 1038 | dest_cc_list.append(cc_ids[0]) | 1059 | dest_cc_list.append(cc_ids[0]) |
101 | 1039 | else: | 1060 | else: |
102 | @@ -1044,10 +1065,15 @@ | |||
103 | 1044 | # Accounts | 1065 | # Accounts |
104 | 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... |
105 | 1046 | acc_list = [] | 1067 | acc_list = [] |
107 | 1047 | for account in data.get('destination_ids').split(','): | 1068 | split_char = ';' |
108 | 1069 | if split_char not in data.get('destination_ids'): | ||
109 | 1070 | split_char = ',' | ||
110 | 1071 | for account in data.get('destination_ids').split(split_char): | ||
111 | 1048 | acc = account.strip() | 1072 | acc = account.strip() |
114 | 1049 | acc_dom = [('type', '!=', 'view'), ('is_analytic_addicted', '=', True), ('code', '=', acc)] | 1073 | if acc not in gl_account_cache: |
115 | 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)] |
116 | 1075 | gl_account_cache[acc] = acc_obj.search(cr, uid, acc_dom, order='id', limit=1, context=context) | ||
117 | 1076 | acc_ids = gl_account_cache.get(acc) | ||
118 | 1051 | if acc_ids: | 1077 | if acc_ids: |
119 | 1052 | acc_list.append(acc_ids[0]) | 1078 | acc_list.append(acc_ids[0]) |
120 | 1053 | else: | 1079 | else: |
121 | @@ -1082,6 +1108,7 @@ | |||
122 | 1082 | 1108 | ||
123 | 1083 | # Cost Centers | 1109 | # Cost Centers |
124 | 1084 | if import_brw.model_list_selection == 'cost_centers': | 1110 | if import_brw.model_list_selection == 'cost_centers': |
125 | 1111 | ids_to_update = acc_analytic_obj.search(cr, uid, [('code', '=ilike', data.get('code')), ('category', '=', 'OC')]) | ||
126 | 1085 | context['from_import_menu'] = True | 1112 | context['from_import_menu'] = True |
127 | 1086 | data['category'] = 'OC' | 1113 | data['category'] = 'OC' |
128 | 1087 | # Parent Analytic Account | 1114 | # Parent Analytic Account |
129 | 1088 | 1115 | ||
130 | === modified file 'bin/addons/msf_doc_import/msf_import_export_conf.py' | |||
131 | --- bin/addons/msf_doc_import/msf_import_export_conf.py 2019-05-14 15:12:35 +0000 | |||
132 | +++ bin/addons/msf_doc_import/msf_import_export_conf.py 2019-05-28 09:09:44 +0000 | |||
133 | @@ -98,27 +98,32 @@ | |||
134 | 98 | 'funding_pools': { | 98 | 'funding_pools': { |
135 | 99 | 'name': 'Funding Pools', | 99 | 'name': 'Funding Pools', |
136 | 100 | 'domain_type': 'finance', | 100 | 'domain_type': 'finance', |
138 | 101 | 'model': 'account.analytic.account' | 101 | 'model': 'account.analytic.account', |
139 | 102 | 'domain': [('category', '=', 'FUNDING'), ('parent_id', '!=', False)] | ||
140 | 102 | }, | 103 | }, |
141 | 103 | 'destinations': { | 104 | 'destinations': { |
142 | 104 | 'name': 'Destinations', | 105 | 'name': 'Destinations', |
143 | 105 | 'domain_type': 'finance', | 106 | 'domain_type': 'finance', |
145 | 106 | 'model': 'account.analytic.account' | 107 | 'model': 'account.analytic.account', |
146 | 108 | 'domain': [('category', '=', 'DEST'), ('parent_id', '!=', False)] | ||
147 | 107 | }, | 109 | }, |
148 | 108 | 'cost_centers': { | 110 | 'cost_centers': { |
149 | 109 | 'name': 'Cost Centers', | 111 | 'name': 'Cost Centers', |
150 | 110 | 'domain_type': 'finance', | 112 | 'domain_type': 'finance', |
152 | 111 | 'model': 'account.analytic.account' | 113 | 'model': 'account.analytic.account', |
153 | 114 | 'domain': [('category', '=', 'OC'), ('parent_id', '!=', False)] | ||
154 | 112 | }, | 115 | }, |
155 | 113 | 'free1': { | 116 | 'free1': { |
156 | 114 | 'name': 'Free 1', | 117 | 'name': 'Free 1', |
157 | 115 | 'domain_type': 'finance', | 118 | 'domain_type': 'finance', |
159 | 116 | 'model': 'account.analytic.account' | 119 | 'model': 'account.analytic.account', |
160 | 120 | 'domain': [('category', '=', 'FREE1'), ('parent_id', '!=', False)] | ||
161 | 117 | }, | 121 | }, |
162 | 118 | 'free2': { | 122 | 'free2': { |
163 | 119 | 'name': 'Free 2', | 123 | 'name': 'Free 2', |
164 | 120 | 'domain_type': 'finance', | 124 | 'domain_type': 'finance', |
166 | 121 | 'model': 'account.analytic.account' | 125 | 'model': 'account.analytic.account', |
167 | 126 | 'domain': [('category', '=', 'FREE2'), ('parent_id', '!=', False)] | ||
168 | 122 | }, | 127 | }, |
169 | 123 | 'analytic_journals': { | 128 | 'analytic_journals': { |
170 | 124 | 'name': 'Analytic Journals', | 129 | 'name': 'Analytic Journals', |
171 | @@ -503,8 +508,8 @@ | |||
172 | 503 | }, | 508 | }, |
173 | 504 | 'funding_pools': { | 509 | 'funding_pools': { |
174 | 505 | 'header_list': [ | 510 | 'header_list': [ |
175 | 511 | 'code', | ||
176 | 506 | 'name', | 512 | 'name', |
177 | 507 | 'code', | ||
178 | 508 | 'parent_id.code', | 513 | 'parent_id.code', |
179 | 509 | 'type', | 514 | 'type', |
180 | 510 | 'date_start', | 515 | 'date_start', |
181 | @@ -522,8 +527,8 @@ | |||
182 | 522 | }, | 527 | }, |
183 | 523 | 'cost_centers': { | 528 | 'cost_centers': { |
184 | 524 | 'header_list': [ | 529 | 'header_list': [ |
185 | 530 | 'code', | ||
186 | 525 | 'name', | 531 | 'name', |
187 | 526 | 'code', | ||
188 | 527 | 'parent_id.code', | 532 | 'parent_id.code', |
189 | 528 | 'type', | 533 | 'type', |
190 | 529 | 'date_start', | 534 | 'date_start', |
191 | @@ -538,8 +543,8 @@ | |||
192 | 538 | }, | 543 | }, |
193 | 539 | 'destinations': { | 544 | 'destinations': { |
194 | 540 | 'header_list': [ | 545 | 'header_list': [ |
195 | 546 | 'code', | ||
196 | 541 | 'name', | 547 | 'name', |
197 | 542 | 'code', | ||
198 | 543 | 'parent_id.code', | 548 | 'parent_id.code', |
199 | 544 | 'type', | 549 | 'type', |
200 | 545 | 'date_start', | 550 | 'date_start', |
201 | 546 | 551 | ||
202 | === modified file 'bin/addons/msf_doc_import/report/import_generic_template.py' | |||
203 | --- bin/addons/msf_doc_import/report/import_generic_template.py 2019-05-06 09:49:19 +0000 | |||
204 | +++ bin/addons/msf_doc_import/report/import_generic_template.py 2019-05-28 09:09:44 +0000 | |||
205 | @@ -147,6 +147,8 @@ | |||
206 | 147 | new_ctx = context.copy() | 147 | new_ctx = context.copy() |
207 | 148 | if 'lang' in MODEL_DICT.get(data['selection'], {}): | 148 | if 'lang' in MODEL_DICT.get(data['selection'], {}): |
208 | 149 | new_ctx['lang'] = MODEL_DICT[data['selection']]['lang'] | 149 | new_ctx['lang'] = MODEL_DICT[data['selection']]['lang'] |
209 | 150 | if data['selection'] == 'destinations': | ||
210 | 151 | new_ctx['account_only_code'] = True | ||
211 | 150 | for i in range(0, len(ids), chunk_size): | 152 | for i in range(0, len(ids), chunk_size): |
212 | 151 | ids_chunk = ids[i:i + chunk_size] | 153 | ids_chunk = ids[i:i + chunk_size] |
213 | 152 | context['translate_selection_field'] = True | 154 | context['translate_selection_field'] = True |