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

Proposed by jftempo on 2019-05-28
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 2019-05-28 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
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 """
6 Use "-" instead of " " between name and code for account's default name
7 """
8+ if context is None:
9+ context = {}
10 if not ids:
11 return []
12 reads = self.read(cr, uid, ids, ['name', 'code'], context=context)
13@@ -425,7 +427,10 @@
14 for record in reads:
15 name = record['name']
16 if record['code']:
17- name = record['code'] + ' - '+name
18+ if context.get('account_only_code'):
19+ name = record['code']
20+ else:
21+ name = record['code'] + ' - '+name
22 res.append((record['id'], name))
23 return res
24
25
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 acc_analytic_obj = self.pool.get('account.analytic.account')
31 acc_dest_obj = self.pool.get('account.destination.link')
32
33+ cost_centers_cache = {}
34+ gl_account_cache = {}
35+ parent_ok_cache = {}
36 import_data_obj = self.pool.get('import_data')
37 prod_nomenclature_obj = self.pool.get('product.nomenclature')
38
39@@ -725,6 +728,16 @@
40 fields_def = impobj.fields_get(cr, uid, context=context)
41 i = 0
42
43+ # custom process to retrieve CC, Destination_ids
44+ custom_m2m = []
45+ if import_brw.model_list_selection == 'destinations':
46+ custom_m2m = ['dest_cc_ids', 'destination_ids']
47+ elif import_brw.model_list_selection == 'funding_pools':
48+ custom_m2m = ['cost_center_ids', 'tuple_destination_account_ids']
49+ for c_m2m in custom_m2m:
50+ if c_m2m in fields_def:
51+ fields_def[c_m2m]['type'] = 'many2many_custom'
52+
53 def _get_obj(header, value, fields_def):
54 list_obj = header.split('.')
55 relation = fields_def[list_obj[0]]['relation']
56@@ -964,6 +977,7 @@
57
58 # Funding Pools
59 if import_brw.model_list_selection == 'funding_pools':
60+ ids_to_update = acc_analytic_obj.search(cr, uid, [('code', '=ilike', data.get('code')), ('category', '=', 'FUNDING')])
61 context['from_import_menu'] = True
62 data['category'] = 'FUNDING'
63 # Parent Analytic Account
64@@ -1016,10 +1030,13 @@
65 data['category'] = 'DEST'
66 # Parent Analytic Account
67 if data.get('parent_id'):
68- parent_id = acc_analytic_obj.browse(cr, uid, data['parent_id'], fields_to_fetch=['type', 'category'], context=context)
69- parent_type = parent_id.type or ''
70- parent_category = parent_id.category or ''
71- if parent_type != 'view' or parent_category != 'DEST':
72+ if data['parent_id'] not in parent_ok_cache:
73+ parent_id = acc_analytic_obj.browse(cr, uid, data['parent_id'], fields_to_fetch=['type', 'category'], context=context)
74+ parent_type = parent_id.type or ''
75+ parent_category = parent_id.category or ''
76+ if parent_type == 'view' and parent_category == 'DEST':
77+ parent_ok_cache[data['parent_id']] = True
78+ if not parent_ok_cache.get(data['parent_id']):
79 raise Exception(_('The Parent Analytic Account must be a View type Destination.'))
80 # Type
81 if data['type'] not in ['normal', 'view']:
82@@ -1029,11 +1046,15 @@
83 if data.get('allow_all_cc'):
84 raise Exception(_("Please either list the Cost Centers to allow, or allow all Cost Centers."))
85 dest_cc_list = []
86- for cost_center in data.get('dest_cc_ids').split(','):
87+ split_char = ';'
88+ if split_char not in data.get('dest_cc_ids'):
89+ split_char = ','
90+ for cost_center in data.get('dest_cc_ids').split(split_char):
91 cc = cost_center.strip()
92- cc_dom = [('category', '=', 'OC'), ('type', '=', 'normal'),
93- '|', ('code', '=', cc), ('name', '=', cc)]
94- cc_ids = impobj.search(cr, uid, cc_dom, order='id', limit=1, context=context)
95+ if cc not in cost_centers_cache:
96+ cc_dom = [('category', '=', 'OC'), ('type', '=', 'normal'), ('code', '=', cc)]
97+ cost_centers_cache[cc] = impobj.search(cr, uid, cc_dom, order='id', limit=1, context=context)
98+ cc_ids = cost_centers_cache.get(cc)
99 if cc_ids:
100 dest_cc_list.append(cc_ids[0])
101 else:
102@@ -1044,10 +1065,15 @@
103 # Accounts
104 if data.get('destination_ids'): # "destinations_ids" corresponds to G/L accounts...
105 acc_list = []
106- for account in data.get('destination_ids').split(','):
107+ split_char = ';'
108+ if split_char not in data.get('destination_ids'):
109+ split_char = ','
110+ for account in data.get('destination_ids').split(split_char):
111 acc = account.strip()
112- acc_dom = [('type', '!=', 'view'), ('is_analytic_addicted', '=', True), ('code', '=', acc)]
113- acc_ids = acc_obj.search(cr, uid, acc_dom, order='id', limit=1, context=context)
114+ if acc not in gl_account_cache:
115+ acc_dom = [('type', '!=', 'view'), ('is_analytic_addicted', '=', True), ('code', '=', acc)]
116+ gl_account_cache[acc] = acc_obj.search(cr, uid, acc_dom, order='id', limit=1, context=context)
117+ acc_ids = gl_account_cache.get(acc)
118 if acc_ids:
119 acc_list.append(acc_ids[0])
120 else:
121@@ -1082,6 +1108,7 @@
122
123 # Cost Centers
124 if import_brw.model_list_selection == 'cost_centers':
125+ ids_to_update = acc_analytic_obj.search(cr, uid, [('code', '=ilike', data.get('code')), ('category', '=', 'OC')])
126 context['from_import_menu'] = True
127 data['category'] = 'OC'
128 # Parent Analytic Account
129
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 'funding_pools': {
135 'name': 'Funding Pools',
136 'domain_type': 'finance',
137- 'model': 'account.analytic.account'
138+ 'model': 'account.analytic.account',
139+ 'domain': [('category', '=', 'FUNDING'), ('parent_id', '!=', False)]
140 },
141 'destinations': {
142 'name': 'Destinations',
143 'domain_type': 'finance',
144- 'model': 'account.analytic.account'
145+ 'model': 'account.analytic.account',
146+ 'domain': [('category', '=', 'DEST'), ('parent_id', '!=', False)]
147 },
148 'cost_centers': {
149 'name': 'Cost Centers',
150 'domain_type': 'finance',
151- 'model': 'account.analytic.account'
152+ 'model': 'account.analytic.account',
153+ 'domain': [('category', '=', 'OC'), ('parent_id', '!=', False)]
154 },
155 'free1': {
156 'name': 'Free 1',
157 'domain_type': 'finance',
158- 'model': 'account.analytic.account'
159+ 'model': 'account.analytic.account',
160+ 'domain': [('category', '=', 'FREE1'), ('parent_id', '!=', False)]
161 },
162 'free2': {
163 'name': 'Free 2',
164 'domain_type': 'finance',
165- 'model': 'account.analytic.account'
166+ 'model': 'account.analytic.account',
167+ 'domain': [('category', '=', 'FREE2'), ('parent_id', '!=', False)]
168 },
169 'analytic_journals': {
170 'name': 'Analytic Journals',
171@@ -503,8 +508,8 @@
172 },
173 'funding_pools': {
174 'header_list': [
175+ 'code',
176 'name',
177- 'code',
178 'parent_id.code',
179 'type',
180 'date_start',
181@@ -522,8 +527,8 @@
182 },
183 'cost_centers': {
184 'header_list': [
185+ 'code',
186 'name',
187- 'code',
188 'parent_id.code',
189 'type',
190 'date_start',
191@@ -538,8 +543,8 @@
192 },
193 'destinations': {
194 'header_list': [
195+ 'code',
196 'name',
197- 'code',
198 'parent_id.code',
199 'type',
200 'date_start',
201
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 new_ctx = context.copy()
207 if 'lang' in MODEL_DICT.get(data['selection'], {}):
208 new_ctx['lang'] = MODEL_DICT[data['selection']]['lang']
209+ if data['selection'] == 'destinations':
210+ new_ctx['account_only_code'] = True
211 for i in range(0, len(ids), chunk_size):
212 ids_chunk = ids[i:i + chunk_size]
213 context['translate_selection_field'] = True

Subscribers

People subscribed via source and target branches