Merge lp:~unifield-team/unifield-wm/uf-28-warning-rw into lp:unifield-wm

Proposed by jftempo
Status: Merged
Merged at revision: 2458
Proposed branch: lp:~unifield-team/unifield-wm/uf-28-warning-rw
Merge into: lp:unifield-wm
Diff against target: 311 lines (+92/-75)
6 files modified
delivery_mechanism/delivery_mechanism.py (+2/-0)
delivery_mechanism/wizard/enter_reason.py (+0/-1)
msf_outgoing/msf_outgoing_view.xml (+4/-4)
order_types/stock.py (+75/-64)
stock_override/stock.py (+4/-0)
stock_override/stock_view.xml (+7/-6)
To merge this branch: bzr merge lp:~unifield-team/unifield-wm/uf-28-warning-rw
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+254245@code.launchpad.net
To post a comment you must log in.
2456. By Duy VO

US-28: Changed the warning message to be clearer.

2457. By Duy VO

US-28: Removed the deco call

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'delivery_mechanism/delivery_mechanism.py'
2--- delivery_mechanism/delivery_mechanism.py 2015-03-23 10:11:31 +0000
3+++ delivery_mechanism/delivery_mechanism.py 2015-03-26 15:30:31 +0000
4@@ -24,6 +24,7 @@
5 from osv import osv, fields
6 from osv.orm import browse_record
7 from tools.translate import _
8+from order_types.stock import check_rw_warning
9
10
11 class stock_picking_processing_info(osv.osv_memory):
12@@ -1294,6 +1295,7 @@
13 def _manual_create_rw_messages(self, cr, uid, context=None):
14 return
15
16+ @check_rw_warning
17 def enter_reason(self, cr, uid, ids, context=None):
18 '''
19 open reason wizard
20
21=== modified file 'delivery_mechanism/wizard/enter_reason.py'
22--- delivery_mechanism/wizard/enter_reason.py 2014-11-04 09:13:14 +0000
23+++ delivery_mechanism/wizard/enter_reason.py 2015-03-26 15:30:31 +0000
24@@ -25,7 +25,6 @@
25
26 import netsvc
27
28-
29 class enter_reason(osv.osv_memory):
30 '''
31 wizard called to split a memory stock move from create picking wizard
32
33=== modified file 'msf_outgoing/msf_outgoing_view.xml'
34--- msf_outgoing/msf_outgoing_view.xml 2015-03-09 13:15:15 +0000
35+++ msf_outgoing/msf_outgoing_view.xml 2015-03-26 15:30:31 +0000
36@@ -251,7 +251,7 @@
37 <field name="inactive_product" invisible="1" />
38 <field name="inactive_error" attrs="{'invisible': [('inactive_product', '=', False)]}" />
39 <field name="pt_created" invisible="1" />
40- <button name="call_cancel_wizard" type="object" string="Cancel" states="draft,assigned,confirmed" icon="gtk-del" attrs="{'invisible': [('pt_created', '=', True)]}" />
41+ <button name="call_cancel_wizard" type="object" string="Cancel" states="draft,assigned,confirmed" icon="gtk-del" attrs="{'invisible': [('pt_created', '=', True)]}" context="{'from_button': True}" />
42 </tree>
43 <form string="Stock Moves">
44 <group colspan="2" col="4">
45@@ -336,8 +336,8 @@
46 <field name="line_state" readonly="1" attrs="{'invisible': [('state', '!=', 'draft')]}" nolabel="1" />
47 <field name="flow_type" />
48 <group colspan="1" col="1">
49- <button name="call_cancel_wizard" type="object" states="draft" string="_Cancel Picking" icon="gtk-cancel"/>
50- <button name="button_cancel" states="assigned,confirmed" string="_Cancel Picking" icon="gtk-cancel"/>
51+ <button name="call_cancel_wizard" type="object" states="draft" string="_Cancel Picking" icon="gtk-cancel" context="{'from_button': True}" />
52+ <button name="button_cancel" states="assigned,confirmed" string="_Cancel Picking" icon="gtk-cancel" context="{'from_button': True}" />
53 </group>
54 <field name="has_draft_moves" invisible="1" />
55 <button name="action_confirm_moves" states="draft" string="Confirm" type="object" icon="gtk-apply" attrs="{'invisible': [('has_draft_moves', '=', False)]}"/>
56@@ -1067,7 +1067,7 @@
57 <group col="12" colspan="4">
58 <field name="state" readonly="1"/>
59 <field name="flow_type" />
60- <button name="button_cancel" states="assigned,confirmed,draft" string="_Cancel Picking" icon="gtk-cancel"/>
61+ <button name="button_cancel" states="assigned,confirmed,draft" string="_Cancel Picking" icon="gtk-cancel" context="{'from_button': True}" />
62 <button name="action_assign" states="draft,confirmed" string="Check Availability" type="object" icon="gtk-find"/>
63 <button name="force_assign" states="confirmed" string="Force Availability" type="object" icon="gtk-jump-to"/>
64 <button name="packing" states="assigned" string="Pack..." type="object" icon="gtk-go-forward"/>
65
66=== modified file 'order_types/stock.py'
67--- order_types/stock.py 2015-03-10 15:17:55 +0000
68+++ order_types/stock.py 2015-03-26 15:30:31 +0000
69@@ -23,72 +23,83 @@
70 from order_types import ORDER_PRIORITY, ORDER_CATEGORY
71 from tools.translate import _
72
73-
74+# US-28: Refactored the method decoration to be reused for both RW and CP
75+def cp_rw_warning(func, rw_flag, *args, **kwargs):
76+ self = args[0]
77+ kw_keys = kwargs.keys()
78+
79+ from_button = False
80+ if kwargs.get('context'):
81+ from_button = kwargs['context'].get('from_button')
82+ elif len(args) > 4 and isinstance(args[4], dict ):
83+ from_button = args[4].get('from_button')
84+
85+ from_cp_check = kwargs.get('context', {}).get('from_cp_check')
86+ wargs = kwargs.get('context', {}).get('callback', {}) or kwargs
87+ if from_button and not from_cp_check:
88+ cr = args[1]
89+ uid = args[2]
90+ ids = args[3]
91+ pick_obj = self.pool.get('stock.picking')
92+ rw_type = hasattr(pick_obj, '_get_usb_entity_type') and pick_obj._get_usb_entity_type(cr, uid) or False
93+
94+ text = "remote warehouse"
95+ this_instance = "central platform"
96+ if rw_flag == pick_obj.REMOTE_WAREHOUSE:
97+ text = "central platform"
98+ this_instance = "remote warehouse"
99+
100+ if rw_type == rw_flag:
101+ name = """This action should only be performed at the %s instance! Are you sure to proceed it at this %s instance?""" %(text, this_instance)
102+ model = 'confirm'
103+ step = 'default'
104+ question = name
105+ clazz = self._name
106+ args = [ids]
107+ kwargs = {}
108+ wiz_obj = self.pool.get('wizard')
109+ # open the selected wizard
110+ callback = {
111+ 'clazz': clazz,
112+ 'func': func.__name__,
113+ 'args': args,
114+ 'kwargs': kwargs,
115+ 'from_cp_check': True,
116+ }
117+ tmp_context = dict(kwargs.get('context', {}),
118+ question=question,
119+ callback=callback,
120+ from_cp_check=True)
121+
122+
123+ res = wiz_obj.open_wizard(cr, uid, ids,
124+ name=name,
125+ model=model,
126+ step=step,
127+ context=tmp_context)
128+ return res
129+ new_kwargs = {}
130+ for kwk in kw_keys:
131+ if kwk in wargs:
132+ new_kwargs[kwk] = wargs[kwk]
133+
134+ res = func(*args, **new_kwargs)
135+ if from_cp_check and not (isinstance(res, dict) and res.get('res.model') != 'wizard'):
136+ return {'type': 'ir.actions.act_window_close'}
137+ else:
138+ return res
139+
140+# US-28: Refactored the method decoration to be reused for both RW and CP warning
141 def check_cp_rw(func):
142 def decorated(*args, **kwargs):
143- self = args[0]
144- kw_keys = kwargs.keys()
145-
146- from_button = False
147- if kwargs.get('context'):
148- from_button = kwargs['context'].get('from_button')
149- elif len(args) > 4 and isinstance(args[4], dict ):
150- from_button = args[4].get('from_button')
151-
152- from_cp_check = kwargs.get('context', {}).get('from_cp_check')
153- wargs = kwargs.get('context', {}).get('callback', {}) or kwargs
154- if from_button and not from_cp_check:
155- cr = args[1]
156- uid = args[2]
157- ids = args[3]
158- pick_obj = self.pool.get('stock.picking')
159- rw_type = hasattr(pick_obj, '_get_usb_entity_type') and \
160- pick_obj._get_usb_entity_type(cr, uid) or False
161-
162- if rw_type == self.pool.get('stock.picking').CENTRAL_PLATFORM:
163- name = """This action should only be performed at the Remote
164- Warehouse instance! Are you sure to proceed it at this main instance?"""
165- model = 'confirm'
166- step = 'default'
167- question = name
168- clazz = self._name
169- args = [ids]
170- kwargs = {}
171- wiz_obj = self.pool.get('wizard')
172- # open the selected wizard
173- callback = {
174- 'clazz': clazz,
175- 'func': func.__name__,
176- 'args': args,
177- 'kwargs': kwargs,
178- 'from_cp_check': True,
179- }
180- tmp_context = dict(kwargs.get('context', {}),
181- question=question,
182- callback=callback,
183- from_cp_check=True)
184-
185-
186- res = wiz_obj.open_wizard(cr, uid, ids,
187- name=name,
188- model=model,
189- step=step,
190- context=tmp_context)
191- return res
192-
193- new_kwargs = {}
194- for kwk in kw_keys:
195- if kwk in wargs:
196- new_kwargs[kwk] = wargs[kwk]
197-
198- res = func(*args, **new_kwargs)
199- if from_cp_check and not (isinstance(res, dict) and res.get('res.model') != 'wizard'):
200- return {'type': 'ir.actions.act_window_close'}
201- else:
202- return res
203-
204- return decorated
205-
206+ return cp_rw_warning(func, "central_platform", *args, **kwargs)
207+ return decorated
208+
209+# US-28: Refactored the method decoration to be reused for both RW and CP warning
210+def check_rw_warning(func):
211+ def decorated(*args, **kwargs):
212+ return cp_rw_warning(func, "remote_warehouse", *args, **kwargs)
213+ return decorated
214
215 class stock_move(osv.osv):
216 _name = 'stock.move'
217
218=== modified file 'stock_override/stock.py'
219--- stock_override/stock.py 2015-03-24 08:53:36 +0000
220+++ stock_override/stock.py 2015-03-26 15:30:31 +0000
221@@ -34,6 +34,7 @@
222 import decimal_precision as dp
223 from msf_partner import PARTNER_TYPE
224 from order_types.stock import check_cp_rw
225+from order_types.stock import check_rw_warning
226
227
228 #----------------------------------------------------------
229@@ -588,6 +589,8 @@
230 def cancel_assign(self, cr, uid, ids, *args, **kwargs):
231 return super(stock_picking, self).cancel_assign(cr, uid, ids)
232
233+
234+ @check_rw_warning
235 def call_cancel_wizard(self, cr, uid, ids, context=None):
236 '''
237 Call the wizard of cancelation (ask user if he wants to resource goods)
238@@ -1318,6 +1321,7 @@
239 'has_to_be_resourced': False,
240 }
241
242+ @check_rw_warning
243 def call_cancel_wizard(self, cr, uid, ids, context=None):
244 '''
245 Call the wizard to ask user if he wants to re-source the need
246
247=== modified file 'stock_override/stock_view.xml'
248--- stock_override/stock_view.xml 2015-03-19 09:01:18 +0000
249+++ stock_override/stock_view.xml 2015-03-26 15:30:31 +0000
250@@ -369,7 +369,7 @@
251 <button name="call_cancel_wizard" icon="gtk-del" string="Cancel &amp; Resource" type="object"
252 confirm="Do you really want to delete selected record ?"
253 attrs="{'invisible': ['|', ('from_wkf', '=', False), ('fake_state', 'in', ('cancel', 'done'))]}"
254- context="{'from_int': 1}"/>
255+ context="{'from_int': 1, 'from_button': True}"/>
256 </tree>
257
258 <form string="Stock Moves">
259@@ -465,7 +465,7 @@
260 <field name="state" readonly="1"/>
261 <field name="has_draft_moves" invisible="1" />
262 <!-- <button name="return_to_state" string="Return to initial state" states="import" icon="gtk-execute" type="object" />-->
263- <button name="call_cancel_wizard" states="assigned,confirmed,draft" string="_Cancel" icon="gtk-cancel" type="object" />
264+ <button name="call_cancel_wizard" states="assigned,confirmed,draft" string="_Cancel" icon="gtk-cancel" type="object" context="{'from_button': True}"/>
265 <button name="draft_force_assign" states="draft,confirmed,assigned" string="Confirm" type="object" icon="gtk-apply" attrs="{'invisible': ['|', '&amp;', ('state', 'in', ['done', 'cancel', 'import']), ('state', '!=', 'draft'), ('has_draft_moves', '=', False)]}" />
266 <button name="action_assign" states="confirmed,assigned" string="Check Availability" type="object" icon="gtk-find" context="{'from_button': True}"/>
267 <button name="force_assign" states="confirmed,assigned" string="Force Availability" type="object" icon="gtk-jump-to" context="{'from_button': True}" />
268@@ -617,7 +617,7 @@
269 <field name="price_changed" invisible="1" />
270 <button name="get_price_changed" type="object" string="Price changed" icon="terp-dolar_ok!" attrs="{'invisible': ['|', ('price_changed', '=', False), ('fake_state', '!=', 'done')]}" />
271 <field name="from_wkf" invisible="1" />
272- <button name="call_cancel_wizard" type="object" string="Cancel" attrs="{'invisible': ['|', ('from_wkf', '=', False), ('fake_state', 'in', ('cancel', 'done'))]}" icon="gtk-del" />
273+ <button name="call_cancel_wizard" type="object" string="Cancel" attrs="{'invisible': ['|', ('from_wkf', '=', False), ('fake_state', 'in', ('cancel', 'done'))]}" icon="gtk-del" context="{'from_button': True}" />
274 </tree>
275 <form string="Stock Moves">
276 <group colspan="2" col="4">
277@@ -707,7 +707,7 @@
278 string="Cancel"
279 type="object"
280 icon="gtk-cancel"
281- context="{'cancel_type': 'update_out'}"
282+ context="{'cancel_type': 'update_out', 'from_button': True}"
283 confirm="Warning, you are going to Cancel!"
284 />
285 <field name="from_wkf_sourcing" invisible="1" />
286@@ -717,6 +717,7 @@
287 string="Cancel &amp; Resource"
288 type="object"
289 icon="gtk-cancel"
290+ context="{'from_button': True}"
291 confirm="Warning, you are going to Cancel and Resource!"
292 />
293
294@@ -906,7 +907,7 @@
295 <field name="inactive_product" invisible="1" />
296 <field name="inactive_error" attrs="{'invisible': [('inactive_product', '=', False)]}" />
297 <button name="%(stock.action_partial_move_server)d" string="Process" type="action" states="confirmed,assigned" icon="gtk-go-forward" invisible="1"/>
298- <button name="call_cancel_wizard" type="object" string="Cancel" states="draft,assigned,confirmed" icon="gtk-del" />
299+ <button name="call_cancel_wizard" type="object" string="Cancel" states="draft,assigned,confirmed" icon="gtk-del" context="{'from_button': True}" />
300 </tree>
301 <form string="Stock Moves">
302 <group colspan="2" col="4">
303@@ -996,7 +997,7 @@
304 <button name="set_delivered" icon="gtk-apply" type="object" string="Confirm Delivery" attrs="{'invisible': ['|', '|', '|', ('type', '!=', 'out'), ('subtype', '!=', 'standard'), ('state', '!=', 'done'), ('delivered', '=', True)]}"/>
305 <field name="cross_docking_ok" invisible="1"/>
306 <!--<button name="button_cancel" states="assigned,confirmed,draft" string="_Cancel" icon="gtk-cancel"/>-->
307- <button name="call_cancel_wizard" states="assigned,confirmed,draft" string="_Cancel" icon="gtk-cancel" type="object" />
308+ <button name="call_cancel_wizard" states="assigned,confirmed,draft" string="_Cancel" icon="gtk-cancel" type="object" context="{'from_button': True}" />
309 <button name="draft_force_assign" states="draft" string="Confirm" type="object" icon="gtk-apply"/>
310 <button name="action_assign" states="confirmed,assigned" string="Check Availability" type="object" icon="gtk-find" context="{'from_button': True}" />
311 <button name="convert_to_pick" states="draft,confirmed,assigned" string="Convert to Picking Ticket" type="object" icon="gtk-convert" context="{'from_button': True}" />

Subscribers

People subscribed via source and target branches