File tree Expand file tree Collapse file tree 2 files changed +23
-10
lines changed Expand file tree Collapse file tree 2 files changed +23
-10
lines changed Original file line number Diff line number Diff line change @@ -235,13 +235,8 @@ def _compute_graph_jobs_count(self):
235235 record .graph_jobs_count = count_per_graph_uuid .get (record .graph_uuid ) or 0
236236
237237 @api .model_create_multi
238+ @api .private
238239 def create (self , vals_list ):
239- if self .env .context .get ("_job_edit_sentinel" ) is not self .EDIT_SENTINEL :
240- # Prevent to create a queue.job record "raw" from RPC.
241- # ``with_delay()`` must be used.
242- raise exceptions .AccessError (
243- _ ("Queue jobs must be created by calling 'with_delay()'." )
244- )
245240 return super (
246241 QueueJob ,
247242 self .with_context (mail_create_nolog = True , mail_create_nosubscribe = True ),
Original file line number Diff line number Diff line change 33
44from odoo import exceptions
55from odoo .tests import common
6+ from odoo .tools import mute_logger
67
78
8- class TestJobWriteProtected (common .TransactionCase ):
9+ class TestJobCreatePrivate (common .HttpCase ):
910 def test_create_error (self ):
10- with self .assertRaises (exceptions .AccessError ):
11- self .env ["queue.job" ].create (
12- {"uuid" : "test" , "model_name" : "res.partner" , "method_name" : "write" }
11+ self .authenticate ("admin" , "admin" )
12+ with self .assertRaises (common .JsonRpcException ) as cm , mute_logger ("odoo.http" ):
13+ self .make_jsonrpc_request (
14+ "/web/dataset/call_kw" ,
15+ params = {
16+ "model" : "queue.job" ,
17+ "method" : "create" ,
18+ "args" : [],
19+ "kwargs" : {
20+ "method_name" : "write" ,
21+ "model_name" : "res.partner" ,
22+ "uuid" : "test" ,
23+ },
24+ },
25+ headers = {
26+ "Cookie" : f"session_id={ self .session .sid } ;" ,
27+ },
1328 )
29+ self .assertEqual ("odoo.exceptions.AccessError" , str (cm .exception ))
1430
31+
32+ class TestJobWriteProtected (common .TransactionCase ):
1533 def test_write_protected_field_error (self ):
1634 job_ = self .env ["res.partner" ].with_delay ().create ({"name" : "test" })
1735 db_job = job_ .db_record ()
You can’t perform that action at this time.
0 commit comments