Merge lp:~fabien-morin/unifield-server/fm-us-1719 into lp:unifield-server
- fm-us-1719
- Merge into trunk
Proposed by
jftempo
Status: | Merged |
---|---|
Merged at revision: | 4220 |
Proposed branch: | lp:~fabien-morin/unifield-server/fm-us-1719 |
Merge into: | lp:unifield-server |
Diff against target: |
610 lines (+308/-129) 7 files modified
bin/addons/msf_profile/data/patches.xml (+4/-0) bin/addons/msf_profile/msf_profile.py (+78/-18) bin/addons/sync_client/ir_model_data.py (+5/-11) bin/addons/sync_client/orm.py (+4/-4) bin/addons/sync_client/sync_client.py (+77/-0) bin/addons/sync_common/common.py (+138/-94) bin/addons/sync_server/rules.py (+2/-2) |
To merge this branch: | bzr merge lp:~fabien-morin/unifield-server/fm-us-1719 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
UniField Reviewer Team | Pending | ||
Review via email: mp+317171@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/msf_profile/data/patches.xml' |
2 | --- bin/addons/msf_profile/data/patches.xml 2017-02-09 17:18:36 +0000 |
3 | +++ bin/addons/msf_profile/data/patches.xml 2017-02-16 09:58:42 +0000 |
4 | @@ -1,6 +1,10 @@ |
5 | <?xml version="1.0" encoding="utf-8" ?> |
6 | <openerp> |
7 | <data> |
8 | + <record id="remove_not_synchronized_data" model="patch.scripts"> |
9 | + <field name="method">remove_not_synchronized_data</field> |
10 | + </record> |
11 | + |
12 | <record id="us_2110_patch" model="patch.scripts"> |
13 | <field name="method">us_2110_patch</field> |
14 | </record> |
15 | |
16 | === modified file 'bin/addons/msf_profile/msf_profile.py' |
17 | --- bin/addons/msf_profile/msf_profile.py 2017-02-13 11:31:10 +0000 |
18 | +++ bin/addons/msf_profile/msf_profile.py 2017-02-16 09:58:42 +0000 |
19 | @@ -46,6 +46,50 @@ |
20 | 'model': lambda *a: 'patch.scripts', |
21 | } |
22 | |
23 | + def remove_not_synchronized_data(self, cr, uid, *a, **b): |
24 | + ''' |
25 | + The list of models to synchronize was wrong. It is now build |
26 | + automatically and is then more exact. |
27 | + This patch will remove all the data from ir_model_data that are not |
28 | + synchronized models. |
29 | + ''' |
30 | + from sync_common import WHITE_LIST_MODEL |
31 | + removed_obj = 0 |
32 | + |
33 | + # if sync_client module is installed, get the list of synchronized models |
34 | + if self.pool.get('sync.client.rule') and\ |
35 | + self.pool.get('sync.client.message_rule'): |
36 | + entity_obj = self.pool.get('sync.client.entity') |
37 | + server_model_white_set = entity_obj.get_model_white_list(cr, uid) |
38 | + |
39 | + # check that all models from the newly generated list are in the hardcoded white list |
40 | + difference = server_model_white_set.difference(WHITE_LIST_MODEL) |
41 | + if difference: |
42 | + err_msg = 'Warning: Some models used in the synchronization '\ |
43 | + 'rule are not present in the WHITE_LIST_MODEL: %s' |
44 | + self._logger.error(err_msg) |
45 | + raise osv.except_osv( |
46 | + 'Error', |
47 | + err_msg, |
48 | + ) |
49 | + elif server_model_white_set: |
50 | + # get list of all existing models used in ir_model_data |
51 | + cr.execute('SELECT DISTINCT(model) FROM ir_model_data') |
52 | + model_list = [x and x[0] for x in cr.fetchall()] |
53 | + model_to_remove = (set(model_list).difference(server_model_white_set)) |
54 | + import pprint |
55 | + pp = pprint.PrettyPrinter(indent=2) |
56 | + model_to_remove_pp = pp.pformat(model_to_remove) |
57 | + self._logger.warn('%s models should not be part of ir_model_data.' % len(model_to_remove)) |
58 | + self._logger.warn('The objects linked to the model(s) %s will be removed from ir_model_data.' % model_to_remove_pp) |
59 | + |
60 | + for model in model_to_remove: |
61 | + cr.execute("DELETE FROM ir_model_data WHERE model='%s' AND module='sd'" % model) |
62 | + current_count = cr.rowcount |
63 | + removed_obj += current_count |
64 | + self._logger.warn('ir.model.data, model=%s, %s objects deleted.' % (model, current_count)) |
65 | + self._logger.warn('ir.model.data, total of %s objects deleted.' % removed_obj) |
66 | + |
67 | def us_1613_remove_all_track_changes_action(self, cr, uid, *a, **b): |
68 | ''' |
69 | each time the msf_audittrail is updated, the subscribe() method is |
70 | @@ -126,25 +170,31 @@ |
71 | def setup_security_on_sync_server(self, cr, uid, *a, **b): |
72 | update_module = self.pool.get('sync.server.update') |
73 | if not update_module: |
74 | - # this script is exucuted on server side, update the first delete |
75 | + # this script is exucuted on server side only |
76 | return |
77 | |
78 | data_obj = self.pool.get('ir.model.data') |
79 | - group_id = data_obj.get_object_reference(cr, uid, 'base', |
80 | - 'group_erp_manager')[1] |
81 | - |
82 | - model_obj = self.pool.get('ir.model') |
83 | - model_list_not_to_change = ['res.users', 'res.lang', 'res.widget', |
84 | - 'res.widget.user', 'res.log', 'publisher_warranty.contract', |
85 | - 'module.module'] |
86 | - model_ids = model_obj.search(cr, uid, |
87 | - [('model', 'not like', "ir%"), |
88 | - ('model', 'not in', model_list_not_to_change)]) |
89 | - |
90 | - access_obj = self.pool.get('ir.model.access') |
91 | - no_group_access = access_obj.search(cr, uid, [('group_id', '=', False), |
92 | - ('model_id', 'in', model_ids)]) |
93 | - access_obj.write(cr, uid, no_group_access, {'group_id': group_id}) |
94 | + group_id = None |
95 | + try: |
96 | + group_id = data_obj.get_object_reference(cr, 1, 'base', |
97 | + 'group_erp_manager')[1] |
98 | + except ValueError: |
99 | + # If these groups does not exists anymore |
100 | + pass |
101 | + |
102 | + if group_id: |
103 | + model_obj = self.pool.get('ir.model') |
104 | + model_list_not_to_change = ['res.users', 'res.lang', 'res.widget', |
105 | + 'res.widget.user', 'res.log', 'publisher_warranty.contract', |
106 | + 'module.module'] |
107 | + model_ids = model_obj.search(cr, uid, |
108 | + [('model', 'not like', "ir%"), |
109 | + ('model', 'not in', model_list_not_to_change)]) |
110 | + |
111 | + access_obj = self.pool.get('ir.model.access') |
112 | + no_group_access = access_obj.search(cr, uid, [('group_id', '=', False), |
113 | + ('model_id', 'in', model_ids)]) |
114 | + access_obj.write(cr, uid, no_group_access, {'group_id': group_id}) |
115 | |
116 | def us_1482_fix_default_code_on_msf_lines(self, cr, uid, *a, **b): |
117 | """ |
118 | @@ -185,6 +235,8 @@ |
119 | {'password': encrypted_password}) |
120 | |
121 | def us_1610_set_oc_on_all_groups(self, cr, uid, *a, **b): |
122 | + from sync_common import OC_LIST |
123 | + lower_oc_list = [x.lower() for x in OC_LIST] |
124 | logger = logging.getLogger('update') |
125 | update_module = self.pool.get('sync.server.entity_group') |
126 | if update_module: |
127 | @@ -196,7 +248,11 @@ |
128 | if 'oc' in group_name: |
129 | index = group_name.index('oc') |
130 | oc = group_name[index:index+3] |
131 | - update_module.write(cr, uid, group['id'], {'oc': oc}) |
132 | + if oc in lower_oc_list: |
133 | + update_module.write(cr, uid, group['id'], {'oc': oc}) |
134 | + else: |
135 | + logger.warn("""OC = %s from group '%s' is not in the OC_LIST, please fix |
136 | + mannualy""" % (oc, group['name'])) |
137 | else: |
138 | logger.warn('sync.server.entity_group "%s" does not contain '\ |
139 | '"oc" or "OC" in its name. Please set up the '\ |
140 | @@ -213,7 +269,11 @@ |
141 | if 'oc' in entity_name: |
142 | index = entity_name.index('oc') |
143 | oc = entity_name[index:index+3] |
144 | - sync_client_module.write(cr, uid, entity['id'], {'oc': oc}) |
145 | + if oc in lower_oc_list: |
146 | + sync_client_module.write(cr, uid, entity['id'], {'oc': oc}) |
147 | + else: |
148 | + logger.warn("""OC = %s from group '%s' is not in the OC_LIST, please fix |
149 | + mannualy""" % (oc, group['name'])) |
150 | else: |
151 | logger.warn('sync.client.entity "%s" does not contain '\ |
152 | '"oc" or "OC" in its name. Please set up the '\ |
153 | |
154 | === modified file 'bin/addons/sync_client/ir_model_data.py' |
155 | --- bin/addons/sync_client/ir_model_data.py 2016-11-09 09:40:24 +0000 |
156 | +++ bin/addons/sync_client/ir_model_data.py 2017-02-16 09:58:42 +0000 |
157 | @@ -24,7 +24,7 @@ |
158 | from osv import osv, fields |
159 | import tools |
160 | |
161 | -from sync_common import MODELS_TO_IGNORE, MODELS_TO_IGNORE_DOMAIN, normalize_sdref |
162 | +from sync_common import WHITE_LIST_MODEL, normalize_sdref |
163 | |
164 | |
165 | class ir_module_module(osv.osv): |
166 | @@ -98,16 +98,10 @@ |
167 | """ |
168 | # loop on objects that don't match the models to ignore domain in sync common |
169 | result = set() |
170 | - ir_model = self.pool.get('ir.model') |
171 | - model_ids = ir_model.search(cr, 1, MODELS_TO_IGNORE_DOMAIN) |
172 | - |
173 | - for model in filter(lambda m:m.model not in MODELS_TO_IGNORE, |
174 | - ir_model.browse(cr, 1, model_ids)): |
175 | - |
176 | - obj = self.pool.get(model.model) |
177 | - |
178 | + for model in WHITE_LIST_MODEL: |
179 | + obj = self.pool.get(model) |
180 | if obj is None: |
181 | - self._logger.warn('Could not get object %s while creating all missing sdrefs' % model.model) |
182 | + self._logger.warn('Could not get object %s while creating all missing sdrefs' % model) |
183 | continue |
184 | |
185 | # ignore wizard objects |
186 | @@ -251,7 +245,7 @@ |
187 | |
188 | # when a module load a specific xmlid, the sdref is updated according |
189 | # that xmlid |
190 | - if values['model'] not in MODELS_TO_IGNORE and \ |
191 | + if values['model'] in WHITE_LIST_MODEL and \ |
192 | values['module'] not in ('sd', '__export__') and \ |
193 | not (values['module'] == 'base' and values['name'].startswith('main_')): |
194 | sdref_name = "%(module)s_%(name)s" % values |
195 | |
196 | === modified file 'bin/addons/sync_client/orm.py' |
197 | --- bin/addons/sync_client/orm.py 2016-08-23 12:54:03 +0000 |
198 | +++ bin/addons/sync_client/orm.py 2017-02-16 09:58:42 +0000 |
199 | @@ -8,7 +8,7 @@ |
200 | import types |
201 | from datetime import date, datetime |
202 | |
203 | -from sync_common import MODELS_TO_IGNORE, xmlid_to_sdref |
204 | +from sync_common import WHITE_LIST_MODEL, xmlid_to_sdref |
205 | |
206 | #import cProfile |
207 | ## Helpers ################################################################### |
208 | @@ -489,7 +489,7 @@ |
209 | funct_field = audit_obj.get_functionnal_fields(cr, 1, self._name, audit_rule_ids) |
210 | |
211 | to_be_synchronized = ( |
212 | - self._name not in MODELS_TO_IGNORE and |
213 | + self._name in WHITE_LIST_MODEL and |
214 | (not context.get('sync_update_execution') and |
215 | not context.get('sync_update_creation'))) |
216 | |
217 | @@ -528,7 +528,7 @@ |
218 | funct_field = audit_obj.get_functionnal_fields(cr, 1, self._name, audit_rule_ids) |
219 | |
220 | to_be_synchronized = ( |
221 | - self._name not in MODELS_TO_IGNORE and |
222 | + self._name in WHITE_LIST_MODEL and |
223 | (not context.get('sync_update_execution') and |
224 | not context.get('sync_update_creation'))) |
225 | |
226 | @@ -617,7 +617,7 @@ |
227 | # synchronization is made. |
228 | # Otherwise, references are kept and synchronization is triggered |
229 | # ...see? |
230 | - if self._name not in MODELS_TO_IGNORE \ |
231 | + if self._name in WHITE_LIST_MODEL \ |
232 | and not context.get('sync_update_creation'): |
233 | context = dict(context, avoid_sdref_deletion=True) |
234 | if not context.get('sync_update_execution'): |
235 | |
236 | === modified file 'bin/addons/sync_client/sync_client.py' |
237 | --- bin/addons/sync_client/sync_client.py 2016-11-18 13:31:06 +0000 |
238 | +++ bin/addons/sync_client/sync_client.py 2017-02-16 09:58:42 +0000 |
239 | @@ -42,6 +42,7 @@ |
240 | |
241 | import functools |
242 | |
243 | +from sync_common import WHITE_LIST_MODEL |
244 | from datetime import datetime, timedelta |
245 | |
246 | from sync_common import OC_LIST_TUPLE |
247 | @@ -205,6 +206,17 @@ |
248 | self.pool.get('sync.monitor').get_logger(cr, uid, defaults_logger, context=context) |
249 | context['log_sale_purchase'] = True |
250 | |
251 | + # generate a white list of models |
252 | + if self.pool.get('sync.client.rule') and\ |
253 | + self.pool.get('sync.client.message_rule'): |
254 | + server_model_white_set = self.get_model_white_list(cr, uid) |
255 | + # check all models are in the hardcoded white list |
256 | + difference = server_model_white_set.difference(WHITE_LIST_MODEL) |
257 | + if difference: |
258 | + msg = 'Warning: Some models used in the synchronization '\ |
259 | + 'rule are not present in the WHITE_LIST_MODEL: %s' |
260 | + logger.append(_(msg) % ' ,'.join(list(difference))) |
261 | + |
262 | # create a specific cursor for the call |
263 | self.sync_cursor = pooler.get_db(cr.dbname).cursor() |
264 | |
265 | @@ -497,6 +509,71 @@ |
266 | finally: |
267 | self.renew_lock.release() |
268 | |
269 | + def get_model_white_list(self, cr, uid): |
270 | + ''' |
271 | + return a set of all models involved in the synchronization process |
272 | + ''' |
273 | + model_field_dict = {} |
274 | + |
275 | + # search for model of sync_server.sync_rule |
276 | + if self.pool.get('sync_server.sync_rule'): |
277 | + rule_module = self.pool.get('sync_server.sync_rule') |
278 | + model_field_name = 'model_id' |
279 | + else: |
280 | + rule_module = self.pool.get('sync.client.rule') |
281 | + model_field_name = 'model' |
282 | + obj_ids = rule_module.search(cr, uid, [('active', '=', True)]) |
283 | + for obj in rule_module.read(cr, uid, obj_ids, [model_field_name, 'included_fields']): |
284 | + if obj[model_field_name] not in model_field_dict: |
285 | + model_field_dict[obj[model_field_name]] = set() |
286 | + model_field_dict[obj[model_field_name]].update(eval(obj['included_fields'])) |
287 | + |
288 | + # search for model of sync_server.message_rule |
289 | + if self.pool.get('sync_server.message_rule'): |
290 | + rule_module = self.pool.get('sync_server.message_rule') |
291 | + model_field_name = 'model_id' |
292 | + else: |
293 | + rule_module = self.pool.get('sync.client.message_rule') |
294 | + model_field_name = 'model' |
295 | + obj_ids = rule_module.search(cr, uid, [('active', '=', True)]) |
296 | + for obj in rule_module.read(cr, uid, obj_ids, [model_field_name, 'arguments']): |
297 | + if obj[model_field_name] not in model_field_dict: |
298 | + model_field_dict[obj[model_field_name]] = set() |
299 | + model_field_dict[obj[model_field_name]].update(eval(obj['arguments'])) |
300 | + |
301 | + model_set = set(model_field_dict.keys()) |
302 | + |
303 | + def get_field_obj(model, field_name): |
304 | + model_obj = self.pool.get(model) |
305 | + field_obj = None |
306 | + if field_name in model_obj._columns: |
307 | + field_obj = model_obj._columns[field_name] |
308 | + elif field_name in model_obj._inherit_fields: |
309 | + field_obj = model_obj._inherit_fields[field_name][2] |
310 | + return field_obj |
311 | + |
312 | + |
313 | + # for each field corresponding to each model, check if it is a m2m m2o or o2m |
314 | + # if yes, add the model of the relation to the model set |
315 | + |
316 | + for model, field_list in model_field_dict.items(): |
317 | + field_list_to_parse = [x for x in field_list if '/id' in x] |
318 | + if not field_list_to_parse: |
319 | + continue |
320 | + |
321 | + for field in field_list_to_parse: |
322 | + field = field.replace('/id', '') |
323 | + if len(field.split('/')) == 2: |
324 | + related_field, field = field.split('/') |
325 | + field_obj = get_field_obj(model, related_field) |
326 | + related_model = field_obj._obj |
327 | + field_obj = get_field_obj(related_model, field) |
328 | + else: |
329 | + field_obj = get_field_obj(model, field) |
330 | + if field_obj._type in ('many2one', 'many2many', 'one2many'): |
331 | + model_set.add(field_obj._obj) |
332 | + return model_set |
333 | + |
334 | @sync_process('data_push') |
335 | def push_update(self, cr, uid, context=None): |
336 | """ |
337 | |
338 | === modified file 'bin/addons/sync_common/common.py' |
339 | --- bin/addons/sync_common/common.py 2016-11-18 13:31:06 +0000 |
340 | +++ bin/addons/sync_common/common.py 2017-02-16 09:58:42 +0000 |
341 | @@ -8,101 +8,147 @@ |
342 | import tools |
343 | from tools.translate import _ |
344 | |
345 | +# model related to synchronization, this model don't have to be ignored. |
346 | +# list build by getting models of update rules and message rules |
347 | +WHITE_LIST_MODEL = [ |
348 | + 'account.account', |
349 | + 'account.account.type', |
350 | + 'account.analytic.account', |
351 | + 'account.analytic.journal', |
352 | + 'account.analytic.line', |
353 | + 'account.bank.statement', |
354 | + 'account.bank.statement.line', |
355 | + 'account.bank.statement.line.deleted', |
356 | + 'account.cashbox.line', |
357 | + 'account.destination.link', |
358 | + 'account.fiscal.position', |
359 | + 'account.fiscalyear', |
360 | + 'account.fiscalyear.state', |
361 | + 'account.invoice', |
362 | + 'account.journal', |
363 | + 'account.move', |
364 | + 'account.move.line', |
365 | + 'account.move.reconcile', |
366 | + 'account.payment.term', |
367 | + 'account.period', |
368 | + 'account.period.state', |
369 | + 'account.target.costcenter', |
370 | + 'account.tax', |
371 | + 'account.tax.code', |
372 | + 'analytic.distribution', |
373 | + 'claim.event', |
374 | + 'claim.product.line', |
375 | + 'composition.item', |
376 | + 'composition.kit', |
377 | + 'cost.center.distribution.line', |
378 | + 'country.export.mapping', |
379 | + 'distribution.line', |
380 | + 'financing.contract.contract', |
381 | + 'financing.contract.donor', |
382 | + 'financing.contract.format', |
383 | + 'financing.contract.format.line', |
384 | + 'financing.contract.funding.pool.line', |
385 | + 'free.1.distribution.line', |
386 | + 'free.2.distribution.line', |
387 | + 'funding.pool.distribution.line', |
388 | + 'hq.entries', |
389 | + 'hr.employee', |
390 | + 'hr.employee.marital.status', |
391 | + 'hr.job', |
392 | + 'initial.stock.inventory', |
393 | + 'initial.stock.inventory.line', |
394 | + 'ir.actions.act_window', |
395 | + 'ir.filters', |
396 | + 'ir.model', |
397 | + 'ir.model.access', |
398 | + 'ir.model.fields', |
399 | + 'ir.rule', |
400 | + 'ir.sequence', |
401 | + 'ir.translation', |
402 | + 'ir.ui.menu', |
403 | + 'ir.ui.view', |
404 | + 'kit.creation', |
405 | + 'kit.creation.to.consume', |
406 | + 'monthly.review.consumption', |
407 | + 'monthly.review.consumption.line', |
408 | + 'msf.budget', |
409 | + 'msf.budget.decision.moment', |
410 | + 'msf.budget.line', |
411 | + 'msf.instance', |
412 | + 'msf_button_access_rights.button_access_rule', |
413 | + 'msf_field_access_rights.field_access_rule', |
414 | + 'msf_field_access_rights.field_access_rule_line', |
415 | + 'pack.type', |
416 | + 'procurement.order', |
417 | + 'product.asset', |
418 | + 'product.asset.type', |
419 | + 'product.category', |
420 | + 'product.cold_chain', |
421 | + 'product.heat_sensitive', |
422 | + 'product.international.status', |
423 | + 'product.justification.code', |
424 | + 'product.list', |
425 | + 'product.list.line', |
426 | + 'product.nomenclature', |
427 | + 'product.pricelist', |
428 | + 'product.pricelist.type', |
429 | + 'product.pricelist.version', |
430 | + 'product.product', |
431 | + 'product.uom', |
432 | + 'product.uom.categ', |
433 | + 'purchase.order', |
434 | + 'purchase.order.line', |
435 | + 'real.average.consumption', |
436 | + 'real.average.consumption.line', |
437 | + 'res.company', |
438 | + 'res.country', |
439 | + 'res.country.restriction', |
440 | + 'res.country.state', |
441 | + 'res.currency', |
442 | + 'res.currency.rate', |
443 | + 'res.currency.table', |
444 | + 'res.groups', |
445 | + 'res.partner', |
446 | + 'res.partner.address', |
447 | + 'res.partner.title', |
448 | + 'res.users', |
449 | + 'return.claim', |
450 | + 'sale.order', |
451 | + 'sale.order.line', |
452 | + 'sale.order.line.cancel', |
453 | + 'shipment', |
454 | + 'stock.frequence', |
455 | + 'stock.inventory', |
456 | + 'stock.inventory.line', |
457 | + 'stock.journal', |
458 | + 'stock.location', |
459 | + 'stock.location.chained.options', |
460 | + 'stock.mission.report', |
461 | + 'stock.mission.report.line', |
462 | + 'stock.move', |
463 | + 'stock.picking', |
464 | + 'stock.production.lot', |
465 | + 'stock.reason.type', |
466 | + 'stock.warehouse', |
467 | + 'stock.warehouse.automatic.supply', |
468 | + 'stock.warehouse.automatic.supply.line', |
469 | + 'stock.warehouse.order.cycle', |
470 | + 'stock.warehouse.order.cycle.line', |
471 | + 'stock.warehouse.orderpoint', |
472 | + 'supplier.catalogue', |
473 | + 'supplier.catalogue.line', |
474 | + 'sync.monitor', |
475 | + 'sync.sale.order.line.split', |
476 | + 'sync.version.instance.monitor', |
477 | + 'tender', |
478 | + 'tender.line', |
479 | + 'threshold.value', |
480 | + 'threshold.value.line', |
481 | +] |
482 | + |
483 | OC_LIST = ['OCA', 'OCB', 'OCBA', 'OCG', 'OCP'] |
484 | OC_LIST_TUPLE = zip([x.lower() for x in OC_LIST], OC_LIST) |
485 | |
486 | -MODELS_TO_IGNORE = [ |
487 | - 'ir.actions.wizard', |
488 | - 'ir.actions.act_window.view', |
489 | - 'ir.report.custom', |
490 | - 'ir.actions.act_window.view', |
491 | - 'ir.actions.wizard', |
492 | - 'ir.report.custom', |
493 | - 'ir.ui.view', |
494 | - 'ir.sequence', |
495 | - 'ir.actions.url', |
496 | - 'ir.values', |
497 | - 'ir.report.custom.fields', |
498 | - 'ir.cron', |
499 | - 'ir.actions.report.xml', |
500 | - 'ir.property', |
501 | - 'ir.actions.todo', |
502 | - 'ir.sequence.type', |
503 | - #'ir.actions.act_window', |
504 | - 'ir.module.module', |
505 | - 'ir.ui.view', |
506 | - 'ir.module.repository', |
507 | - 'ir.model.data', |
508 | - 'ir.model.fields', |
509 | - 'ir.ui.view_sc', |
510 | - 'ir.config_parameter', |
511 | - |
512 | - #'sync.monitor', |
513 | - 'sync.client.rule', |
514 | - 'sync.client.push.data.information', |
515 | - 'sync.client.update_to_send', |
516 | - 'sync.client.update_received', |
517 | - 'sync.client.entity', |
518 | - 'sync.client.sync_server_connection', |
519 | - 'sync.client.message_rule', |
520 | - 'sync.client.message_to_send', |
521 | - 'sync.client.message_received', |
522 | - 'sync.client.message_sync', |
523 | - 'sync.client.orm_extended', |
524 | - |
525 | - 'sync.server.test', |
526 | - 'sync_server.version.manager', |
527 | - 'sync.server.entity_group', |
528 | - 'sync.server.entity', |
529 | - 'sync.server.group_type', |
530 | - 'sync.server.entity_group', |
531 | - 'sync.server.entity', |
532 | - 'sync.server.sync_manager', |
533 | - 'sync_server.sync_rule', |
534 | - 'sync_server.message_rule', |
535 | - 'sync_server.sync_rule.forced_values', |
536 | - 'sync_server.sync_rule.fallback_values', |
537 | - 'sync_server.rule.validation.message', |
538 | - 'sync.server.update', |
539 | - 'sync.server.message', |
540 | - 'sync_server.version', |
541 | - 'sync.server.puller_logs', |
542 | - 'audittrail.log.sequence', |
543 | - 'audittrail.log.line', |
544 | - |
545 | - 'res.widget', |
546 | - 'product.likely.expire.report', |
547 | - 'product.likely.expire.report.line', |
548 | - 'operations.event', |
549 | -] |
550 | - |
551 | -MODELS_TO_IGNORE_DOMAIN = [ |
552 | - 'sync_client.%', |
553 | - 'sync_server.%', |
554 | - 'res.widget%', |
555 | - 'base%', |
556 | - 'board%', |
557 | - 'audittrail%', |
558 | - 'workflow%', |
559 | -] |
560 | - |
561 | -def __compile_models_to_ignore(): |
562 | - global MODELS_TO_IGNORE_DOMAIN |
563 | - simple_patterns = [] |
564 | - exact_models = [] |
565 | - for model in MODELS_TO_IGNORE_DOMAIN: |
566 | - if model.find('%') >= 0: |
567 | - simple_patterns.append(model) |
568 | - else: |
569 | - exact_models.append(model) |
570 | - MODELS_TO_IGNORE_DOMAIN[:] = [('model','not in',exact_models)] |
571 | - for pattern in simple_patterns: |
572 | - MODELS_TO_IGNORE_DOMAIN.extend(['!',('model','=like',pattern)]) |
573 | - |
574 | -__compile_models_to_ignore() |
575 | - |
576 | - |
577 | - |
578 | def xmlid_to_sdref(xmlid): |
579 | if not xmlid: return None |
580 | head, sep, tail = xmlid.partition('.') |
581 | @@ -112,8 +158,6 @@ |
582 | else: |
583 | return head |
584 | |
585 | - |
586 | - |
587 | # TODO deprecated, should disappear |
588 | def sync_log(obj, message=None, level='debug', ids=None, data=None, tb=False): |
589 | if not hasattr(obj, '_logger'): |
590 | |
591 | === modified file 'bin/addons/sync_server/rules.py' |
592 | --- bin/addons/sync_server/rules.py 2016-11-18 11:26:45 +0000 |
593 | +++ bin/addons/sync_server/rules.py 2017-02-16 09:58:42 +0000 |
594 | @@ -27,7 +27,7 @@ |
595 | from datetime import datetime |
596 | |
597 | import logging |
598 | -from sync_common import MODELS_TO_IGNORE_DOMAIN, sync_log |
599 | +from sync_common import sync_log |
600 | |
601 | _field2type = { |
602 | 'text' : 'str', |
603 | @@ -829,7 +829,7 @@ |
604 | |
605 | def _get_fallback_value(self, cr, uid, context=None): |
606 | model = self.pool.get('ir.model') |
607 | - ids = model.search(cr, uid, MODELS_TO_IGNORE_DOMAIN) |
608 | + ids = model.search(cr, uid, ('model', 'not in', WHITE_LIST_MODEL)) |
609 | res = model.read(cr, uid, ids, ['model'], context) |
610 | return [(r['model'], r['model']) for r in res] |
611 |