Merge lp:~jfb-tempo-consulting/unifield-server/US-6718-6712-6684 into lp:unifield-server
- US-6718-6712-6684
- Merge into trunk
Proposed by
jftempo
Status: | Merged |
---|---|
Merged at revision: | 5622 |
Proposed branch: | lp:~jfb-tempo-consulting/unifield-server/US-6718-6712-6684 |
Merge into: | lp:unifield-server |
Diff against target: |
610 lines (+187/-67) (has conflicts) 15 files modified
bin/addons/base/ir/ir.xml (+2/-1) bin/addons/base/ir/ir_cron.py (+4/-2) bin/addons/base/res/res_currency.py (+2/-2) bin/addons/msf_instance/data/instance_data.xml (+0/-13) bin/addons/msf_instance/data/remote_backup.xml (+1/-0) bin/addons/msf_instance/msf_instance.py (+14/-2) bin/addons/msf_profile/data/patches.xml (+7/-0) bin/addons/msf_profile/i18n/fr_MF.po (+32/-10) bin/addons/msf_profile/msf_profile.py (+17/-0) bin/addons/sync_client/backup.py (+38/-10) bin/addons/sync_client/backup_view.xml (+20/-18) bin/addons/sync_client/data/cron.xml (+2/-1) bin/addons/sync_client/sync_client.py (+3/-1) bin/tools/misc.py (+41/-7) bin/unifield-version.txt (+4/-0) Text conflict in bin/addons/msf_profile/data/patches.xml Text conflict in bin/addons/msf_profile/msf_profile.py Text conflict in bin/unifield-version.txt |
To merge this branch: | bzr merge lp:~jfb-tempo-consulting/unifield-server/US-6718-6712-6684 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
UniField Reviewer Team | Pending | ||
Review via email: mp+378100@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/base/ir/ir.xml' |
2 | --- bin/addons/base/ir/ir.xml 2019-06-18 13:53:48 +0000 |
3 | +++ bin/addons/base/ir/ir.xml 2020-01-27 10:41:32 +0000 |
4 | @@ -1576,7 +1576,8 @@ |
5 | <field name="arch" type="xml"> |
6 | <form string="Scheduled Actions"> |
7 | <field name="name"/> |
8 | - <field name="active"/> |
9 | + <field name="active" attrs="{'readonly': [('manual_activation', '=', False)]}"/> |
10 | + <field name="manual_activation" invisible="1" /> |
11 | <field name="user_id" /> |
12 | <field name="priority" /> |
13 | <notebook colspan="4"> |
14 | |
15 | === modified file 'bin/addons/base/ir/ir_cron.py' |
16 | --- bin/addons/base/ir/ir_cron.py 2019-07-19 07:33:28 +0000 |
17 | +++ bin/addons/base/ir/ir_cron.py 2020-01-27 10:41:32 +0000 |
18 | @@ -60,7 +60,8 @@ |
19 | 'model': fields.char('Object', size=64, help="Name of object whose function will be called when this scheduler will run. e.g. 'res.partener'"), |
20 | 'function': fields.char('Function', size=64, help="Name of the method to be called on the object when this scheduler is executed."), |
21 | 'args': fields.text('Arguments', help="Arguments to be passed to the method. e.g. (uid,)"), |
22 | - 'priority': fields.integer('Priority', help='0=Very Urgent\n10=Not urgent') |
23 | + 'priority': fields.integer('Priority', help='0=Very Urgent\n10=Not urgent'), |
24 | + 'manual_activation': fields.boolean('Manual Activation', internal=1, readonly=1, help='Used to set active as RO'), |
25 | } |
26 | |
27 | _defaults = { |
28 | @@ -71,7 +72,8 @@ |
29 | 'interval_type' : lambda *a: 'months', |
30 | 'numbercall' : lambda *a: 1, |
31 | 'active' : lambda *a: 1, |
32 | - 'doall' : lambda *a: 0 |
33 | + 'doall' : lambda *a: 0, |
34 | + 'manual_activation': True |
35 | } |
36 | |
37 | def _check_args(self, cr, uid, ids, context=None): |
38 | |
39 | === modified file 'bin/addons/base/res/res_currency.py' |
40 | --- bin/addons/base/res/res_currency.py 2019-10-31 14:53:19 +0000 |
41 | +++ bin/addons/base/res/res_currency.py 2020-01-27 10:41:32 +0000 |
42 | @@ -329,7 +329,7 @@ |
43 | partner_list = ' / '.join(x.res_id.name for x in properties) |
44 | raise osv.except_osv(_('Error !'), |
45 | _('You cannot uncheck the ESC checkbox because this currency is used on these \'ESC\' partners : \ |
46 | - %s' % partner_list)) |
47 | + %s') % partner_list) |
48 | |
49 | if 'active' in values and not values.get('currency_table_id', False) and pricelist_obj: |
50 | if values['active'] == False: |
51 | @@ -501,7 +501,7 @@ |
52 | date = line[0] |
53 | elif line[0] != date: |
54 | raise osv.except_osv(_('Error'), |
55 | - _("All dates should be equal for all lines in file %s." % file_to_import)) |
56 | + _("All dates should be equal for all lines in file %s.") % file_to_import) |
57 | line_number += 1 |
58 | |
59 | # check that this date is a real date |
60 | |
61 | === modified file 'bin/addons/msf_instance/data/instance_data.xml' |
62 | --- bin/addons/msf_instance/data/instance_data.xml 2018-02-22 14:23:17 +0000 |
63 | +++ bin/addons/msf_instance/data/instance_data.xml 2020-01-27 10:41:32 +0000 |
64 | @@ -15,18 +15,5 @@ |
65 | <field name="instance_id" ref="instance_section" /> |
66 | </record> |
67 | |
68 | - <record id="ir_cron_remote_backup" model="ir.cron" forcecreate="1"> |
69 | - <field name="function">send_backup</field> |
70 | - <field name="user_id">1</field> |
71 | - <field name="name">Send Remote Backup</field> |
72 | - <field name="interval_type">days</field> |
73 | - <field eval="-1" name="numbercall"/> |
74 | - <field eval="5" name="priority"/> |
75 | - <field eval="0" name="doall"/> |
76 | - <field eval="0" name="active"/> |
77 | - <field eval="1" name="interval_number"/> |
78 | - <field name="model">msf.instance</field> |
79 | - </record> |
80 | - |
81 | </data> |
82 | </openerp> |
83 | |
84 | === modified file 'bin/addons/msf_instance/data/remote_backup.xml' |
85 | --- bin/addons/msf_instance/data/remote_backup.xml 2019-07-19 07:33:28 +0000 |
86 | +++ bin/addons/msf_instance/data/remote_backup.xml 2020-01-27 10:41:32 +0000 |
87 | @@ -12,6 +12,7 @@ |
88 | <field eval="0" name="active"/> |
89 | <field eval="1" name="interval_number"/> |
90 | <field name="model">msf.instance.cloud</field> |
91 | + <field name="manual_activation" eval="False" /> |
92 | </record> |
93 | |
94 | </data> |
95 | |
96 | === modified file 'bin/addons/msf_instance/msf_instance.py' |
97 | --- bin/addons/msf_instance/msf_instance.py 2019-07-30 10:04:51 +0000 |
98 | +++ bin/addons/msf_instance/msf_instance.py 2020-01-27 10:41:32 +0000 |
99 | @@ -680,7 +680,8 @@ |
100 | to_write['active'] = False |
101 | elif to_activate: |
102 | if not cron_data.active: |
103 | - to_write['active'] = True |
104 | + if self.pool.get('backup.config').search(cr, uid, [('backup_type', '=', 'sharepoint')]): |
105 | + to_write['active'] = True |
106 | |
107 | next_cron = DateTime.strptime(cron_data.nextcall, '%Y-%m-%d %H:%M:%S') |
108 | if not cron_data.active or abs(round(next_cron.hour + next_cron.minute/60.,2) - round(myself['cloud_schedule_time'],2)) > 0.001: |
109 | @@ -707,6 +708,17 @@ |
110 | return now_dt >= start_dt or now_dt <= end_dt |
111 | |
112 | def send_backup_bg(self, cr, uid, progress=False, context=None): |
113 | + if not self.pool.get('backup.config').search(cr, uid, [('backup_type', '=', 'sharepoint')]): |
114 | + self._logger.warn('SharePoint push: the cron task is active but the backup configuration is set to Cont. Backup') |
115 | + return True |
116 | + local_instance = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.instance_id |
117 | + if not local_instance: |
118 | + return True |
119 | + info = self._get_cloud_info(cr, uid, local_instance.id) |
120 | + for data in ['url', 'login', 'password']: |
121 | + if not info[data]: |
122 | + self.pool.get('sync.version.instance.monitor').create(cr, uid, {'cloud_error': 'SharePoint indentifiers not set.'}, context=context) |
123 | + return True |
124 | thread = threading.Thread(target=self.send_backup_run, args=(cr.dbname, uid, progress, context)) |
125 | thread.start() |
126 | return True |
127 | @@ -739,7 +751,7 @@ |
128 | progress_obj = False |
129 | |
130 | try: |
131 | - if not config.get('send_to_onedrive') and not misc.use_prod_sync(cr): |
132 | + if not config.get('send_to_onedrive') and not misc.use_prod_sync(cr, uid, self.pool): |
133 | raise osv.except_osv(_('Warning'), _('Only production instances are allowed !')) |
134 | |
135 | if not local_instance: |
136 | |
137 | === modified file 'bin/addons/msf_profile/data/patches.xml' |
138 | --- bin/addons/msf_profile/data/patches.xml 2020-01-14 16:49:14 +0000 |
139 | +++ bin/addons/msf_profile/data/patches.xml 2020-01-27 10:41:32 +0000 |
140 | @@ -477,6 +477,7 @@ |
141 | <field name="method">us_6768_trigger_FP_sync</field> |
142 | </record> |
143 | |
144 | +<<<<<<< TREE |
145 | <!-- UF15.1 --> |
146 | <record id="us_6930_gen_unreconcile" model="patch.scripts"> |
147 | <field name="method">us_6930_gen_unreconcile</field> |
148 | @@ -490,5 +491,11 @@ |
149 | <field name="method">rec_entries_uf14_1_uf15</field> |
150 | </record> |
151 | |
152 | +======= |
153 | + <record id="us_6684_push_backup" model="patch.scripts"> |
154 | + <field name="method">us_6684_push_backup</field> |
155 | + </record> |
156 | + |
157 | +>>>>>>> MERGE-SOURCE |
158 | </data> |
159 | </openerp> |
160 | |
161 | === modified file 'bin/addons/msf_profile/i18n/fr_MF.po' |
162 | --- bin/addons/msf_profile/i18n/fr_MF.po 2019-11-21 16:33:04 +0000 |
163 | +++ bin/addons/msf_profile/i18n/fr_MF.po 2020-01-27 10:41:32 +0000 |
164 | @@ -106296,17 +106296,13 @@ |
165 | msgstr "%s non trouvé" |
166 | |
167 | #. module: sync_client |
168 | -#: field:backup.config,continuous_backup_enabled:0 |
169 | -msgid "Activate continuous backup" |
170 | -msgstr "Activer la sauvegarde continue" |
171 | - |
172 | -#. module: sync_client |
173 | #: field:backup.config,basebackup_error:0 |
174 | msgid "Base backup error" |
175 | msgstr "Erreur Sauvegarde Base" |
176 | |
177 | #. module: sync_client |
178 | #: view:backup.config:0 |
179 | +#: selection:backup.config,backup_type:0 |
180 | msgid "Continuous Backup" |
181 | msgstr "Sauvegarde Continue" |
182 | |
183 | @@ -106395,11 +106391,8 @@ |
184 | |
185 | #. module: sync_client |
186 | #: view:backup.config:0 |
187 | -msgid "" |
188 | -"Replace the 3 occurences of \"C:\\\\WAL\\\\\" with the path to the local WAL" |
189 | -" Archive directory." |
190 | -msgstr "Remplacer les 3 occurrences de \"C:\\\\WAL\\\\\" par votre répertoire local" |
191 | -" des archives WAL" |
192 | +msgid "Replace the 3 occurences of \"C:\\\\WAL\\\\\" with the path to the local WAL Archive directory." |
193 | +msgstr "Remplacer les 3 occurrences de \"C:\\\\WAL\\\\\" par votre répertoire local des archives WAL" |
194 | |
195 | #. module: sync_client |
196 | #: view:backup.config:0 |
197 | @@ -106586,3 +106579,32 @@ |
198 | msgid "Funding Pool not found." |
199 | msgstr "Funding Pool non trouvé." |
200 | |
201 | +#. module: sync_client |
202 | +#: field:backup.config,backup_type:0 |
203 | +msgid "Backup Type" |
204 | +msgstr "Type de Sauvegarde" |
205 | + |
206 | +#. module: sync_client |
207 | +#: selection:backup.config,backup_type:0 |
208 | +msgid "Direct push to Sharepoint" |
209 | +msgstr "Envoi direct sur Sharepoint" |
210 | + |
211 | +#. module: sync_client |
212 | +#: field:sync.client.entity,previous_hw:0 |
213 | +msgid "Last HW successfully used" |
214 | +msgstr "Dernier HW validé" |
215 | + |
216 | +#. module: base |
217 | +#: field:ir.cron,manual_activation:0 |
218 | +msgid "Manual Activation" |
219 | +msgstr "Activation Manuelle" |
220 | + |
221 | +#. module: sync_client |
222 | +#: view:backup.config:0 |
223 | +msgid "Type of Backup" |
224 | +msgstr "Type de Sauvegarde" |
225 | + |
226 | +#. module: base |
227 | +#: help:ir.cron,manual_activation:0 |
228 | +msgid "Used to set active as RO" |
229 | +msgstr "Utilisé pour passer le champ Actif en lecture seule" |
230 | |
231 | === modified file 'bin/addons/msf_profile/msf_profile.py' |
232 | --- bin/addons/msf_profile/msf_profile.py 2020-01-17 13:25:56 +0000 |
233 | +++ bin/addons/msf_profile/msf_profile.py 2020-01-27 10:41:32 +0000 |
234 | @@ -52,6 +52,7 @@ |
235 | 'model': lambda *a: 'patch.scripts', |
236 | } |
237 | |
238 | +<<<<<<< TREE |
239 | # UF15.2 |
240 | def rec_entries_uf14_1_uf15(self, cr, uid, *a, **b): |
241 | current_instance = self.pool.get('res.users').browse(cr, uid, uid, fields_to_fetch=['company_id']).company_id.instance_id |
242 | @@ -130,6 +131,22 @@ |
243 | |
244 | return True |
245 | |
246 | +======= |
247 | + # UF16.0 |
248 | + def us_6684_push_backup(self, cr, uid, *a, **b): |
249 | + backup_obj = self.pool.get('backup.config') |
250 | + if backup_obj: |
251 | + cr.execute("update ir_cron set manual_activation='f' where function='send_backup_bg' and model='msf.instance.cloud'") |
252 | + cr.execute("update ir_cron set name='Send Continuous Backup', manual_activation='f' where function='sent_continuous_backup_bg' and model='backup.config'") |
253 | + if cr.column_exists('backup_config', 'continuous_backup_enabled'): |
254 | + cr.execute("update backup_config set backup_type='cont_back' where continuous_backup_enabled='t'") |
255 | + |
256 | + # update active field on cron |
257 | + bck_ids = backup_obj.search(cr, uid, []) |
258 | + backup_obj.write(cr, uid, bck_ids, {}) |
259 | + return True |
260 | + |
261 | +>>>>>>> MERGE-SOURCE |
262 | # UF15.0 |
263 | def us_6768_trigger_FP_sync(self, cr, uid, *a, **b): |
264 | """ |
265 | |
266 | === modified file 'bin/addons/sync_client/backup.py' |
267 | --- bin/addons/sync_client/backup.py 2019-09-27 15:05:56 +0000 |
268 | +++ bin/addons/sync_client/backup.py 2020-01-27 10:41:32 +0000 |
269 | @@ -77,7 +77,6 @@ |
270 | 'backup_path': fields.function(_get_bck_info, type='char', string='Last Backup', method=True, multi='cloud'), |
271 | 'backup_size': fields.function(_get_bck_info, type='float', string='Backup Size', method=True, multi='cloud'), |
272 | |
273 | - 'continuous_backup_enabled': fields.boolean('Activate continuous backup'), |
274 | 'wal_directory': fields.char('Local Path to WAL Archive Dir', help='Must be set in postgresql.conf', size=256), |
275 | 'remote_user': fields.char('Remote User', help='Keep empty to use default value', size=256), |
276 | 'remote_host': fields.char('Remote Host', help='Keep empty to use default value', size=256), |
277 | @@ -88,19 +87,40 @@ |
278 | 'rsync_date': fields.datetime('Date of last rsync', readonly=1), |
279 | 'rsync_error': fields.text('Rsync error', readonly=1), |
280 | 'help_wal': fields.function(tools.misc.get_fake, type='boolean', string='Display steps to set Continuous Backup', method=True), |
281 | + 'backup_type': fields.selection([('cont_back', 'Continuous Backup'), ('sharepoint', 'Direct push to Sharepoint')], 'Backup Type', required=True), |
282 | } |
283 | |
284 | _defaults = { |
285 | + 'backup_type': 'sharepoint', |
286 | 'name' : 'c:\\backup\\', |
287 | 'beforemanualsync' : True, |
288 | 'beforeautomaticsync' : True, |
289 | 'aftermanualsync' : True, |
290 | 'afterautomaticsync' : True, |
291 | 'beforepatching': True, |
292 | - 'continuous_backup_enabled': False, |
293 | 'ssh_config_dir': 'C:\\Program Files (x86)\\msf\\SSH_CONFIG', |
294 | } |
295 | |
296 | + def _activate_push_cron(self, cr, uid, ids, context=None): |
297 | + ir_cron = self.pool.get('ir.cron') |
298 | + |
299 | + for bck in self.read(cr, uid, ids, ['backup_type'], context=context): |
300 | + od_active = bck['backup_type'] == 'sharepoint' |
301 | + |
302 | + od_task = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'msf_instance', 'ir_cron_remote_backup') |
303 | + if not ir_cron.search(cr, uid, [('id', '=', od_task[1]), ('active', '=', od_active)]): |
304 | + ir_cron.write(cr, uid, od_task[1], {'active': od_active}) |
305 | + |
306 | + wal_task = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'sync_client', 'ir_cron_wal') |
307 | + if not ir_cron.search(cr, uid, [('id', '=', wal_task[1]), ('active', '=', not od_active)]): |
308 | + ir_cron.write(cr, uid, wal_task[1], {'active': not od_active}) |
309 | + |
310 | + return True |
311 | + |
312 | + _constraints = [ |
313 | + (_activate_push_cron, '', []) |
314 | + ] |
315 | + |
316 | def button_basebackup(self, cr, uid, ids, context=None): |
317 | self.write(cr, uid, ids, {'basebackup_error': _('In progress')}, context=context) |
318 | new_thread = threading.Thread( |
319 | @@ -121,7 +141,7 @@ |
320 | else: |
321 | cr = old_cr |
322 | bk = self.browse(cr, uid, ids[0], context) |
323 | - if not bk.continuous_backup_enabled: |
324 | + if bk.backup_type != 'cont_back': |
325 | raise Exception(_('Continuous Backup is disabled')) |
326 | if not bk.wal_directory: |
327 | raise Exception(_('"Path to WAL Dir" is empty')) |
328 | @@ -155,20 +175,25 @@ |
329 | |
330 | def sent_continuous_backup(self, old_cr, uid, context=None): |
331 | try: |
332 | + if context is None: |
333 | + context = {} |
334 | cr = pooler.get_db(old_cr.dbname).cursor() |
335 | - ids = self.search(cr, uid, [], context) |
336 | - bk = self.read(cr, uid, ids[0], ['continuous_backup_enabled', 'basebackup_date'], context=context) |
337 | - if not bk['continuous_backup_enabled']: |
338 | + ids = self.search(cr, uid, [], context=context) |
339 | + bk = self.read(cr, uid, ids[0], ['backup_type', 'basebackup_date'], context=context) |
340 | + if bk['backup_type'] != 'cont_back': |
341 | self._logger.info(_('Continuous backup disabled')) |
342 | return True |
343 | if not bk['basebackup_date']: |
344 | + if context.get('sync_type'): |
345 | + self._logger.info('Base Backup disabled after sync') |
346 | + return True |
347 | self.generate_basebackup_bg(cr, uid, ids, context=context, new_cr=False) |
348 | self.sent_to_remote_bg(cr, uid, ids, context=context, new_cr=False) |
349 | return True |
350 | |
351 | - except Exception, e: |
352 | + except Exception: |
353 | cr.rollback() |
354 | - raise e |
355 | + raise |
356 | finally: |
357 | cr.commit() |
358 | cr.close(True) |
359 | @@ -193,15 +218,16 @@ |
360 | else: |
361 | cr = old_cr |
362 | |
363 | - if not tools.config.get('send_to_onedrive') and not tools.misc.use_prod_sync(cr): |
364 | + if not tools.config.get('send_to_onedrive') and not tools.misc.use_prod_sync(cr, uid, self.pool): |
365 | raise Exception(_('Only production instances are allowed !')) |
366 | |
367 | dbname = cr.dbname |
368 | bk = self.browse(cr, uid, ids[0], context) |
369 | - if not bk.continuous_backup_enabled: |
370 | + if bk.backup_type != 'cont_back': |
371 | raise Exception('Continuous Backup is disabled') |
372 | if not bk.wal_directory: |
373 | raise Exception('"Path to WAL Dir" is empty') |
374 | + tools.misc.force_wal_generation(cr, bk.wal_directory) |
375 | tools.misc.sent_to_remote(bk.wal_directory, config_dir=bk.ssh_config_dir, remote_user=bk.remote_user, remote_host=bk.remote_host, remote_dir=dbname) |
376 | self.write(cr, uid, [bk.id], {'rsync_date': time.strftime('%Y-%m-%d %H:%M:%S'), 'rsync_error': False}, context=ctx_no_write) |
377 | return True |
378 | @@ -305,6 +331,8 @@ |
379 | elif state.startswith('after'): |
380 | suffix = '-A' |
381 | |
382 | + if state.startswith('after'): |
383 | + self.sent_continuous_backup_bg(cr, uid, context) |
384 | if bkp_ids: |
385 | if logger: |
386 | logger.append("Database %s backup started.." % state) |
387 | |
388 | === modified file 'bin/addons/sync_client/backup_view.xml' |
389 | --- bin/addons/sync_client/backup_view.xml 2019-09-27 15:29:25 +0000 |
390 | +++ bin/addons/sync_client/backup_view.xml 2020-01-27 10:41:32 +0000 |
391 | @@ -36,7 +36,6 @@ |
392 | <field name="scheduledbackup"/> |
393 | </group> |
394 | <button type="object" string="Backup" name="button_exp_dump" icon="db_dump.png" /> |
395 | - <button type="object" string="Send Last Backup to remote" name="send_to_cloud" icon="cloud.png"/> |
396 | <group colspan="6"> |
397 | <html> |
398 | <br /><br /> |
399 | @@ -52,21 +51,26 @@ |
400 | <br /><br /> |
401 | </html> |
402 | </group> |
403 | - <separator colspan="6" string="Cloud" /> |
404 | + <separator colspan="6" string="Type of Backup" /> |
405 | + <field name="backup_type" /> |
406 | + |
407 | + <group colspan="6" col="6" attrs="{'invisible': [('backup_type', '!=', 'sharepoint')]}"> |
408 | <field name="cloud_url" widget="url" colspan="6"/> |
409 | <newline /> |
410 | <field name="cloud_date" /> |
411 | <field name="cloud_backup" /> |
412 | - <field name="cloud_size" widget="human_size"/> |
413 | - <button colspan="2" icon="monitor.png" name="test_cloud" string="Test Cloud" type="object" /> |
414 | + <field name="cloud_size" widget="human_size" /> |
415 | + <button type="object" string="Test Cloud" name="test_cloud" icon="monitor.png" colspan="3"/> |
416 | + <button type="object" string="Send Last Backup to remote" name="send_to_cloud" icon="cloud.png" colspan="3"/> |
417 | <group colspan="6"> |
418 | <html> |
419 | <br /><br /> |
420 | </html> |
421 | </group> |
422 | <field name="cloud_error" colspan="6" widget="full_text"/> |
423 | + </group> |
424 | |
425 | - <separator colspan="6" string="Continuous Backup" /> |
426 | + <group colspan="6" attrs="{'invisible': [('backup_type', '!=', 'cont_back')]}"> |
427 | <field name="help_wal" readonly="0"/> |
428 | <group colspan="6" attrs="{'invisible': [('help_wal', '=', False)]}"> |
429 | <html> |
430 | @@ -102,20 +106,18 @@ |
431 | <br /> |
432 | </html> |
433 | </group> |
434 | - <field name="continuous_backup_enabled" /> |
435 | - <group colspan="6" attrs="{'invisible': [('continuous_backup_enabled', '=', False)]}"> |
436 | - <field name="wal_directory" attrs="{'required': [('continuous_backup_enabled', '=', True)]}" colspan="3"/> |
437 | - <field name="ssh_config_dir" attrs="{'required': [('continuous_backup_enabled', '=', True)]}" colspan="3"/> |
438 | - <newline /> |
439 | - <field name="remote_user" /> |
440 | - <field name="remote_host" /> |
441 | - <button type="object" string="Generate Base Backup" name="button_basebackup" icon="db_dump.png" colspan="2"/> |
442 | - <button type="object" string="Send WAL/Base backup to remote" name="button_rsync" icon="cloud.png" colspan="2"/> |
443 | + <field name="wal_directory" attrs="{'required': [('backup_type', '=', 'cont_back')]}" colspan="3"/> |
444 | + <field name="ssh_config_dir" attrs="{'required': [('backup_type', '=', 'cont_back')]}" colspan="3"/> |
445 | + <newline /> |
446 | + <field name="remote_user" /> |
447 | + <field name="remote_host" /> |
448 | + <button type="object" string="Generate Base Backup" name="button_basebackup" icon="db_dump.png" colspan="2"/> |
449 | + <button type="object" string="Send WAL/Base backup to remote" name="button_rsync" icon="cloud.png" colspan="2"/> |
450 | |
451 | - <field name="basebackup_date" /> |
452 | - <field name="rsync_date" /> |
453 | - <field name="basebackup_error" colspan="6" attrs="{'invisible': [('basebackup_error', '=', False)]}"/> |
454 | - <field name="rsync_error" colspan="6" attrs="{'invisible': [('rsync_error', '=', False)]}"/> |
455 | + <field name="basebackup_date" /> |
456 | + <field name="rsync_date" /> |
457 | + <field name="basebackup_error" colspan="6" attrs="{'invisible': [('basebackup_error', '=', False)]}"/> |
458 | + <field name="rsync_error" colspan="6" attrs="{'invisible': [('rsync_error', '=', False)]}"/> |
459 | </group> |
460 | </group> |
461 | </form> |
462 | |
463 | === modified file 'bin/addons/sync_client/data/cron.xml' |
464 | --- bin/addons/sync_client/data/cron.xml 2019-09-05 15:33:40 +0000 |
465 | +++ bin/addons/sync_client/data/cron.xml 2020-01-27 10:41:32 +0000 |
466 | @@ -31,13 +31,14 @@ |
467 | <record id="ir_cron_wal" model="ir.cron"> |
468 | <field name="function">sent_continuous_backup_bg</field> |
469 | <field name="user_id">1</field> |
470 | - <field name="name">Sent Continuous Backup</field> |
471 | + <field name="name">Send Continuous Backup</field> |
472 | <field name="interval_type">days</field> |
473 | <field eval="-1" name="numbercall"/> |
474 | <field eval="5" name="priority"/> |
475 | <field eval="0" name="doall"/> |
476 | <field eval="1" name="active"/> |
477 | <field eval="1" name="interval_number"/> |
478 | + <field name="manual_activation" eval="False" /> |
479 | <field name="model">backup.config</field> |
480 | </record> |
481 | |
482 | |
483 | === modified file 'bin/addons/sync_client/sync_client.py' |
484 | --- bin/addons/sync_client/sync_client.py 2019-11-07 16:10:38 +0000 |
485 | +++ bin/addons/sync_client/sync_client.py 2020-01-27 10:41:32 +0000 |
486 | @@ -492,7 +492,7 @@ |
487 | 'max_update' : fields.integer('Max Update Sequence', readonly=True), |
488 | 'message_to_send' : fields.function(_get_nb_message_send, method=True, string='Nb message to send', type='integer', readonly=True), |
489 | 'update_to_send' : fields.function(_get_nb_update_send, method=True, string='Nb update to send', type='integer', readonly=True), |
490 | - |
491 | + 'previous_hw': fields.char('Last HW successfully used', size=128, select=True), |
492 | # used to determine which sync rules to use |
493 | # UF-2531: moved this from the RW module to the general sync module |
494 | 'usb_instance_type': fields.selection((('',''),('central_platform','Central Platform'),('remote_warehouse','Remote Warehouse')), string='USB Instance Type'), |
495 | @@ -762,6 +762,8 @@ |
496 | res = proxy.get_model_to_sync(entity.identifier, self._hardware_id) |
497 | if not res[0]: |
498 | raise Exception, res[1] |
499 | + |
500 | + entity.write({'previous_hw': self._hardware_id}, context=context) |
501 | check_md5(res[2], res[1], _('method set_rules')) |
502 | self.pool.get('sync.client.rule').save(cr, uid, res[1], context=context) |
503 | |
504 | |
505 | === modified file 'bin/tools/misc.py' |
506 | --- bin/tools/misc.py 2019-09-24 14:34:16 +0000 |
507 | +++ bin/tools/misc.py 2020-01-27 10:41:32 +0000 |
508 | @@ -33,6 +33,7 @@ |
509 | import socket |
510 | import sys |
511 | import threading |
512 | + |
513 | import time |
514 | import warnings |
515 | import zipfile |
516 | @@ -71,6 +72,7 @@ |
517 | # We include the *Base ones just in case, currently they seem to be subclasses of the _* ones. |
518 | SKIPPED_ELEMENT_TYPES = (etree._Comment, etree._ProcessingInstruction, etree.CommentBase, etree.PIBase) |
519 | |
520 | +rsync_lock = threading.RLock() |
521 | |
522 | # initialize a database with base/base.sql |
523 | def init_db(cr): |
524 | @@ -161,6 +163,23 @@ |
525 | new_path = '%s/' % new_path |
526 | return new_path |
527 | |
528 | +def force_wal_generation(cr, wal_path): |
529 | + cr.execute('select * from pg_xlogfile_name_offset(pg_switch_xlog())') |
530 | + file_name, offset = cr.fetchone() |
531 | + _logger.warn('WAL generation forced %s %s' % (file_name, offset)) |
532 | + if not offset or not file_name: |
533 | + return True |
534 | + zip_new_wal = os.path.join(wal_path, '%s.7z' % file_name) |
535 | + wait = 0 |
536 | + while True: |
537 | + if os.path.exists(zip_new_wal): |
538 | + return True |
539 | + wait += 1 |
540 | + if wait > 30: |
541 | + _logger.warn('7z Wal %s not found' % zip_new_wal) |
542 | + return False |
543 | + time.sleep(2) |
544 | + |
545 | def sent_to_remote(local_path, config_dir=False, remote_user=False, remote_host=False, remote_dir=False): |
546 | |
547 | exe_dir = os.path.join(os.path.normcase(os.path.abspath(config['root_path'])), 'rsync') |
548 | @@ -187,11 +206,12 @@ |
549 | |
550 | remote_path = '%s/' % remote_dir |
551 | try: |
552 | - command = [sync, '--remove-source-files', '--partial-dir=.rsync-partial', '-a', '-e', '"%s" -F "%s"'%(ssh, sshconfig), '--include=*/', '--include=*7z', '--exclude=*', path_to_cygwin(local_path), "%s@%s:%s" % (remote_user, remote_host, remote_path)] |
553 | - _logger.info(' '.join(command)) |
554 | - subprocess.check_output(command, stderr=subprocess.STDOUT) |
555 | - _logger.info('Rsync ends') |
556 | - return True |
557 | + with rsync_lock: |
558 | + command = [sync, '--remove-source-files', '--partial-dir=.rsync-partial', '-a', '-e', '"%s" -F "%s"'%(ssh, sshconfig), '--include=*/', '--include=*7z', '--exclude=*', path_to_cygwin(local_path), "%s@%s:%s" % (remote_user, remote_host, remote_path)] |
559 | + _logger.info(' '.join(command)) |
560 | + subprocess.check_output(command, stderr=subprocess.STDOUT) |
561 | + _logger.info('Rsync ends') |
562 | + return True |
563 | except subprocess.CalledProcessError, e: |
564 | _logger.error('rsync %s' % e.output) |
565 | raise Exception(e.output) |
566 | @@ -1861,14 +1881,28 @@ |
567 | self.path = path |
568 | self.delete = delete |
569 | |
570 | -def use_prod_sync(cr): |
571 | +def use_prod_sync(cr, uid=False, pool=False): |
572 | cr.execute('''SELECT host, database |
573 | FROM sync_client_sync_server_connection''') |
574 | host, database = cr.fetchone() |
575 | |
576 | if host and database and database.strip() == 'SYNC_SERVER' and \ |
577 | ('sync.unifield.net' in host.lower() or '212.95.73.129' in host): |
578 | - return True |
579 | + if uid and pool: |
580 | + connection = pool.get('sync.client.sync_server_connection') |
581 | + entity_obj = pool.get('sync.client.entity') |
582 | + if not connection or not entity_obj: |
583 | + return False |
584 | + entity = entity_obj.get_entity(cr, uid) |
585 | + if connection.is_connected: |
586 | + # check HW on the sync server |
587 | + proxy = pool.get("sync.client.sync_server_connection").get_connection(cr, uid, "sync.server.entity") |
588 | + res = proxy.get_entity(entity.identifier, entity._hardware_id) |
589 | + if res and res[0]: |
590 | + return True |
591 | + return entity._hardware_id == entity.previous_hw |
592 | + else: |
593 | + return True |
594 | |
595 | return False |
596 | |
597 | |
598 | === modified file 'bin/unifield-version.txt' |
599 | --- bin/unifield-version.txt 2020-01-21 11:12:03 +0000 |
600 | +++ bin/unifield-version.txt 2020-01-27 10:41:32 +0000 |
601 | @@ -72,5 +72,9 @@ |
602 | 1c581f08bd22b9eced1e56a2579c493c 2019-09-13 10:00:00 UF14.0 |
603 | ef09c0d9b821cd261751160f19c14fe4 2019-10-08 11:00:00 UF14.1 |
604 | 915fa0cc07178db7ac7ea9b26d4e2099 2019-12-06 11:00:00 UF15.0 |
605 | +<<<<<<< TREE |
606 | 23667883c71ea98cb25fa79e00ac1a49 2020-01-13 16:00:00 UF15.1 |
607 | 856a56ee10ded2cc9a2aba457ff199a1 2020-01-21 12:00:00 UF15.2 |
608 | +======= |
609 | +915fa0cc07178db7ac7ea9b26d4e2088 2019-12-30 11:00:00 UF16cont.0 |
610 | +>>>>>>> MERGE-SOURCE |