@@ -24,6 +24,17 @@ def _get_ref(self, cursor, uid, context=None):
2424 res = obj .read (cursor , uid , ids , ['model' , 'name' ], context )
2525 return [(r ['model' ], r ['name' ]) for r in res ]
2626
27+ def update_poweremail_callback_params (self , reference , ids_cbk , model_context , origin_ids , meta , template_id , context ):
28+ model_name , record_id_str = reference .split (',' )
29+ if model_name not in model_context :
30+ model_context [model_name ] = context .copy ()
31+ model_context [model_name ]['pe_callback_origin_ids' ] = {}
32+ record_id = int (record_id_str )
33+ ids_cbk [model_name ] = ids_cbk .get (model_name , []) + [record_id ]
34+ model_context [model_name ]['pe_callback_origin_ids' ][record_id ] = origin_ids
35+ model_context [model_name ]['meta' ][record_id ] = meta
36+ model_context [model_name ]['template_id' ] = template_id
37+
2738 def poweremail_callback (self , cursor , uid , ids , func , vals = None , context = None ):
2839 """Crida el callback callbacks[func] del reference de ids
2940 """
@@ -37,25 +48,32 @@ def poweremail_callback(self, cursor, uid, ids, func, vals=None, context=None):
3748 ('id' , 'in' , ids )
3849 ])
3950 ids_cbk = {}
40- ctx = context .copy ()
41- ctx ['pe_callback_origin_ids' ] = {}
51+ ctx = {}
52+ meta = context .get ('meta' , {})
53+
4254 for line_v in line_vs :
4355 if not line_v ['ref' ]:
4456 continue
45- meta = {}
46- model_name , record_id_str = line_v ['ref' ].split (',' )
47- record_id = int (record_id_str )
48- ids_cbk [model_name ] = ids_cbk .get (model_name , []) + [record_id ]
49- ctx ['pe_callback_origin_ids' ][record_id ] = line_v ['id' ]
50- ctx ['meta' ][record_id ] = meta
51- ctx ['template_id' ] = line_v ['campaign_id.template_id' ]
57+ if line_v ['id' ] in meta :
58+ mail_meta = meta [line_v ['id' ]]
59+ if 'extra_ref' in mail_meta :
60+ self .update_poweremail_callback_params (
61+ mail_meta ['extra_ref' ], ids_cbk , ctx ,
62+ context ['pe_callback_origin_ids' ][line_v ['id' ]],
63+ meta , line_v ['campaign_id.template_id' ], context
64+ )
65+
66+ self .update_poweremail_callback_params (
67+ line_v ['ref' ], ids_cbk , ctx , line_v ['id' ],
68+ meta , line_v ['campaign_id.template_id' ], context
69+ )
5270 for model in ids_cbk :
5371 src = self .pool .get (model )
5472 try :
5573 if vals :
56- getattr (src , self .callbacks [func ])(cursor , uid , ids_cbk [model ], vals , ctx )
74+ getattr (src , self .callbacks [func ])(cursor , uid , ids_cbk [model ], vals , ctx [ model ] )
5775 else :
58- getattr (src , self .callbacks [func ])(cursor , uid , ids_cbk [model ], ctx )
76+ getattr (src , self .callbacks [func ])(cursor , uid , ids_cbk [model ], ctx [ model ] )
5977 except AttributeError :
6078 pass
6179
0 commit comments