Merge lp:~dorian-kemps/unifield-server/US-9509 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 6281
Proposed branch: lp:~dorian-kemps/unifield-server/US-9509
Merge into: lp:unifield-server
Diff against target: 54 lines (+23/-5)
1 file modified
bin/addons/product_attributes/product_attributes.py (+23/-5)
To merge this branch: bzr merge lp:~dorian-kemps/unifield-server/US-9509
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+424506@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/product_attributes/product_attributes.py'
2--- bin/addons/product_attributes/product_attributes.py 2022-04-01 08:58:53 +0000
3+++ bin/addons/product_attributes/product_attributes.py 2022-06-13 12:48:06 +0000
4@@ -1876,9 +1876,15 @@
5 Re-activate product.
6 '''
7 wiz_obj = self.pool.get('product.ask.activate.wizard')
8+ data_obj = self.pool.get('ir.model.data')
9
10 instance_level = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.instance_id.level
11+ hq_status = data_obj.get_object_reference(cr, uid, 'product_attributes', 'int_3')[1]
12+ itc_status = data_obj.get_object_reference(cr, uid, 'product_attributes', 'int_1')[1]
13+ esc_status = data_obj.get_object_reference(cr, uid, 'product_attributes', 'int_2')[1]
14+ local_status = data_obj.get_object_reference(cr, uid, 'product_attributes', 'int_4')[1]
15 for product in self.browse(cr, uid, ids, context=context):
16+ vals = {'active': True}
17 if product.active:
18 raise osv.except_osv(_('Error'), _('The product [%s] %s is already active.') % (product.default_code, product.name))
19 if product.standard_ok == 'non_standard_local':
20@@ -1894,9 +1900,12 @@
21 }
22 elif instance_level == 'project':
23 raise osv.except_osv(_('Error'), _('%s activation is not allowed at project') % (product.default_code,))
24-
25- real_uid = hasattr(uid, 'realUid') and uid.realUid or uid
26- self.write(cr, real_uid, ids, {'active': True}, context=context)
27+ if (instance_level == 'section' and (product.international_status.id in (hq_status, itc_status, esc_status) or
28+ (product.oc_subscription and product.state_ud in ('valid', 'outdated', 'discontinued')))) or \
29+ (instance_level == 'coordo' and product.international_status.id == local_status):
30+ vals.update({'state': data_obj.get_object_reference(cr, uid, 'product_attributes', 'status_1')[1]})
31+ real_uid = hasattr(uid, 'realUid') and uid.realUid or uid
32+ self.write(cr, real_uid, product.id, vals, context=context)
33
34 return True
35
36@@ -3194,8 +3203,17 @@
37 if context is None:
38 context = {}
39
40- prod_id = self.browse(cr, uid, ids[0], context=context).product_id.id
41- self.pool.get('product.product').write(cr, uid, prod_id, {'active': True}, context=context)
42+ data_obj = self.pool.get('ir.model.data')
43+
44+ prod = self.browse(cr, uid, ids[0], fields_to_fetch=['product_id'], context=context).product_id
45+ local_status = data_obj.get_object_reference(cr, uid, 'product_attributes', 'int_4')[1]
46+
47+ vals = {'active': True}
48+ # US-9509: The flow can only go through there if the instance is coordo
49+ if prod.international_status.id == local_status:
50+ vals.update({'state': data_obj.get_object_reference(cr, uid, 'product_attributes', 'status_1')[1]})
51+
52+ self.pool.get('product.product').write(cr, uid, prod.id, vals, context=context)
53
54 return {'type': 'ir.actions.act_window_close'}
55

Subscribers

People subscribed via source and target branches