Merge lp:~fabien-morin/unifield-server/fm-us-1719 into lp:unifield-server

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
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+317171@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/msf_profile/data/patches.xml'
--- bin/addons/msf_profile/data/patches.xml 2017-02-09 17:18:36 +0000
+++ bin/addons/msf_profile/data/patches.xml 2017-02-16 09:58:42 +0000
@@ -1,6 +1,10 @@
1<?xml version="1.0" encoding="utf-8" ?>1<?xml version="1.0" encoding="utf-8" ?>
2<openerp>2<openerp>
3 <data>3 <data>
4 <record id="remove_not_synchronized_data" model="patch.scripts">
5 <field name="method">remove_not_synchronized_data</field>
6 </record>
7
4 <record id="us_2110_patch" model="patch.scripts">8 <record id="us_2110_patch" model="patch.scripts">
5 <field name="method">us_2110_patch</field>9 <field name="method">us_2110_patch</field>
6 </record>10 </record>
711
=== modified file 'bin/addons/msf_profile/msf_profile.py'
--- bin/addons/msf_profile/msf_profile.py 2017-02-13 11:31:10 +0000
+++ bin/addons/msf_profile/msf_profile.py 2017-02-16 09:58:42 +0000
@@ -46,6 +46,50 @@
46 'model': lambda *a: 'patch.scripts',46 'model': lambda *a: 'patch.scripts',
47 }47 }
4848
49 def remove_not_synchronized_data(self, cr, uid, *a, **b):
50 '''
51 The list of models to synchronize was wrong. It is now build
52 automatically and is then more exact.
53 This patch will remove all the data from ir_model_data that are not
54 synchronized models.
55 '''
56 from sync_common import WHITE_LIST_MODEL
57 removed_obj = 0
58
59 # if sync_client module is installed, get the list of synchronized models
60 if self.pool.get('sync.client.rule') and\
61 self.pool.get('sync.client.message_rule'):
62 entity_obj = self.pool.get('sync.client.entity')
63 server_model_white_set = entity_obj.get_model_white_list(cr, uid)
64
65 # check that all models from the newly generated list are in the hardcoded white list
66 difference = server_model_white_set.difference(WHITE_LIST_MODEL)
67 if difference:
68 err_msg = 'Warning: Some models used in the synchronization '\
69 'rule are not present in the WHITE_LIST_MODEL: %s'
70 self._logger.error(err_msg)
71 raise osv.except_osv(
72 'Error',
73 err_msg,
74 )
75 elif server_model_white_set:
76 # get list of all existing models used in ir_model_data
77 cr.execute('SELECT DISTINCT(model) FROM ir_model_data')
78 model_list = [x and x[0] for x in cr.fetchall()]
79 model_to_remove = (set(model_list).difference(server_model_white_set))
80 import pprint
81 pp = pprint.PrettyPrinter(indent=2)
82 model_to_remove_pp = pp.pformat(model_to_remove)
83 self._logger.warn('%s models should not be part of ir_model_data.' % len(model_to_remove))
84 self._logger.warn('The objects linked to the model(s) %s will be removed from ir_model_data.' % model_to_remove_pp)
85
86 for model in model_to_remove:
87 cr.execute("DELETE FROM ir_model_data WHERE model='%s' AND module='sd'" % model)
88 current_count = cr.rowcount
89 removed_obj += current_count
90 self._logger.warn('ir.model.data, model=%s, %s objects deleted.' % (model, current_count))
91 self._logger.warn('ir.model.data, total of %s objects deleted.' % removed_obj)
92
49 def us_1613_remove_all_track_changes_action(self, cr, uid, *a, **b):93 def us_1613_remove_all_track_changes_action(self, cr, uid, *a, **b):
50 '''94 '''
51 each time the msf_audittrail is updated, the subscribe() method is95 each time the msf_audittrail is updated, the subscribe() method is
@@ -126,25 +170,31 @@
126 def setup_security_on_sync_server(self, cr, uid, *a, **b):170 def setup_security_on_sync_server(self, cr, uid, *a, **b):
127 update_module = self.pool.get('sync.server.update')171 update_module = self.pool.get('sync.server.update')
128 if not update_module:172 if not update_module:
129 # this script is exucuted on server side, update the first delete173 # this script is exucuted on server side only
130 return174 return
131175
132 data_obj = self.pool.get('ir.model.data')176 data_obj = self.pool.get('ir.model.data')
133 group_id = data_obj.get_object_reference(cr, uid, 'base',177 group_id = None
134 'group_erp_manager')[1]178 try:
135179 group_id = data_obj.get_object_reference(cr, 1, 'base',
136 model_obj = self.pool.get('ir.model')180 'group_erp_manager')[1]
137 model_list_not_to_change = ['res.users', 'res.lang', 'res.widget',181 except ValueError:
138 'res.widget.user', 'res.log', 'publisher_warranty.contract',182 # If these groups does not exists anymore
139 'module.module']183 pass
140 model_ids = model_obj.search(cr, uid,184
141 [('model', 'not like', "ir%"),185 if group_id:
142 ('model', 'not in', model_list_not_to_change)])186 model_obj = self.pool.get('ir.model')
143187 model_list_not_to_change = ['res.users', 'res.lang', 'res.widget',
144 access_obj = self.pool.get('ir.model.access')188 'res.widget.user', 'res.log', 'publisher_warranty.contract',
145 no_group_access = access_obj.search(cr, uid, [('group_id', '=', False),189 'module.module']
146 ('model_id', 'in', model_ids)])190 model_ids = model_obj.search(cr, uid,
147 access_obj.write(cr, uid, no_group_access, {'group_id': group_id})191 [('model', 'not like', "ir%"),
192 ('model', 'not in', model_list_not_to_change)])
193
194 access_obj = self.pool.get('ir.model.access')
195 no_group_access = access_obj.search(cr, uid, [('group_id', '=', False),
196 ('model_id', 'in', model_ids)])
197 access_obj.write(cr, uid, no_group_access, {'group_id': group_id})
148198
149 def us_1482_fix_default_code_on_msf_lines(self, cr, uid, *a, **b):199 def us_1482_fix_default_code_on_msf_lines(self, cr, uid, *a, **b):
150 """200 """
@@ -185,6 +235,8 @@
185 {'password': encrypted_password})235 {'password': encrypted_password})
186236
187 def us_1610_set_oc_on_all_groups(self, cr, uid, *a, **b):237 def us_1610_set_oc_on_all_groups(self, cr, uid, *a, **b):
238 from sync_common import OC_LIST
239 lower_oc_list = [x.lower() for x in OC_LIST]
188 logger = logging.getLogger('update')240 logger = logging.getLogger('update')
189 update_module = self.pool.get('sync.server.entity_group')241 update_module = self.pool.get('sync.server.entity_group')
190 if update_module:242 if update_module:
@@ -196,7 +248,11 @@
196 if 'oc' in group_name:248 if 'oc' in group_name:
197 index = group_name.index('oc')249 index = group_name.index('oc')
198 oc = group_name[index:index+3]250 oc = group_name[index:index+3]
199 update_module.write(cr, uid, group['id'], {'oc': oc})251 if oc in lower_oc_list:
252 update_module.write(cr, uid, group['id'], {'oc': oc})
253 else:
254 logger.warn("""OC = %s from group '%s' is not in the OC_LIST, please fix
255 mannualy""" % (oc, group['name']))
200 else:256 else:
201 logger.warn('sync.server.entity_group "%s" does not contain '\257 logger.warn('sync.server.entity_group "%s" does not contain '\
202 '"oc" or "OC" in its name. Please set up the '\258 '"oc" or "OC" in its name. Please set up the '\
@@ -213,7 +269,11 @@
213 if 'oc' in entity_name:269 if 'oc' in entity_name:
214 index = entity_name.index('oc')270 index = entity_name.index('oc')
215 oc = entity_name[index:index+3]271 oc = entity_name[index:index+3]
216 sync_client_module.write(cr, uid, entity['id'], {'oc': oc})272 if oc in lower_oc_list:
273 sync_client_module.write(cr, uid, entity['id'], {'oc': oc})
274 else:
275 logger.warn("""OC = %s from group '%s' is not in the OC_LIST, please fix
276 mannualy""" % (oc, group['name']))
217 else:277 else:
218 logger.warn('sync.client.entity "%s" does not contain '\278 logger.warn('sync.client.entity "%s" does not contain '\
219 '"oc" or "OC" in its name. Please set up the '\279 '"oc" or "OC" in its name. Please set up the '\
220280
=== modified file 'bin/addons/sync_client/ir_model_data.py'
--- bin/addons/sync_client/ir_model_data.py 2016-11-09 09:40:24 +0000
+++ bin/addons/sync_client/ir_model_data.py 2017-02-16 09:58:42 +0000
@@ -24,7 +24,7 @@
24from osv import osv, fields24from osv import osv, fields
25import tools25import tools
2626
27from sync_common import MODELS_TO_IGNORE, MODELS_TO_IGNORE_DOMAIN, normalize_sdref27from sync_common import WHITE_LIST_MODEL, normalize_sdref
2828
2929
30class ir_module_module(osv.osv):30class ir_module_module(osv.osv):
@@ -98,16 +98,10 @@
98 """98 """
99 # loop on objects that don't match the models to ignore domain in sync common99 # loop on objects that don't match the models to ignore domain in sync common
100 result = set()100 result = set()
101 ir_model = self.pool.get('ir.model')101 for model in WHITE_LIST_MODEL:
102 model_ids = ir_model.search(cr, 1, MODELS_TO_IGNORE_DOMAIN)102 obj = self.pool.get(model)
103
104 for model in filter(lambda m:m.model not in MODELS_TO_IGNORE,
105 ir_model.browse(cr, 1, model_ids)):
106
107 obj = self.pool.get(model.model)
108
109 if obj is None:103 if obj is None:
110 self._logger.warn('Could not get object %s while creating all missing sdrefs' % model.model)104 self._logger.warn('Could not get object %s while creating all missing sdrefs' % model)
111 continue105 continue
112106
113 # ignore wizard objects107 # ignore wizard objects
@@ -251,7 +245,7 @@
251245
252 # when a module load a specific xmlid, the sdref is updated according246 # when a module load a specific xmlid, the sdref is updated according
253 # that xmlid247 # that xmlid
254 if values['model'] not in MODELS_TO_IGNORE and \248 if values['model'] in WHITE_LIST_MODEL and \
255 values['module'] not in ('sd', '__export__') and \249 values['module'] not in ('sd', '__export__') and \
256 not (values['module'] == 'base' and values['name'].startswith('main_')):250 not (values['module'] == 'base' and values['name'].startswith('main_')):
257 sdref_name = "%(module)s_%(name)s" % values251 sdref_name = "%(module)s_%(name)s" % values
258252
=== modified file 'bin/addons/sync_client/orm.py'
--- bin/addons/sync_client/orm.py 2016-08-23 12:54:03 +0000
+++ bin/addons/sync_client/orm.py 2017-02-16 09:58:42 +0000
@@ -8,7 +8,7 @@
8import types8import types
9from datetime import date, datetime9from datetime import date, datetime
1010
11from sync_common import MODELS_TO_IGNORE, xmlid_to_sdref11from sync_common import WHITE_LIST_MODEL, xmlid_to_sdref
1212
13#import cProfile13#import cProfile
14## Helpers ###################################################################14## Helpers ###################################################################
@@ -489,7 +489,7 @@
489 funct_field = audit_obj.get_functionnal_fields(cr, 1, self._name, audit_rule_ids)489 funct_field = audit_obj.get_functionnal_fields(cr, 1, self._name, audit_rule_ids)
490490
491 to_be_synchronized = (491 to_be_synchronized = (
492 self._name not in MODELS_TO_IGNORE and492 self._name in WHITE_LIST_MODEL and
493 (not context.get('sync_update_execution') and493 (not context.get('sync_update_execution') and
494 not context.get('sync_update_creation')))494 not context.get('sync_update_creation')))
495495
@@ -528,7 +528,7 @@
528 funct_field = audit_obj.get_functionnal_fields(cr, 1, self._name, audit_rule_ids)528 funct_field = audit_obj.get_functionnal_fields(cr, 1, self._name, audit_rule_ids)
529529
530 to_be_synchronized = (530 to_be_synchronized = (
531 self._name not in MODELS_TO_IGNORE and531 self._name in WHITE_LIST_MODEL and
532 (not context.get('sync_update_execution') and532 (not context.get('sync_update_execution') and
533 not context.get('sync_update_creation')))533 not context.get('sync_update_creation')))
534534
@@ -617,7 +617,7 @@
617 # synchronization is made.617 # synchronization is made.
618 # Otherwise, references are kept and synchronization is triggered618 # Otherwise, references are kept and synchronization is triggered
619 # ...see?619 # ...see?
620 if self._name not in MODELS_TO_IGNORE \620 if self._name in WHITE_LIST_MODEL \
621 and not context.get('sync_update_creation'):621 and not context.get('sync_update_creation'):
622 context = dict(context, avoid_sdref_deletion=True)622 context = dict(context, avoid_sdref_deletion=True)
623 if not context.get('sync_update_execution'):623 if not context.get('sync_update_execution'):
624624
=== modified file 'bin/addons/sync_client/sync_client.py'
--- bin/addons/sync_client/sync_client.py 2016-11-18 13:31:06 +0000
+++ bin/addons/sync_client/sync_client.py 2017-02-16 09:58:42 +0000
@@ -42,6 +42,7 @@
4242
43import functools43import functools
4444
45from sync_common import WHITE_LIST_MODEL
45from datetime import datetime, timedelta46from datetime import datetime, timedelta
4647
47from sync_common import OC_LIST_TUPLE48from sync_common import OC_LIST_TUPLE
@@ -205,6 +206,17 @@
205 self.pool.get('sync.monitor').get_logger(cr, uid, defaults_logger, context=context)206 self.pool.get('sync.monitor').get_logger(cr, uid, defaults_logger, context=context)
206 context['log_sale_purchase'] = True207 context['log_sale_purchase'] = True
207208
209 # generate a white list of models
210 if self.pool.get('sync.client.rule') and\
211 self.pool.get('sync.client.message_rule'):
212 server_model_white_set = self.get_model_white_list(cr, uid)
213 # check all models are in the hardcoded white list
214 difference = server_model_white_set.difference(WHITE_LIST_MODEL)
215 if difference:
216 msg = 'Warning: Some models used in the synchronization '\
217 'rule are not present in the WHITE_LIST_MODEL: %s'
218 logger.append(_(msg) % ' ,'.join(list(difference)))
219
208 # create a specific cursor for the call220 # create a specific cursor for the call
209 self.sync_cursor = pooler.get_db(cr.dbname).cursor()221 self.sync_cursor = pooler.get_db(cr.dbname).cursor()
210222
@@ -497,6 +509,71 @@
497 finally:509 finally:
498 self.renew_lock.release()510 self.renew_lock.release()
499511
512 def get_model_white_list(self, cr, uid):
513 '''
514 return a set of all models involved in the synchronization process
515 '''
516 model_field_dict = {}
517
518 # search for model of sync_server.sync_rule
519 if self.pool.get('sync_server.sync_rule'):
520 rule_module = self.pool.get('sync_server.sync_rule')
521 model_field_name = 'model_id'
522 else:
523 rule_module = self.pool.get('sync.client.rule')
524 model_field_name = 'model'
525 obj_ids = rule_module.search(cr, uid, [('active', '=', True)])
526 for obj in rule_module.read(cr, uid, obj_ids, [model_field_name, 'included_fields']):
527 if obj[model_field_name] not in model_field_dict:
528 model_field_dict[obj[model_field_name]] = set()
529 model_field_dict[obj[model_field_name]].update(eval(obj['included_fields']))
530
531 # search for model of sync_server.message_rule
532 if self.pool.get('sync_server.message_rule'):
533 rule_module = self.pool.get('sync_server.message_rule')
534 model_field_name = 'model_id'
535 else:
536 rule_module = self.pool.get('sync.client.message_rule')
537 model_field_name = 'model'
538 obj_ids = rule_module.search(cr, uid, [('active', '=', True)])
539 for obj in rule_module.read(cr, uid, obj_ids, [model_field_name, 'arguments']):
540 if obj[model_field_name] not in model_field_dict:
541 model_field_dict[obj[model_field_name]] = set()
542 model_field_dict[obj[model_field_name]].update(eval(obj['arguments']))
543
544 model_set = set(model_field_dict.keys())
545
546 def get_field_obj(model, field_name):
547 model_obj = self.pool.get(model)
548 field_obj = None
549 if field_name in model_obj._columns:
550 field_obj = model_obj._columns[field_name]
551 elif field_name in model_obj._inherit_fields:
552 field_obj = model_obj._inherit_fields[field_name][2]
553 return field_obj
554
555
556 # for each field corresponding to each model, check if it is a m2m m2o or o2m
557 # if yes, add the model of the relation to the model set
558
559 for model, field_list in model_field_dict.items():
560 field_list_to_parse = [x for x in field_list if '/id' in x]
561 if not field_list_to_parse:
562 continue
563
564 for field in field_list_to_parse:
565 field = field.replace('/id', '')
566 if len(field.split('/')) == 2:
567 related_field, field = field.split('/')
568 field_obj = get_field_obj(model, related_field)
569 related_model = field_obj._obj
570 field_obj = get_field_obj(related_model, field)
571 else:
572 field_obj = get_field_obj(model, field)
573 if field_obj._type in ('many2one', 'many2many', 'one2many'):
574 model_set.add(field_obj._obj)
575 return model_set
576
500 @sync_process('data_push')577 @sync_process('data_push')
501 def push_update(self, cr, uid, context=None):578 def push_update(self, cr, uid, context=None):
502 """579 """
503580
=== modified file 'bin/addons/sync_common/common.py'
--- bin/addons/sync_common/common.py 2016-11-18 13:31:06 +0000
+++ bin/addons/sync_common/common.py 2017-02-16 09:58:42 +0000
@@ -8,101 +8,147 @@
8import tools8import tools
9from tools.translate import _9from tools.translate import _
1010
11# model related to synchronization, this model don't have to be ignored.
12# list build by getting models of update rules and message rules
13WHITE_LIST_MODEL = [
14 'account.account',
15 'account.account.type',
16 'account.analytic.account',
17 'account.analytic.journal',
18 'account.analytic.line',
19 'account.bank.statement',
20 'account.bank.statement.line',
21 'account.bank.statement.line.deleted',
22 'account.cashbox.line',
23 'account.destination.link',
24 'account.fiscal.position',
25 'account.fiscalyear',
26 'account.fiscalyear.state',
27 'account.invoice',
28 'account.journal',
29 'account.move',
30 'account.move.line',
31 'account.move.reconcile',
32 'account.payment.term',
33 'account.period',
34 'account.period.state',
35 'account.target.costcenter',
36 'account.tax',
37 'account.tax.code',
38 'analytic.distribution',
39 'claim.event',
40 'claim.product.line',
41 'composition.item',
42 'composition.kit',
43 'cost.center.distribution.line',
44 'country.export.mapping',
45 'distribution.line',
46 'financing.contract.contract',
47 'financing.contract.donor',
48 'financing.contract.format',
49 'financing.contract.format.line',
50 'financing.contract.funding.pool.line',
51 'free.1.distribution.line',
52 'free.2.distribution.line',
53 'funding.pool.distribution.line',
54 'hq.entries',
55 'hr.employee',
56 'hr.employee.marital.status',
57 'hr.job',
58 'initial.stock.inventory',
59 'initial.stock.inventory.line',
60 'ir.actions.act_window',
61 'ir.filters',
62 'ir.model',
63 'ir.model.access',
64 'ir.model.fields',
65 'ir.rule',
66 'ir.sequence',
67 'ir.translation',
68 'ir.ui.menu',
69 'ir.ui.view',
70 'kit.creation',
71 'kit.creation.to.consume',
72 'monthly.review.consumption',
73 'monthly.review.consumption.line',
74 'msf.budget',
75 'msf.budget.decision.moment',
76 'msf.budget.line',
77 'msf.instance',
78 'msf_button_access_rights.button_access_rule',
79 'msf_field_access_rights.field_access_rule',
80 'msf_field_access_rights.field_access_rule_line',
81 'pack.type',
82 'procurement.order',
83 'product.asset',
84 'product.asset.type',
85 'product.category',
86 'product.cold_chain',
87 'product.heat_sensitive',
88 'product.international.status',
89 'product.justification.code',
90 'product.list',
91 'product.list.line',
92 'product.nomenclature',
93 'product.pricelist',
94 'product.pricelist.type',
95 'product.pricelist.version',
96 'product.product',
97 'product.uom',
98 'product.uom.categ',
99 'purchase.order',
100 'purchase.order.line',
101 'real.average.consumption',
102 'real.average.consumption.line',
103 'res.company',
104 'res.country',
105 'res.country.restriction',
106 'res.country.state',
107 'res.currency',
108 'res.currency.rate',
109 'res.currency.table',
110 'res.groups',
111 'res.partner',
112 'res.partner.address',
113 'res.partner.title',
114 'res.users',
115 'return.claim',
116 'sale.order',
117 'sale.order.line',
118 'sale.order.line.cancel',
119 'shipment',
120 'stock.frequence',
121 'stock.inventory',
122 'stock.inventory.line',
123 'stock.journal',
124 'stock.location',
125 'stock.location.chained.options',
126 'stock.mission.report',
127 'stock.mission.report.line',
128 'stock.move',
129 'stock.picking',
130 'stock.production.lot',
131 'stock.reason.type',
132 'stock.warehouse',
133 'stock.warehouse.automatic.supply',
134 'stock.warehouse.automatic.supply.line',
135 'stock.warehouse.order.cycle',
136 'stock.warehouse.order.cycle.line',
137 'stock.warehouse.orderpoint',
138 'supplier.catalogue',
139 'supplier.catalogue.line',
140 'sync.monitor',
141 'sync.sale.order.line.split',
142 'sync.version.instance.monitor',
143 'tender',
144 'tender.line',
145 'threshold.value',
146 'threshold.value.line',
147]
148
11OC_LIST = ['OCA', 'OCB', 'OCBA', 'OCG', 'OCP']149OC_LIST = ['OCA', 'OCB', 'OCBA', 'OCG', 'OCP']
12OC_LIST_TUPLE = zip([x.lower() for x in OC_LIST], OC_LIST)150OC_LIST_TUPLE = zip([x.lower() for x in OC_LIST], OC_LIST)
13151
14MODELS_TO_IGNORE = [
15 'ir.actions.wizard',
16 'ir.actions.act_window.view',
17 'ir.report.custom',
18 'ir.actions.act_window.view',
19 'ir.actions.wizard',
20 'ir.report.custom',
21 'ir.ui.view',
22 'ir.sequence',
23 'ir.actions.url',
24 'ir.values',
25 'ir.report.custom.fields',
26 'ir.cron',
27 'ir.actions.report.xml',
28 'ir.property',
29 'ir.actions.todo',
30 'ir.sequence.type',
31 #'ir.actions.act_window',
32 'ir.module.module',
33 'ir.ui.view',
34 'ir.module.repository',
35 'ir.model.data',
36 'ir.model.fields',
37 'ir.ui.view_sc',
38 'ir.config_parameter',
39
40 #'sync.monitor',
41 'sync.client.rule',
42 'sync.client.push.data.information',
43 'sync.client.update_to_send',
44 'sync.client.update_received',
45 'sync.client.entity',
46 'sync.client.sync_server_connection',
47 'sync.client.message_rule',
48 'sync.client.message_to_send',
49 'sync.client.message_received',
50 'sync.client.message_sync',
51 'sync.client.orm_extended',
52
53 'sync.server.test',
54 'sync_server.version.manager',
55 'sync.server.entity_group',
56 'sync.server.entity',
57 'sync.server.group_type',
58 'sync.server.entity_group',
59 'sync.server.entity',
60 'sync.server.sync_manager',
61 'sync_server.sync_rule',
62 'sync_server.message_rule',
63 'sync_server.sync_rule.forced_values',
64 'sync_server.sync_rule.fallback_values',
65 'sync_server.rule.validation.message',
66 'sync.server.update',
67 'sync.server.message',
68 'sync_server.version',
69 'sync.server.puller_logs',
70 'audittrail.log.sequence',
71 'audittrail.log.line',
72
73 'res.widget',
74 'product.likely.expire.report',
75 'product.likely.expire.report.line',
76 'operations.event',
77]
78
79MODELS_TO_IGNORE_DOMAIN = [
80 'sync_client.%',
81 'sync_server.%',
82 'res.widget%',
83 'base%',
84 'board%',
85 'audittrail%',
86 'workflow%',
87]
88
89def __compile_models_to_ignore():
90 global MODELS_TO_IGNORE_DOMAIN
91 simple_patterns = []
92 exact_models = []
93 for model in MODELS_TO_IGNORE_DOMAIN:
94 if model.find('%') >= 0:
95 simple_patterns.append(model)
96 else:
97 exact_models.append(model)
98 MODELS_TO_IGNORE_DOMAIN[:] = [('model','not in',exact_models)]
99 for pattern in simple_patterns:
100 MODELS_TO_IGNORE_DOMAIN.extend(['!',('model','=like',pattern)])
101
102__compile_models_to_ignore()
103
104
105
106def xmlid_to_sdref(xmlid):152def xmlid_to_sdref(xmlid):
107 if not xmlid: return None153 if not xmlid: return None
108 head, sep, tail = xmlid.partition('.')154 head, sep, tail = xmlid.partition('.')
@@ -112,8 +158,6 @@
112 else:158 else:
113 return head159 return head
114160
115
116
117# TODO deprecated, should disappear161# TODO deprecated, should disappear
118def sync_log(obj, message=None, level='debug', ids=None, data=None, tb=False):162def sync_log(obj, message=None, level='debug', ids=None, data=None, tb=False):
119 if not hasattr(obj, '_logger'):163 if not hasattr(obj, '_logger'):
120164
=== modified file 'bin/addons/sync_server/rules.py'
--- bin/addons/sync_server/rules.py 2016-11-18 11:26:45 +0000
+++ bin/addons/sync_server/rules.py 2017-02-16 09:58:42 +0000
@@ -27,7 +27,7 @@
27from datetime import datetime27from datetime import datetime
2828
29import logging29import logging
30from sync_common import MODELS_TO_IGNORE_DOMAIN, sync_log30from sync_common import sync_log
3131
32_field2type = {32_field2type = {
33 'text' : 'str',33 'text' : 'str',
@@ -829,7 +829,7 @@
829829
830 def _get_fallback_value(self, cr, uid, context=None):830 def _get_fallback_value(self, cr, uid, context=None):
831 model = self.pool.get('ir.model')831 model = self.pool.get('ir.model')
832 ids = model.search(cr, uid, MODELS_TO_IGNORE_DOMAIN)832 ids = model.search(cr, uid, ('model', 'not in', WHITE_LIST_MODEL))
833 res = model.read(cr, uid, ids, ['model'], context)833 res = model.read(cr, uid, ids, ['model'], context)
834 return [(r['model'], r['model']) for r in res]834 return [(r['model'], r['model']) for r in res]
835835

Subscribers

People subscribed via source and target branches