@@ -196,3 +196,90 @@ def test_09_set_compute_error_on_type_change(self):
196196 "Changing the type of a field is not yet supported" ,
197197 ):
198198 field .set_compute ()
199+
200+ def test_10_create_with_ui_context_returns_reload_action (self ):
201+ """Test that create with UI context returns reload action"""
202+ # Simulate UI context with params
203+ context = {"params" : {"model" : "ir.model.fields" , "view_type" : "form" }}
204+ result = (
205+ self .field_model .with_context (context )
206+ .create (
207+ {
208+ "name" : "x_cst_grp_reload_test" ,
209+ "model_id" : self .model_id .id ,
210+ "field_description" : "Reload Test" ,
211+ "ttype" : "char" ,
212+ "state" : "manual" ,
213+ "target_type" : "grp" ,
214+ "field_category" : "cst" ,
215+ }
216+ )
217+ )
218+
219+ # When created in UI context with target_type, should return reload action
220+ self .assertIsInstance (result , dict )
221+ self .assertEqual (result .get ("type" ), "ir.actions.client" )
222+ self .assertEqual (result .get ("tag" ), "reload" )
223+
224+ def test_11_create_without_ui_context_returns_recordset (self ):
225+ """Test that create without UI context returns normal recordset"""
226+ # Create without params in context (programmatic call)
227+ result = self .field_model .create (
228+ {
229+ "name" : "x_cst_grp_no_reload" ,
230+ "model_id" : self .model_id .id ,
231+ "field_description" : "No Reload Test" ,
232+ "ttype" : "char" ,
233+ "state" : "manual" ,
234+ "target_type" : "grp" ,
235+ "field_category" : "cst" ,
236+ }
237+ )
238+
239+ # Should return recordset, not action dict
240+ self .assertEqual (result ._name , "ir.model.fields" )
241+ self .assertTrue (result .id )
242+
243+ def test_12_write_with_ui_context_returns_reload_action (self ):
244+ """Test that write with UI context returns reload action"""
245+ field = self .field_model .create (
246+ {
247+ "name" : "x_cst_grp_write_test" ,
248+ "model_id" : self .model_id .id ,
249+ "field_description" : "Write Test" ,
250+ "ttype" : "char" ,
251+ "state" : "manual" ,
252+ "target_type" : "grp" ,
253+ "field_category" : "cst" ,
254+ }
255+ )
256+
257+ # Update with UI context
258+ context = {"params" : {"model" : "ir.model.fields" , "view_type" : "form" }}
259+ result = field .with_context (context ).write ({"field_description" : "Updated Description" })
260+
261+ # Should return reload action
262+ self .assertIsInstance (result , dict )
263+ self .assertEqual (result .get ("type" ), "ir.actions.client" )
264+ self .assertEqual (result .get ("tag" ), "reload" )
265+
266+ def test_13_write_without_ui_context_returns_boolean (self ):
267+ """Test that write without UI context returns boolean"""
268+ field = self .field_model .create (
269+ {
270+ "name" : "x_cst_grp_write_no_reload" ,
271+ "model_id" : self .model_id .id ,
272+ "field_description" : "Write No Reload" ,
273+ "ttype" : "char" ,
274+ "state" : "manual" ,
275+ "target_type" : "grp" ,
276+ "field_category" : "cst" ,
277+ }
278+ )
279+
280+ # Update without UI context (programmatic call)
281+ result = field .write ({"field_description" : "Updated Without Reload" })
282+
283+ # Should return boolean True
284+ self .assertTrue (result )
285+ self .assertIsInstance (result , bool )
0 commit comments