Merge lp:~unifield-team/unifield-server/us-1497 into lp:unifield-server

Proposed by Quentin THEURET @Amaris
Status: Merged
Merged at revision: 3861
Proposed branch: lp:~unifield-team/unifield-server/us-1497
Merge into: lp:unifield-server
Diff against target: 72 lines (+23/-4)
2 files modified
bin/addons/msf_profile/msf_profile.py (+13/-3)
bin/service/security.py (+10/-1)
To merge this branch: bzr merge lp:~unifield-team/unifield-server/us-1497
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+300329@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/msf_profile/msf_profile.py'
2--- bin/addons/msf_profile/msf_profile.py 2016-06-30 20:39:20 +0000
3+++ bin/addons/msf_profile/msf_profile.py 2016-07-18 14:07:23 +0000
4@@ -31,6 +31,7 @@
5
6 class patch_scripts(osv.osv):
7 _name = 'patch.scripts'
8+ _logger = logging.getLogger('patch_scripts')
9
10 _columns = {
11 'model': fields.text(string='Model', required=True),
12@@ -48,8 +49,16 @@
13 for ps in ps_obj.read(cr, uid, ps_ids, ['model', 'method']):
14 method = ps['method']
15 model_obj = self.pool.get(ps['model'])
16- getattr(model_obj, method)(cr, uid, *a, **b)
17- self.write(cr, uid, [ps['id']], {'run': True})
18+ try:
19+ getattr(model_obj, method)(cr, uid, *a, **b)
20+ self.write(cr, uid, [ps['id']], {'run': True})
21+ except Exception as e:
22+ err_msg = 'Error with the patch scripts %s.%s :: %s' % (ps['model'], ps['method'], e)
23+ self._logger.error(err_msg)
24+ raise osv.except_osv(
25+ 'Error',
26+ err_msg,
27+ )
28
29 def us_993_patch(self, cr, uid, *a, **b):
30 # set no_update to True on USB group_type not to delete it on
31@@ -653,8 +662,9 @@
32 if setup_br:
33 sale_percent = 1 + (setup_br.sale_price/100.00)
34
35+
36 sql = """UPDATE product_template SET standard_price = 1.00, list_price = %s WHERE standard_price = 0.00"""
37- cr.execute(sql, (sale_percent,))
38+ cr.execute(sql, (sale_percent, ))
39 return True
40
41 patch_scripts()
42
43=== modified file 'bin/service/security.py'
44--- bin/service/security.py 2016-05-25 09:01:14 +0000
45+++ bin/service/security.py 2016-07-18 14:07:23 +0000
46@@ -54,6 +54,8 @@
47 def login(db, login, password):
48 cr = pooler.get_db_only(db).cursor()
49 nb = _get_number_modules(cr, testlogin=True)
50+ cr.execute("SELECT count(id) FROM patch_scripts WHERE run = \'f\'")
51+ patch_failed = cr.fetchone()
52 to_update = False
53 if not nb:
54 to_update = updater.test_do_upgrade(cr)
55@@ -63,9 +65,16 @@
56 kwargs={'threaded': True})
57 s.start()
58 raise Exception("ServerUpdate: Server is updating modules ...")
59+
60+
61 pool = pooler.get_pool(db)
62 user_obj = pool.get('res.users')
63- return user_obj.login(db, login, password)
64+ user_res = user_obj.login(db, login, password)
65+
66+ if user_res != 1 and patch_failed[0]:
67+ raise Exception("PatchFailed: A script during upgrade has failed. Login is forbidden. Please contact your administrator")
68+
69+ return user_res
70
71 def check_super(passwd):
72 if passwd == tools.config['admin_passwd']:

Subscribers

People subscribed via source and target branches

to all changes: