@waron97/prbot 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (18) hide show
  1. package/dotenv +85908 -0
  2. package/example.xml +3903 -0
  3. package/index.js +247 -0
  4. package/out/xml_data_for_ML - RISOLUZIONE CONTRATTUALE - Relazioni mancanti: Fasi - Workflow e Fasi - Esiti Consentiti_2026-01-23 09:21:16.xml +3122 -0
  5. package/out/xml_data_for_ML - RISOLUZIONE CONTRATTUALE - Relazioni mancanti: Fasi - Workflow e Fasi - Esiti Consentiti_2026-01-23 09:25:03.xml +3122 -0
  6. package/out/xml_data_for_ML - RISOLUZIONE CONTRATTUALE - Relazioni mancanti: Fasi - Workflow e Fasi - Esiti Consentiti_2026-01-23 09:28:23.xml +3122 -0
  7. package/out/xml_data_for_ML - RISOLUZIONE CONTRATTUALE - Relazioni mancanti: Fasi - Workflow e Fasi - Esiti Consentiti_2026-01-23 09:31:30.xml +3122 -0
  8. package/out/xml_data_for_ML - RISOLUZIONE CONTRATTUALE - Relazioni mancanti: Fasi - Workflow e Fasi - Esiti Consentiti_2026-01-26 22:53:31.xml +3170 -0
  9. package/out/xml_data_for_ML - RISOLUZIONE CONTRATTUALE - Relazioni mancanti: Fasi - Workflow e Fasi - Esiti Consentiti_2026-01-29 09:38:23.xml +3170 -0
  10. package/out/xml_data_for_ML - RISOLUZIONE CONTRATTUALE_2026-01-23 09:21:17.xml +4160 -0
  11. package/out/xml_data_for_ML - RISOLUZIONE CONTRATTUALE_2026-01-23 09:25:05.xml +4160 -0
  12. package/out/xml_data_for_ML - RISOLUZIONE CONTRATTUALE_2026-01-23 09:28:25.xml +4160 -0
  13. package/out/xml_data_for_ML - RISOLUZIONE CONTRATTUALE_2026-01-23 09:31:31.xml +4160 -0
  14. package/out/xml_data_for_ML - RISOLUZIONE CONTRATTUALE_2026-01-26 22:53:34.xml +4208 -0
  15. package/out/xml_data_for_ML - RISOLUZIONE CONTRATTUALE_2026-01-29 09:38:25.xml +4208 -0
  16. package/out/xml_data_for_ML - Taglio Colonna Gas per Morosit/303/240 - Relazioni mancanti: Fasi - Workflow e Fasi - Esiti Consentiti_2026-01-26 22:57:38.xml" +2358 -0
  17. package/out/xml_data_for_ML - Taglio Colonna Gas per Morosit/303/240_2026-01-26 22:57:40.xml" +3667 -0
  18. package/package.json +31 -0
@@ -0,0 +1,3170 @@
1
+ <odoo>
2
+ <data>
3
+ <record id="symple_triplet_phase_A1001_-_Apertura_Wizard_Risoluzione_contrattuale" model="symple.triplet.phase">
4
+ <field name="active">True</field>
5
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C1402_-_Annullamento_Risoluzione_contrattuale_E-CC01-0001'),ref('symple_triplet_phase_result_C1401_-_Risoluzione_contrattuale_OK_E-CC01-0002')])]"/>
6
+ <field name="allowed_process_ids" model="symple.pb.process" eval="[(6, 0, obj().search([('name','in',('ml_cessazioni_point_selection',)),]).ids)]" />
7
+ <field name="child_case">False</field>
8
+ <field name="code"># Available variables:
9
+ # - case_id: the case that just reached this phase
10
+ # - request: allows you to make HTTP requests (method, url, headers, data)
11
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
12
+ # - json_load: allows you to use JSON.load to convert a json into an object
13
+ # - env: Odoo Environment on which the action is triggered
14
+ # - time, datetime, dateutil, timezone: useful Python libraries
15
+ # - float_compare: Odoo function to compare floats based on specific precisions
16
+ # - ValidationError: Warning Exception to use with raise
17
+ # - Command: x2Many commands namespace
18
+ # - OrderedDict: ordered dictionaries
19
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
20
+ # (line = case id, func = phase name)
21
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
22
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
23
+ # To return a result, assign: result = {...}
24
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
25
+ # phase result will not be set.
26
+
27
+
28
+
29
+ </field>
30
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','Customer Care')])" />
31
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
32
+ <field name="is_a_postalizer_phase">False</field>
33
+ <field name="is_compute_refund">False</field>
34
+ <field name="is_dl">False</field>
35
+ <field name="is_needs_child_case">False</field>
36
+ <field name="is_pick_refund_template">False</field>
37
+ <field name="is_process_managed">True</field>
38
+ <field name="is_quote_accepted">False</field>
39
+ <field name="is_quote_sent">False</field>
40
+ <field name="is_timeout">False</field>
41
+ <field name="is_voidable">False</field>
42
+ <field name="name">A1001 - Apertura Wizard Risoluzione contrattuale</field>
43
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
44
+ <field name="is_externally_integrated">False</field>
45
+ <field name="is_process_cancellable_relaunchable">False</field>
46
+ <field name="wizard_info">{"key":"value"}</field>
47
+ <field name="phase_code">F-CC01-0001</field>
48
+ <field name="check_closed_child_tickets">False</field>
49
+ </record>
50
+ <record id="symple_triplet_phase_A1709_-_verifica_compatibilit_" model="symple.triplet.phase">
51
+ <field name="active">True</field>
52
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C404_-_KO_-_Incompatibile_E-CC01-0003'),ref('symple_triplet_phase_result_C2654_-_Processo_Compatibile_E-CC01-0004'),ref('symple_triplet_phase_result_C2639_-_Incompatibilit__Non_bloccante_E-CC01-0005')])]"/>
53
+ <field name="child_case">False</field>
54
+ <field name="code">def main():
55
+ service_point = case_id.service_point_ids[0]
56
+ billing_profile = service_point.billing_profile_id
57
+ asset = service_point.asset(active=False)
58
+
59
+ if not asset:
60
+ asset_id = False
61
+ else:
62
+ asset_id = asset._id
63
+
64
+ (result, incompatible_case_ids) = ( # "OK" | "KO" | "PARTIAL_KO" # List[int]
65
+ case_id.check_compatibility_matrix(
66
+ asset_id=asset_id,
67
+ client_id=case_id.customer_id.user_sequence,
68
+ billing_id=billing_profile.name,
69
+ # external_id -> default a case.ticket_type_id.univocal_code
70
+ )
71
+ )
72
+
73
+ if incompatible_case_ids:
74
+ case_id.write({"incompatible_ticket_ids": incompatible_case_ids})
75
+
76
+ if result in ["OK", "PARTIAL_KO"]:
77
+ case_id.create_matrix_process(
78
+ asset_id=asset_id,
79
+ client_id=case_id.customer_id.user_sequence,
80
+ billing_id=billing_profile.name,
81
+ # external_id -> default a case.ticket_type_id.univocal_code
82
+ )
83
+
84
+ return result
85
+
86
+
87
+ try:
88
+ result = main()
89
+ except Exception as e:
90
+ log(format_exc())
91
+ case_id.write({"error_message": str(e)})
92
+ </field>
93
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
94
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
95
+ <field name="is_a_postalizer_phase">False</field>
96
+ <field name="is_compute_refund">False</field>
97
+ <field name="is_dl">False</field>
98
+ <field name="is_needs_child_case">False</field>
99
+ <field name="is_pick_refund_template">False</field>
100
+ <field name="is_process_managed">False</field>
101
+ <field name="is_quote_accepted">False</field>
102
+ <field name="is_quote_sent">False</field>
103
+ <field name="is_timeout">False</field>
104
+ <field name="is_voidable">False</field>
105
+ <field name="name">A1709 - verifica compatibilità</field>
106
+ <field name="set_result_automatically">from_code</field>
107
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
108
+ <field name="is_externally_integrated">False</field>
109
+ <field name="is_process_cancellable_relaunchable">False</field>
110
+ <field name="wizard_info">{"key":"value"}</field>
111
+ <field name="phase_code">F-CC01-0002</field>
112
+ <field name="check_closed_child_tickets">False</field>
113
+ </record>
114
+ <record id="symple_triplet_phase_A1710_-_Verifica_compatibilit__KO" model="symple.triplet.phase">
115
+ <field name="active">True</field>
116
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C2409_-_KO_Confermato_E-CC01-0006'),ref('symple_triplet_phase_result_C2410_-_OK_Incompatibilit__Gestita_E-CC01-0007')])]"/>
117
+ <field name="child_case">False</field>
118
+ <field name="code"># Available variables:
119
+ # - case_id: the case that just reached this phase
120
+ # - request: allows you to make HTTP requests (method, url, headers, data)
121
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
122
+ # - json_load: allows you to use JSON.load to convert a json into an object
123
+ # - env: Odoo Environment on which the action is triggered
124
+ # - time, datetime, dateutil, timezone: useful Python libraries
125
+ # - float_compare: Odoo function to compare floats based on specific precisions
126
+ # - ValidationError: Warning Exception to use with raise
127
+ # - Command: x2Many commands namespace
128
+ # - OrderedDict: ordered dictionaries
129
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
130
+ # (line = case id, func = phase name)
131
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
132
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
133
+ # To return a result, assign: result = {...}
134
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
135
+ # phase result will not be set.
136
+
137
+
138
+
139
+ </field>
140
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','BOT')])" />
141
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
142
+ <field name="is_a_postalizer_phase">False</field>
143
+ <field name="is_compute_refund">False</field>
144
+ <field name="is_dl">False</field>
145
+ <field name="is_needs_child_case">False</field>
146
+ <field name="is_pick_refund_template">False</field>
147
+ <field name="is_process_managed">False</field>
148
+ <field name="is_quote_accepted">False</field>
149
+ <field name="is_quote_sent">False</field>
150
+ <field name="is_timeout">False</field>
151
+ <field name="is_voidable">False</field>
152
+ <field name="name">A1710 - Verifica compatibilità KO</field>
153
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
154
+ <field name="is_externally_integrated">False</field>
155
+ <field name="is_process_cancellable_relaunchable">False</field>
156
+ <field name="wizard_info">{"key":"value"}</field>
157
+ <field name="phase_code">F-CC01-0003</field>
158
+ <field name="check_closed_child_tickets">False</field>
159
+ </record>
160
+ <record id="symple_triplet_phase_A1672_-_Recupero_dati_a_CRM" model="symple.triplet.phase">
161
+ <field name="active">True</field>
162
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C2365_-_Recupero_Dati_OK_E-CC01-0008'),ref('symple_triplet_phase_result_C1933_-_Recupero_Dati_KO_E-CC01-0009')])]"/>
163
+ <field name="child_case">False</field>
164
+ <field name="code"><![CDATA[# Available variables:
165
+ # - case_id: the case that just reached this phase
166
+ # - request: allows you to make HTTP requests (method, url, headers, data)
167
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
168
+ # - json_load: allows you to use JSON.load to convert a json into an object
169
+ # - env: Odoo Environment on which the action is triggered
170
+ # - time, datetime, dateutil, timezone: useful Python libraries
171
+ # - float_compare: Odoo function to compare floats based on specific precisions
172
+ # - ValidationError: Warning Exception to use with raise
173
+ # - Command: x2Many commands namespace
174
+ # - OrderedDict: ordered dictionaries
175
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
176
+ # (line = case id, func = phase name)
177
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
178
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
179
+ # To return a result, assign: result = {...}
180
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
181
+ # phase result will not be set.
182
+
183
+
184
+ logs = []
185
+
186
+
187
+ def fmt(date):
188
+ return date.strftime("%d/%m/%Y")
189
+
190
+
191
+ def last_day_of_this_month():
192
+ today = datetime.datetime.today()
193
+ first_of_next_month = today.replace(day=1) + dateutil.relativedelta.relativedelta(
194
+ months=1
195
+ )
196
+ last_day = first_of_next_month - dateutil.relativedelta.relativedelta(days=1)
197
+ return last_day
198
+
199
+
200
+ def last_day_of_next_month():
201
+ today = datetime.datetime.today()
202
+ first_of_next_month = today.replace(day=1) + dateutil.relativedelta.relativedelta(
203
+ months=2
204
+ )
205
+ last_day = first_of_next_month - dateutil.relativedelta.relativedelta(days=1)
206
+ return last_day
207
+
208
+
209
+ def last_day_of_next_next_month():
210
+ today = datetime.datetime.today()
211
+ first_of_next_month = today.replace(day=1) + dateutil.relativedelta.relativedelta(
212
+ months=3
213
+ )
214
+ last_day = first_of_next_month - dateutil.relativedelta.relativedelta(days=1)
215
+ return last_day
216
+
217
+
218
+ def ten_days_from_now():
219
+ today = datetime.datetime.today()
220
+ return today + dateutil.relativedelta.relativedelta(days=10)
221
+
222
+
223
+ # ------------------------------------------------
224
+
225
+
226
+ def get_tipologia_risoluzione():
227
+ table = {
228
+ "CC01-1": ("CAE0", None),
229
+ "CC01-2": ("CAE0", None),
230
+ "CC02": ("CAE8", "CA7"),
231
+ "CC03-1": ("CAE5", "CA5"),
232
+ "CC04-1": ("CAE8", "CA4"),
233
+ "CC05-1": ("CAE2", "CA6"),
234
+ "CC06-1": ("CAE8", "CA7"),
235
+ "CC12-1": ("CAE1", "CA1"),
236
+ "CC13-1": ("CAE8", "CA7"),
237
+ "CC26-1": ("CAE7", "CA3"),
238
+ "CC27-1": ("CAE3", "CA2"),
239
+ }
240
+
241
+ code = case_id.ticket_type_id.code
242
+
243
+ if code not in table:
244
+ raise ValidationError(
245
+ "Non è possibile determinare la tipologia di risoluzione per il dettaglio {}".format(
246
+ code
247
+ )
248
+ )
249
+
250
+ power, gas = table.get(code)
251
+
252
+ sp = first(case_id.service_point_ids)
253
+
254
+ if sp.pod_id and power:
255
+ return power
256
+
257
+ if sp.pdr_id and gas:
258
+ return gas
259
+
260
+ raise ValidationError(
261
+ "Non è possibile determinare la tipologia di risoluzione per il dettaglio {}".format(
262
+ code
263
+ )
264
+ )
265
+
266
+
267
+ def get_data_decorrenza(tipologia_risoluzione):
268
+ today = datetime.datetime.today()
269
+ code = case_id.ticket_type_id.code
270
+
271
+ # -------- Special Case --------
272
+
273
+ if tipologia_risoluzione == "CA1":
274
+ return fmt(ten_days_from_now())
275
+
276
+ if tipologia_risoluzione in ["CA2", "CA3"]:
277
+ return fmt(last_day_of_next_next_month())
278
+
279
+ if (
280
+ tipologia_risoluzione == "CA4"
281
+ and code == "CC04-1"
282
+ and case_id.customer_id.customer_care_category == "pmi"
283
+ ):
284
+ voltura_start_date = (
285
+ today # TODO get real voltura_start_date, don't yet know how
286
+ )
287
+ if voltura_start_date <= today:
288
+ if today.day <= 10:
289
+ return fmt(last_day_of_this_month())
290
+ return fmt(last_day_of_next_month())
291
+ else:
292
+ return fmt(voltura_start_date)
293
+
294
+ # -------- Default Case --------
295
+
296
+ if today.day <= 10:
297
+ return fmt(last_day_of_this_month())
298
+ return fmt(last_day_of_next_month())
299
+
300
+
301
+ # ------------------------------------------------
302
+
303
+
304
+ def main():
305
+ tipologia_risoluzione = get_tipologia_risoluzione()
306
+
307
+ kv_store = case_id.sudo().kv_store()
308
+ data_decorrenza = get_data_decorrenza(tipologia_risoluzione)
309
+ ifs_data = {
310
+ "tipologia_risoluzione": tipologia_risoluzione,
311
+ "data_decorrenza": data_decorrenza,
312
+ }
313
+ kv_store.sudo().set("ifs_data", ifs_data)
314
+ case_id.write(
315
+ {
316
+ "disconnect_date": datetime.datetime.strptime(
317
+ data_decorrenza, "%d/%m/%Y"
318
+ ).date()
319
+ }
320
+ )
321
+
322
+ sp = first(case_id.service_point_ids)
323
+ asset = sp.asset(active=True) # solo sm_state attivo
324
+
325
+ if not asset:
326
+ raise Exception("Asset attivo non trovato per il punto {}".format(sp.code))
327
+
328
+ case_id.sudo().kv_store().set("asset", asset.data)
329
+
330
+ date_fmt = datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%f") + "Z"
331
+
332
+ sp.sudo().write({"state": "deactivating"})
333
+ env["ir.config_parameter"].update_b2w_statemodel(
334
+ "in_cessazione",
335
+ sm_reason=case_id.ticket_type_id.name,
336
+ expected_date=date_fmt,
337
+ asset_id=str(asset._id),
338
+ )
339
+
340
+ return "OK"
341
+
342
+
343
+ try:
344
+ result = main()
345
+ except Exception as e:
346
+ logs.append({"message": str(e), "traceback": format_exc()})
347
+ case_id.write(
348
+ {"error_message": "Errore durante l'esecuzione della fase: {}".format(str(e))}
349
+ )
350
+
351
+
352
+ if logs:
353
+ log(json_dumps(logs))]]></field>
354
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
355
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
356
+ <field name="is_a_postalizer_phase">False</field>
357
+ <field name="is_compute_refund">False</field>
358
+ <field name="is_dl">False</field>
359
+ <field name="is_needs_child_case">False</field>
360
+ <field name="is_pick_refund_template">False</field>
361
+ <field name="is_process_managed">False</field>
362
+ <field name="is_quote_accepted">False</field>
363
+ <field name="is_quote_sent">False</field>
364
+ <field name="is_timeout">False</field>
365
+ <field name="is_voidable">False</field>
366
+ <field name="name">A1672 - Recupero dati a CRM</field>
367
+ <field name="set_result_automatically">from_code</field>
368
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
369
+ <field name="is_externally_integrated">False</field>
370
+ <field name="is_process_cancellable_relaunchable">False</field>
371
+ <field name="wizard_info">{"key":"value"}</field>
372
+ <field name="phase_code">F-CC01-0004</field>
373
+ <field name="check_closed_child_tickets">False</field>
374
+ </record>
375
+ <record id="symple_triplet_phase_A1323_-_Errore_CRM__Recupero_dati_" model="symple.triplet.phase">
376
+ <field name="active">True</field>
377
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C1616_-_Risoluzione_Errore_E-CC01-0010')])]"/>
378
+ <field name="child_case">False</field>
379
+ <field name="code"># Available variables:
380
+ # - case_id: the case that just reached this phase
381
+ # - request: allows you to make HTTP requests (method, url, headers, data)
382
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
383
+ # - json_load: allows you to use JSON.load to convert a json into an object
384
+ # - env: Odoo Environment on which the action is triggered
385
+ # - time, datetime, dateutil, timezone: useful Python libraries
386
+ # - float_compare: Odoo function to compare floats based on specific precisions
387
+ # - ValidationError: Warning Exception to use with raise
388
+ # - Command: x2Many commands namespace
389
+ # - OrderedDict: ordered dictionaries
390
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
391
+ # (line = case id, func = phase name)
392
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
393
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
394
+ # To return a result, assign: result = {...}
395
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
396
+ # phase result will not be set.
397
+
398
+
399
+
400
+ </field>
401
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','AMS')])" />
402
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
403
+ <field name="is_a_postalizer_phase">False</field>
404
+ <field name="is_compute_refund">False</field>
405
+ <field name="is_dl">False</field>
406
+ <field name="is_needs_child_case">False</field>
407
+ <field name="is_pick_refund_template">False</field>
408
+ <field name="is_process_managed">False</field>
409
+ <field name="is_quote_accepted">False</field>
410
+ <field name="is_quote_sent">False</field>
411
+ <field name="is_timeout">False</field>
412
+ <field name="is_voidable">False</field>
413
+ <field name="name">A1323 - Errore CRM (Recupero dati)</field>
414
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
415
+ <field name="is_externally_integrated">False</field>
416
+ <field name="is_process_cancellable_relaunchable">False</field>
417
+ <field name="wizard_info">{"key":"value"}</field>
418
+ <field name="phase_code">F-CC01-0005</field>
419
+ <field name="check_closed_child_tickets">False</field>
420
+ </record>
421
+ <record id="symple_triplet_phase_A1559_-_Invio_alla_Market_Communication" model="symple.triplet.phase">
422
+ <field name="active">True</field>
423
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C1019_-_Inviata_E-CC01-0011')])]"/>
424
+ <field name="child_case">False</field>
425
+ <field name="code"># Available variables:
426
+ # - case_id: the case that just reached this phase
427
+ # - request: allows you to make HTTP requests (method, url, headers, data)
428
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
429
+ # - json_load: allows you to use JSON.load to convert a json into an object
430
+ # - env: Odoo Environment on which the action is triggered
431
+ # - time, datetime, dateutil, timezone: useful Python libraries
432
+ # - float_compare: Odoo function to compare floats based on specific precisions
433
+ # - ValidationError: Warning Exception to use with raise
434
+ # - Command: x2Many commands namespace
435
+ # - OrderedDict: ordered dictionaries
436
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
437
+ # (line = case id, func = phase name)
438
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
439
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
440
+ # To return a result, assign: result = {...}
441
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
442
+ # phase result will not be set.
443
+
444
+
445
+ logs = []
446
+
447
+ # ------------------------------
448
+
449
+
450
+ def get_addizione_regionale():
451
+ return case_id.service_point_ids[0].regional_surcharge_value
452
+
453
+
454
+ # ------------------------------
455
+
456
+
457
+ def get_resubmit_bindings():
458
+ return {
459
+ "helpdesk_ticket": {
460
+ "ids": [
461
+ case_id.id,
462
+ ]
463
+ },
464
+ "billing_profile": {"ids": []},
465
+ "service_point": {"ids": []},
466
+ "res_partner_pod": {"ids": []},
467
+ "res_partner_pdr": {"ids": []},
468
+ }
469
+
470
+
471
+ def shared_data():
472
+ sp = case_id.service_point_ids
473
+ ifs_data = case_id.sudo().kv_store().get("ifs_data")
474
+ tipologia_risoluzione = ifs_data.get("tipologia_risoluzione")
475
+
476
+ return {
477
+ "COD_FLUSSO": "0050",
478
+ "PIVA": case_id.customer_id.numbers_only_vat or "",
479
+ "CF": case_id.customer_id.fiscal_code or "",
480
+ "CF_STRANIERO": "0",
481
+ "ALIQUOTA_IVA": (
482
+ sp.iva_rate if tipologia_risoluzione not in ["CAE1", "CA1"] else ""
483
+ ),
484
+ "ALIQUOTA_ACCISE": "0" if tipologia_risoluzione not in ["CAE1", "CA1"] else "",
485
+ "ADDIZ_PROVINCIALE": (
486
+ "0" if tipologia_risoluzione not in ["CAE1", "CA1"] else ""
487
+ ),
488
+ "ADDIZ_COMUNALE": "0" if tipologia_risoluzione not in ["CAE1", "CA1"] else "",
489
+ "TIPOLOGIA_RISOLUZIONE": tipologia_risoluzione,
490
+ "DATA_DECORRENZA": ifs_data.get("data_decorrenza"),
491
+ "OWNER": "SORGE",
492
+ }
493
+
494
+
495
+ # ------------------------------
496
+
497
+
498
+ def prep_rc1():
499
+ message = shared_data()
500
+ message.update(
501
+ {"COD_SERVIZIO": "RC1", "COD_POD": case_id.service_point_ids[0].pod_id.code}
502
+ )
503
+ return message
504
+
505
+
506
+ def _not_cae1_ca1(value, tipologia_risoluzione):
507
+ if tipologia_risoluzione in ["CAE1", "CA1"]:
508
+ return ""
509
+ return value
510
+
511
+
512
+ def prep_rcg1():
513
+ ifs_data = case_id.sudo().kv_store().get("ifs_data")
514
+ tipologia_risoluzione = ifs_data.get("tipologia_risoluzione")
515
+ message = shared_data()
516
+ is_person = not case_id.customer_id.is_company
517
+ is_ui = message["TIPOLOGIA_RISOLUZIONE"] != "CA4"
518
+ service_point = case_id.service_point_ids[0]
519
+ invoicing_address = service_point.billing_profile_id.invoicing_address_id
520
+ message.update(
521
+ {
522
+ "COD_SERVIZIO": "RCG1",
523
+ "COD_PDR": case_id.service_point_ids[0].pdr_id.code,
524
+ "MOTIVAZIONE": "Scelta commerciale Sorgenia",
525
+ "PRIORITA": "",
526
+ "ALTRE_INFORMAZIONI": "",
527
+ "NOME": _not_cae1_ca1(
528
+ case_id.customer_id.firstname if is_person else "",
529
+ tipologia_risoluzione,
530
+ ),
531
+ "COGNOME": _not_cae1_ca1(
532
+ case_id.customer_id.lastname if is_person else "", tipologia_risoluzione
533
+ ),
534
+ "EMAIL": _not_cae1_ca1(
535
+ case_id.customer_id.email or "", tipologia_risoluzione
536
+ ),
537
+ "TELEFONO": _not_cae1_ca1(
538
+ case_id.customer_id.phone or "", tipologia_risoluzione
539
+ ),
540
+ "ACCESSO_FUI": _not_cae1_ca1(
541
+ "SI" if message["TIPOLOGIA_RISOLUZIONE"] == "CA4" else "NO",
542
+ tipologia_risoluzione,
543
+ ),
544
+ "UI_CF": _not_cae1_ca1(
545
+ case_id.customer_id.fiscal_code if is_ui else "", tipologia_risoluzione
546
+ ),
547
+ "UI_PIVA": _not_cae1_ca1(
548
+ case_id.customer_id.vat if is_ui else "", tipologia_risoluzione
549
+ ),
550
+ "UI_CF_STRANIERO": _not_cae1_ca1("", tipologia_risoluzione),
551
+ "UI_NOME": _not_cae1_ca1(
552
+ case_id.customer_id.firstname if is_ui and is_person else "",
553
+ tipologia_risoluzione,
554
+ ),
555
+ "UI_COGNOME": _not_cae1_ca1(
556
+ case_id.customer_id.lastname if is_ui and is_person else "",
557
+ tipologia_risoluzione,
558
+ ),
559
+ "UI_RAGIONE_SOCIALE_DENOMINAZIONE": _not_cae1_ca1(
560
+ case_id.customer_id.name if is_ui and not is_person else "",
561
+ tipologia_risoluzione,
562
+ ),
563
+ "UI_EMAIL": _not_cae1_ca1(
564
+ case_id.customer_id.email or "" if is_ui else "", tipologia_risoluzione
565
+ ),
566
+ "UI_TELEFONO": _not_cae1_ca1(
567
+ case_id.customer_id.phone or "" if is_ui else "", tipologia_risoluzione
568
+ ),
569
+ "UI_AF_CF": _not_cae1_ca1("", tipologia_risoluzione),
570
+ "UI_AF_PIVA": _not_cae1_ca1("", tipologia_risoluzione),
571
+ "UI_AF_CF_STRANIERO": _not_cae1_ca1("", tipologia_risoluzione),
572
+ "UI_AF_NOME": _not_cae1_ca1("", tipologia_risoluzione),
573
+ "UI_AF_COGNOME": _not_cae1_ca1("", tipologia_risoluzione),
574
+ "UI_AF_RAGIONE_SOCIALE_DENOMINAZIONE": _not_cae1_ca1(
575
+ "", tipologia_risoluzione
576
+ ),
577
+ "UI_FOR_TOPONIMO": _not_cae1_ca1(
578
+ service_point.service_toponym_id.name or "", tipologia_risoluzione
579
+ ),
580
+ "UI_FOR_VIA": _not_cae1_ca1(
581
+ service_point.service_street or "", tipologia_risoluzione
582
+ ),
583
+ "UI_FOR_CIV": _not_cae1_ca1(
584
+ service_point.service_street_number or "", tipologia_risoluzione
585
+ ),
586
+ "UI_FOR_CAP": _not_cae1_ca1(
587
+ service_point.service_zip or "40100", tipologia_risoluzione
588
+ ),
589
+ "UI_FOR_ISTAT": _not_cae1_ca1(
590
+ service_point.service_city_id.istat_code or "", tipologia_risoluzione
591
+ ),
592
+ "UI_FOR_LOCALITA": _not_cae1_ca1(
593
+ service_point.service_city_id.name or "", tipologia_risoluzione
594
+ ),
595
+ "UI_FOR_PROV": _not_cae1_ca1(
596
+ service_point.service_state_code or "", tipologia_risoluzione
597
+ ),
598
+ "UI_FOR_NAZIONE": (
599
+ _not_cae1_ca1(
600
+ service_point.service_country_id.with_context(
601
+ lang="it_IT"
602
+ ).name.upper(),
603
+ tipologia_risoluzione,
604
+ )
605
+ )
606
+ or "",
607
+ "UI_FOR_ALTRO": "",
608
+ "UI_ES_TOPONIMO": _not_cae1_ca1(
609
+ invoicing_address.toponym_id.name or "", tipologia_risoluzione
610
+ ),
611
+ "UI_ES_VIA": _not_cae1_ca1(
612
+ invoicing_address.street or "", tipologia_risoluzione
613
+ ),
614
+ "UI_ES_CIV": _not_cae1_ca1(
615
+ invoicing_address.street_num or "", tipologia_risoluzione
616
+ ),
617
+ "UI_ES_CAP": _not_cae1_ca1(
618
+ invoicing_address.zip or "", tipologia_risoluzione
619
+ ),
620
+ "UI_ES_ISTAT": _not_cae1_ca1(
621
+ invoicing_address.istat_code or "", tipologia_risoluzione
622
+ ),
623
+ "UI_ES_LOCALITA": _not_cae1_ca1(
624
+ invoicing_address.city_id.name or "", tipologia_risoluzione
625
+ ),
626
+ "UI_ES_PROV": _not_cae1_ca1(
627
+ invoicing_address.state_code or "", tipologia_risoluzione
628
+ ),
629
+ "UI_ES_NAZIONE": _not_cae1_ca1(
630
+ invoicing_address.country_id.with_context(lang="it_IT").name.upper()
631
+ or "",
632
+ tipologia_risoluzione,
633
+ ),
634
+ "UI_ES_ALTRO": _not_cae1_ca1("", tipologia_risoluzione),
635
+ "UI_CODICE_UFFICIO": service_point.billing_profile_id.office_code or "",
636
+ "UI_PAGAMENTO_IVA": "",
637
+ "SETT_MERCEOLOGICO": "",
638
+ "COD_RICHIESTA": "",
639
+ "ADDIZ_REGIONALE": (
640
+ get_addizione_regionale()
641
+ if message["TIPOLOGIA_RISOLUZIONE"] != "CA1"
642
+ else ""
643
+ ),
644
+ }
645
+ )
646
+ return message
647
+
648
+
649
+ # ------------------------------
650
+
651
+
652
+ def main():
653
+ ifs_data_message = None
654
+ is_ele = case_id.service_point_ids[0].pod_id.exists()
655
+
656
+ if is_ele:
657
+ ifs_data_message = prep_rc1()
658
+ else:
659
+ ifs_data_message = prep_rcg1()
660
+
661
+ ifs_dict = {
662
+ "ifs_code": "RC1" if is_ele else "RCG1",
663
+ "case_id": str(case_id.id),
664
+ "entity_bindings_resubmit": get_resubmit_bindings(),
665
+ "ifs_data_message": ifs_data_message,
666
+ }
667
+ ifs_json = json_dumps(ifs_dict)
668
+ tenant_id = env["ir.config_parameter"].sudo().get_param("m2c_header_tenant_id")
669
+ org_token = env["ir.config_parameter"].sudo().get_param("m2c_header_org_token")
670
+ headers = {"tenantId": tenant_id, "orgToken": org_token}
671
+ btw_url = "http://b2w-symphony-rest-service/api/symphony/process-instances/ml_IFS_passthrough"
672
+ response = request("POST", btw_url, headers=headers, data=ifs_json)
673
+
674
+ if str(response.status_code) != "200":
675
+ raise ValidationError(str(response.status_code) + " " + str(response.text))
676
+
677
+ return "OK"
678
+
679
+
680
+ try:
681
+ result = main()
682
+ except Exception as e:
683
+ logs.append({"message": str(e), "traceback": format_exc()})
684
+ prev = case_id.info_message + "\n" if case_id.info_message else ""
685
+ case_id.write({"info_message": prev + str(e)})
686
+
687
+ result = "KO"
688
+
689
+
690
+ if logs:
691
+ log(json_dumps(logs))</field>
692
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
693
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
694
+ <field name="is_a_postalizer_phase">False</field>
695
+ <field name="is_compute_refund">False</field>
696
+ <field name="is_dl">False</field>
697
+ <field name="is_needs_child_case">False</field>
698
+ <field name="is_pick_refund_template">False</field>
699
+ <field name="is_process_managed">False</field>
700
+ <field name="is_quote_accepted">False</field>
701
+ <field name="is_quote_sent">False</field>
702
+ <field name="is_timeout">False</field>
703
+ <field name="is_voidable">False</field>
704
+ <field name="name">A1559 - Invio alla Market Communication</field>
705
+ <field name="set_result_automatically">from_code</field>
706
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
707
+ <field name="is_externally_integrated">False</field>
708
+ <field name="is_process_cancellable_relaunchable">False</field>
709
+ <field name="wizard_info">{"key":"value"}</field>
710
+ <field name="phase_code">F-CC01-0006</field>
711
+ <field name="check_closed_child_tickets">False</field>
712
+ </record>
713
+ <record id="symple_triplet_phase_A1715_-_In_attesa_check_IFS" model="symple.triplet.phase">
714
+ <field name="active">True</field>
715
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C2225_-_KO_-_Ammissibilit__Hub_E-CC01-0012'),ref('symple_triplet_phase_result_C2224_-_OK_-_Ammissibilit__Hub_E-CC01-0013')])]"/>
716
+ <field name="child_case">False</field>
717
+ <field name="code"># Available variables:
718
+ # - case_id: the case that just reached this phase
719
+ # - request: allows you to make HTTP requests (method, url, headers, data)
720
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
721
+ # - json_load: allows you to use JSON.load to convert a json into an object
722
+ # - env: Odoo Environment on which the action is triggered
723
+ # - time, datetime, dateutil, timezone: useful Python libraries
724
+ # - float_compare: Odoo function to compare floats based on specific precisions
725
+ # - ValidationError: Warning Exception to use with raise
726
+ # - Command: x2Many commands namespace
727
+ # - OrderedDict: ordered dictionaries
728
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
729
+ # (line = case id, func = phase name)
730
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
731
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
732
+ # To return a result, assign: result = {...}
733
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
734
+ # phase result will not be set.
735
+
736
+
737
+
738
+ </field>
739
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
740
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
741
+ <field name="is_a_postalizer_phase">False</field>
742
+ <field name="is_compute_refund">False</field>
743
+ <field name="is_dl">False</field>
744
+ <field name="is_needs_child_case">False</field>
745
+ <field name="is_pick_refund_template">False</field>
746
+ <field name="is_process_managed">False</field>
747
+ <field name="is_quote_accepted">False</field>
748
+ <field name="is_quote_sent">False</field>
749
+ <field name="is_timeout">False</field>
750
+ <field name="is_voidable">False</field>
751
+ <field name="name">A1715 - In attesa check IFS</field>
752
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
753
+ <field name="is_externally_integrated">False</field>
754
+ <field name="is_process_cancellable_relaunchable">False</field>
755
+ <field name="wizard_info">{"key":"value"}</field>
756
+ <field name="phase_code">F-CC01-0007</field>
757
+ <field name="check_closed_child_tickets">False</field>
758
+ </record>
759
+ <record id="symple_triplet_phase_A1717_-_Gestione_scarti_da_cruscotto" model="symple.triplet.phase">
760
+ <field name="active">True</field>
761
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C2416_-_risottomessa_da_cruscotto_E-CC01-0015'),ref('symple_triplet_phase_result_C1931_-_Errore_non_rilavorabile_E-CC01-0016'),ref('symple_triplet_phase_result_C1763_-_Annullamento_passivo_dal_SII_E-CC01-0017')])]"/>
762
+ <field name="child_case">False</field>
763
+ <field name="code"># Available variables:
764
+ # - case_id: the case that just reached this phase
765
+ # - request: allows you to make HTTP requests (method, url, headers, data)
766
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
767
+ # - json_load: allows you to use JSON.load to convert a json into an object
768
+ # - env: Odoo Environment on which the action is triggered
769
+ # - time, datetime, dateutil, timezone: useful Python libraries
770
+ # - float_compare: Odoo function to compare floats based on specific precisions
771
+ # - ValidationError: Warning Exception to use with raise
772
+ # - Command: x2Many commands namespace
773
+ # - OrderedDict: ordered dictionaries
774
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
775
+ # (line = case id, func = phase name)
776
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
777
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
778
+ # To return a result, assign: result = {...}
779
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
780
+ # phase result will not be set.
781
+
782
+
783
+
784
+ </field>
785
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
786
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
787
+ <field name="is_a_postalizer_phase">False</field>
788
+ <field name="is_compute_refund">False</field>
789
+ <field name="is_dl">False</field>
790
+ <field name="is_needs_child_case">False</field>
791
+ <field name="is_pick_refund_template">False</field>
792
+ <field name="is_process_managed">False</field>
793
+ <field name="is_quote_accepted">False</field>
794
+ <field name="is_quote_sent">False</field>
795
+ <field name="is_timeout">False</field>
796
+ <field name="is_voidable">False</field>
797
+ <field name="name">A1717 - Gestione scarti da cruscotto</field>
798
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
799
+ <field name="is_externally_integrated">False</field>
800
+ <field name="is_process_cancellable_relaunchable">False</field>
801
+ <field name="wizard_info">{"key":"value"}</field>
802
+ <field name="phase_code">F-CC01-0008</field>
803
+ <field name="check_closed_child_tickets">False</field>
804
+ </record>
805
+ <record id="symple_triplet_phase_A2558_-_verifica_avvio_gestione_manuale" model="symple.triplet.phase">
806
+ <field name="active">True</field>
807
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C2598_-_gestione_manuale_E-CC01-0018'),ref('symple_triplet_phase_result_C2509_-_Da_gestire_nuovo_invio_automatico_E-CC01-0019')])]"/>
808
+ <field name="child_case">False</field>
809
+ <field name="code"># Available variables:
810
+ # - case_id: the case that just reached this phase
811
+ # - request: allows you to make HTTP requests (method, url, headers, data)
812
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
813
+ # - json_load: allows you to use JSON.load to convert a json into an object
814
+ # - env: Odoo Environment on which the action is triggered
815
+ # - time, datetime, dateutil, timezone: useful Python libraries
816
+ # - float_compare: Odoo function to compare floats based on specific precisions
817
+ # - ValidationError: Warning Exception to use with raise
818
+ # - Command: x2Many commands namespace
819
+ # - OrderedDict: ordered dictionaries
820
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
821
+ # (line = case id, func = phase name)
822
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
823
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
824
+ # To return a result, assign: result = {...}
825
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
826
+ # phase result will not be set.
827
+
828
+
829
+
830
+ </field>
831
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','BOT')])" />
832
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
833
+ <field name="is_a_postalizer_phase">False</field>
834
+ <field name="is_compute_refund">False</field>
835
+ <field name="is_dl">False</field>
836
+ <field name="is_needs_child_case">False</field>
837
+ <field name="is_pick_refund_template">False</field>
838
+ <field name="is_process_managed">False</field>
839
+ <field name="is_quote_accepted">False</field>
840
+ <field name="is_quote_sent">False</field>
841
+ <field name="is_timeout">False</field>
842
+ <field name="is_voidable">False</field>
843
+ <field name="name">A2558 - verifica avvio gestione manuale</field>
844
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
845
+ <field name="is_externally_integrated">False</field>
846
+ <field name="is_process_cancellable_relaunchable">False</field>
847
+ <field name="wizard_info">{"key":"value"}</field>
848
+ <field name="phase_code">F-CC01-0009</field>
849
+ <field name="check_closed_child_tickets">False</field>
850
+ </record>
851
+ <record id="symple_triplet_phase_A1879_-_Invio_alla_Market_Comm_Forzato" model="symple.triplet.phase">
852
+ <field name="active">True</field>
853
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C1019_-_Inviata_E-CC01-0020')])]"/>
854
+ <field name="child_case">False</field>
855
+ <field name="code"># Available variables:
856
+ # - case_id: the case that just reached this phase
857
+ # - request: allows you to make HTTP requests (method, url, headers, data)
858
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
859
+ # - json_load: allows you to use JSON.load to convert a json into an object
860
+ # - env: Odoo Environment on which the action is triggered
861
+ # - time, datetime, dateutil, timezone: useful Python libraries
862
+ # - float_compare: Odoo function to compare floats based on specific precisions
863
+ # - ValidationError: Warning Exception to use with raise
864
+ # - Command: x2Many commands namespace
865
+ # - OrderedDict: ordered dictionaries
866
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
867
+ # (line = case id, func = phase name)
868
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
869
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
870
+ # To return a result, assign: result = {...}
871
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
872
+ # phase result will not be set.
873
+
874
+
875
+ logs = []
876
+
877
+ # ------------------------------
878
+
879
+
880
+ def get_addizione_regionale():
881
+ return case_id.service_point_ids[0].regional_surcharge_value
882
+
883
+
884
+ # ------------------------------
885
+
886
+
887
+ def get_resubmit_bindings():
888
+ return {
889
+ "helpdesk_ticket": {
890
+ "ids": [
891
+ case_id.id,
892
+ ]
893
+ },
894
+ "billing_profile": {"ids": []},
895
+ "service_point": {"ids": []},
896
+ "res_partner_pod": {"ids": []},
897
+ "res_partner_pdr": {"ids": []},
898
+ }
899
+
900
+
901
+ def shared_data():
902
+ sp = case_id.service_point_ids
903
+ ifs_data = case_id.sudo().kv_store().get("ifs_data")
904
+ tipologia_risoluzione = ifs_data.get("tipologia_risoluzione")
905
+
906
+ return {
907
+ "COD_FLUSSO": "0050",
908
+ "PIVA": case_id.customer_id.numbers_only_vat or "",
909
+ "CF": case_id.customer_id.fiscal_code or "",
910
+ "CF_STRANIERO": "0",
911
+ "ALIQUOTA_IVA": (
912
+ sp.iva_rate if tipologia_risoluzione not in ["CAE1", "CA1"] else ""
913
+ ),
914
+ "ALIQUOTA_ACCISE": "0" if tipologia_risoluzione not in ["CAE1", "CA1"] else "",
915
+ "ADDIZ_PROVINCIALE": (
916
+ "0" if tipologia_risoluzione not in ["CAE1", "CA1"] else ""
917
+ ),
918
+ "ADDIZ_COMUNALE": "0" if tipologia_risoluzione not in ["CAE1", "CA1"] else "",
919
+ "TIPOLOGIA_RISOLUZIONE": tipologia_risoluzione,
920
+ "DATA_DECORRENZA": ifs_data.get("data_decorrenza"),
921
+ "OWNER": "SORGE",
922
+ }
923
+
924
+
925
+ # ------------------------------
926
+
927
+
928
+ def prep_rc1():
929
+ message = shared_data()
930
+ message.update(
931
+ {
932
+ "COD_SERVIZIO": "RC1",
933
+ "COD_POD": case_id.service_point_ids[0].pod_id.code,
934
+ "bypass": True,
935
+ }
936
+ )
937
+ return message
938
+
939
+
940
+ def _not_cae1_ca1(value, tipologia_risoluzione):
941
+ if tipologia_risoluzione in ["CAE1", "CA1"]:
942
+ return ""
943
+ return value
944
+
945
+
946
+ def prep_rcg1():
947
+ ifs_data = case_id.sudo().kv_store().get("ifs_data")
948
+ tipologia_risoluzione = ifs_data.get("tipologia_risoluzione")
949
+ message = shared_data()
950
+ is_person = not case_id.customer_id.is_company
951
+ is_ui = message["TIPOLOGIA_RISOLUZIONE"] != "CA4"
952
+ service_point = case_id.service_point_ids[0]
953
+ invoicing_address = service_point.billing_profile_id.invoicing_address_id
954
+ message.update(
955
+ {
956
+ "COD_SERVIZIO": "RCG1",
957
+ "COD_PDR": case_id.service_point_ids[0].pdr_id.code,
958
+ "MOTIVAZIONE": "Scelta commerciale Sorgenia",
959
+ "PRIORITA": "",
960
+ "ALTRE_INFORMAZIONI": "",
961
+ "NOME": _not_cae1_ca1(
962
+ case_id.customer_id.firstname if is_person else "",
963
+ tipologia_risoluzione,
964
+ ),
965
+ "COGNOME": _not_cae1_ca1(
966
+ case_id.customer_id.lastname if is_person else "", tipologia_risoluzione
967
+ ),
968
+ "EMAIL": _not_cae1_ca1(
969
+ case_id.customer_id.email or "", tipologia_risoluzione
970
+ ),
971
+ "TELEFONO": _not_cae1_ca1(
972
+ case_id.customer_id.phone or "", tipologia_risoluzione
973
+ ),
974
+ "ACCESSO_FUI": _not_cae1_ca1(
975
+ "SI" if message["TIPOLOGIA_RISOLUZIONE"] == "CA4" else "NO",
976
+ tipologia_risoluzione,
977
+ ),
978
+ "UI_CF": _not_cae1_ca1(
979
+ case_id.customer_id.fiscal_code if is_ui else "", tipologia_risoluzione
980
+ ),
981
+ "UI_PIVA": _not_cae1_ca1(
982
+ case_id.customer_id.vat if is_ui else "", tipologia_risoluzione
983
+ ),
984
+ "UI_CF_STRANIERO": _not_cae1_ca1("", tipologia_risoluzione),
985
+ "UI_NOME": _not_cae1_ca1(
986
+ case_id.customer_id.firstname if is_ui and is_person else "",
987
+ tipologia_risoluzione,
988
+ ),
989
+ "UI_COGNOME": _not_cae1_ca1(
990
+ case_id.customer_id.lastname if is_ui and is_person else "",
991
+ tipologia_risoluzione,
992
+ ),
993
+ "UI_RAGIONE_SOCIALE_DENOMINAZIONE": _not_cae1_ca1(
994
+ case_id.customer_id.name if is_ui and not is_person else "",
995
+ tipologia_risoluzione,
996
+ ),
997
+ "UI_EMAIL": _not_cae1_ca1(
998
+ case_id.customer_id.email or "" if is_ui else "", tipologia_risoluzione
999
+ ),
1000
+ "UI_TELEFONO": _not_cae1_ca1(
1001
+ case_id.customer_id.phone or "" if is_ui else "", tipologia_risoluzione
1002
+ ),
1003
+ "UI_AF_CF": _not_cae1_ca1("", tipologia_risoluzione),
1004
+ "UI_AF_PIVA": _not_cae1_ca1("", tipologia_risoluzione),
1005
+ "UI_AF_CF_STRANIERO": _not_cae1_ca1("", tipologia_risoluzione),
1006
+ "UI_AF_NOME": _not_cae1_ca1("", tipologia_risoluzione),
1007
+ "UI_AF_COGNOME": _not_cae1_ca1("", tipologia_risoluzione),
1008
+ "UI_AF_RAGIONE_SOCIALE_DENOMINAZIONE": _not_cae1_ca1(
1009
+ "", tipologia_risoluzione
1010
+ ),
1011
+ "UI_FOR_TOPONIMO": _not_cae1_ca1(
1012
+ service_point.service_toponym_id.name or "", tipologia_risoluzione
1013
+ ),
1014
+ "UI_FOR_VIA": _not_cae1_ca1(
1015
+ service_point.service_street or "", tipologia_risoluzione
1016
+ ),
1017
+ "UI_FOR_CIV": _not_cae1_ca1(
1018
+ service_point.service_street_number or "", tipologia_risoluzione
1019
+ ),
1020
+ "UI_FOR_CAP": _not_cae1_ca1(
1021
+ service_point.service_zip or "40100", tipologia_risoluzione
1022
+ ),
1023
+ "UI_FOR_ISTAT": _not_cae1_ca1(
1024
+ service_point.service_city_id.istat_code or "", tipologia_risoluzione
1025
+ ),
1026
+ "UI_FOR_LOCALITA": _not_cae1_ca1(
1027
+ service_point.service_city_id.name or "", tipologia_risoluzione
1028
+ ),
1029
+ "UI_FOR_PROV": _not_cae1_ca1(
1030
+ service_point.service_state_code or "", tipologia_risoluzione
1031
+ ),
1032
+ "UI_FOR_NAZIONE": (
1033
+ _not_cae1_ca1(
1034
+ service_point.service_country_id.with_context(
1035
+ lang="it_IT"
1036
+ ).name.upper(),
1037
+ tipologia_risoluzione,
1038
+ )
1039
+ )
1040
+ or "",
1041
+ "UI_FOR_ALTRO": "",
1042
+ "UI_ES_TOPONIMO": _not_cae1_ca1(
1043
+ invoicing_address.toponym_id.name or "", tipologia_risoluzione
1044
+ ),
1045
+ "UI_ES_VIA": _not_cae1_ca1(
1046
+ invoicing_address.street or "", tipologia_risoluzione
1047
+ ),
1048
+ "UI_ES_CIV": _not_cae1_ca1(
1049
+ invoicing_address.street_num or "", tipologia_risoluzione
1050
+ ),
1051
+ "UI_ES_CAP": _not_cae1_ca1(
1052
+ invoicing_address.zip or "", tipologia_risoluzione
1053
+ ),
1054
+ "UI_ES_ISTAT": _not_cae1_ca1(
1055
+ invoicing_address.istat_code or "", tipologia_risoluzione
1056
+ ),
1057
+ "UI_ES_LOCALITA": _not_cae1_ca1(
1058
+ invoicing_address.city_id.name or "", tipologia_risoluzione
1059
+ ),
1060
+ "UI_ES_PROV": _not_cae1_ca1(
1061
+ invoicing_address.state_code or "", tipologia_risoluzione
1062
+ ),
1063
+ "UI_ES_NAZIONE": _not_cae1_ca1(
1064
+ invoicing_address.country_id.with_context(lang="it_IT").name.upper()
1065
+ or "",
1066
+ tipologia_risoluzione,
1067
+ ),
1068
+ "UI_ES_ALTRO": _not_cae1_ca1("", tipologia_risoluzione),
1069
+ "UI_CODICE_UFFICIO": service_point.billing_profile_id.office_code or "",
1070
+ "UI_PAGAMENTO_IVA": "",
1071
+ "SETT_MERCEOLOGICO": "",
1072
+ "COD_RICHIESTA": "",
1073
+ "ADDIZ_REGIONALE": (
1074
+ get_addizione_regionale()
1075
+ if message["TIPOLOGIA_RISOLUZIONE"] != "CA1"
1076
+ else ""
1077
+ ),
1078
+ "bypass": True,
1079
+ }
1080
+ )
1081
+ return message
1082
+
1083
+
1084
+ # ------------------------------
1085
+
1086
+
1087
+ def main():
1088
+ ifs_data_message = None
1089
+ is_ele = case_id.service_point_ids[0].pod_id.exists()
1090
+
1091
+ if is_ele:
1092
+ ifs_data_message = prep_rc1()
1093
+ else:
1094
+ ifs_data_message = prep_rcg1()
1095
+
1096
+ ifs_dict = {
1097
+ "ifs_code": "RC1" if is_ele else "RCG1",
1098
+ "case_id": str(case_id.id),
1099
+ "entity_bindings_resubmit": get_resubmit_bindings(),
1100
+ "ifs_data_message": ifs_data_message,
1101
+ }
1102
+ ifs_json = json_dumps(ifs_dict)
1103
+ tenant_id = env["ir.config_parameter"].sudo().get_param("m2c_header_tenant_id")
1104
+ org_token = env["ir.config_parameter"].sudo().get_param("m2c_header_org_token")
1105
+ headers = {"tenantId": tenant_id, "orgToken": org_token}
1106
+ btw_url = "http://b2w-symphony-rest-service/api/symphony/process-instances/ml_IFS_passthrough"
1107
+ response = request("POST", btw_url, headers=headers, data=ifs_json)
1108
+
1109
+ if str(response.status_code) != "200":
1110
+ raise ValidationError(str(response.status_code) + " " + str(response.text))
1111
+
1112
+ return "OK"
1113
+
1114
+
1115
+ try:
1116
+ result = main()
1117
+ except Exception as e:
1118
+ logs.append({"message": str(e), "traceback": format_exc()})
1119
+ prev = case_id.info_message + "\n" if case_id.info_message else ""
1120
+ case_id.write({"info_message": prev + str(e)})
1121
+
1122
+ result = "KO"
1123
+
1124
+
1125
+ if logs:
1126
+ log(json_dumps(logs))</field>
1127
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
1128
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
1129
+ <field name="is_a_postalizer_phase">False</field>
1130
+ <field name="is_compute_refund">False</field>
1131
+ <field name="is_dl">False</field>
1132
+ <field name="is_needs_child_case">False</field>
1133
+ <field name="is_pick_refund_template">False</field>
1134
+ <field name="is_process_managed">False</field>
1135
+ <field name="is_quote_accepted">False</field>
1136
+ <field name="is_quote_sent">False</field>
1137
+ <field name="is_timeout">False</field>
1138
+ <field name="is_voidable">False</field>
1139
+ <field name="name">A1879 - Invio alla Market Comm Forzato</field>
1140
+ <field name="set_result_automatically">from_code</field>
1141
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
1142
+ <field name="is_externally_integrated">False</field>
1143
+ <field name="is_process_cancellable_relaunchable">False</field>
1144
+ <field name="wizard_info">{"key":"value"}</field>
1145
+ <field name="phase_code">F-CC01-0010</field>
1146
+ <field name="check_closed_child_tickets">False</field>
1147
+ </record>
1148
+ <record id="symple_triplet_phase_A1806_-_In_Attesa_Check_HUB_Forzato" model="symple.triplet.phase">
1149
+ <field name="active">True</field>
1150
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C2225_-_KO_-_Ammissibilit__Hub_E-CC01-0021'),ref('symple_triplet_phase_result_C2224_-_OK_-_Ammissibilit__Hub_E-CC01-0022')])]"/>
1151
+ <field name="child_case">False</field>
1152
+ <field name="code"># Available variables:
1153
+ # - case_id: the case that just reached this phase
1154
+ # - request: allows you to make HTTP requests (method, url, headers, data)
1155
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
1156
+ # - json_load: allows you to use JSON.load to convert a json into an object
1157
+ # - env: Odoo Environment on which the action is triggered
1158
+ # - time, datetime, dateutil, timezone: useful Python libraries
1159
+ # - float_compare: Odoo function to compare floats based on specific precisions
1160
+ # - ValidationError: Warning Exception to use with raise
1161
+ # - Command: x2Many commands namespace
1162
+ # - OrderedDict: ordered dictionaries
1163
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
1164
+ # (line = case id, func = phase name)
1165
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
1166
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
1167
+ # To return a result, assign: result = {...}
1168
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
1169
+ # phase result will not be set.
1170
+
1171
+
1172
+
1173
+ </field>
1174
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
1175
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
1176
+ <field name="is_a_postalizer_phase">False</field>
1177
+ <field name="is_compute_refund">False</field>
1178
+ <field name="is_dl">False</field>
1179
+ <field name="is_needs_child_case">False</field>
1180
+ <field name="is_pick_refund_template">False</field>
1181
+ <field name="is_process_managed">False</field>
1182
+ <field name="is_quote_accepted">False</field>
1183
+ <field name="is_quote_sent">False</field>
1184
+ <field name="is_timeout">False</field>
1185
+ <field name="is_voidable">False</field>
1186
+ <field name="name">A1806 - In Attesa Check HUB Forzato</field>
1187
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
1188
+ <field name="is_externally_integrated">False</field>
1189
+ <field name="is_process_cancellable_relaunchable">False</field>
1190
+ <field name="wizard_info">{"key":"value"}</field>
1191
+ <field name="phase_code">F-CC01-0011</field>
1192
+ <field name="check_closed_child_tickets">False</field>
1193
+ </record>
1194
+ <record id="symple_triplet_phase_A1834_-_Gestione_scarti_da_cruscotto_forzato" model="symple.triplet.phase">
1195
+ <field name="active">True</field>
1196
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C2416_-_risottomessa_da_cruscotto_E-CC01-0023'),ref('symple_triplet_phase_result_C1931_-_Errore_non_rilavorabile_E-CC01-0024')])]"/>
1197
+ <field name="child_case">False</field>
1198
+ <field name="code"># Available variables:
1199
+ # - case_id: the case that just reached this phase
1200
+ # - request: allows you to make HTTP requests (method, url, headers, data)
1201
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
1202
+ # - json_load: allows you to use JSON.load to convert a json into an object
1203
+ # - env: Odoo Environment on which the action is triggered
1204
+ # - time, datetime, dateutil, timezone: useful Python libraries
1205
+ # - float_compare: Odoo function to compare floats based on specific precisions
1206
+ # - ValidationError: Warning Exception to use with raise
1207
+ # - Command: x2Many commands namespace
1208
+ # - OrderedDict: ordered dictionaries
1209
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
1210
+ # (line = case id, func = phase name)
1211
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
1212
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
1213
+ # To return a result, assign: result = {...}
1214
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
1215
+ # phase result will not be set.
1216
+
1217
+
1218
+
1219
+ </field>
1220
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
1221
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
1222
+ <field name="is_a_postalizer_phase">False</field>
1223
+ <field name="is_compute_refund">False</field>
1224
+ <field name="is_dl">False</field>
1225
+ <field name="is_needs_child_case">False</field>
1226
+ <field name="is_pick_refund_template">False</field>
1227
+ <field name="is_process_managed">False</field>
1228
+ <field name="is_quote_accepted">False</field>
1229
+ <field name="is_quote_sent">False</field>
1230
+ <field name="is_timeout">False</field>
1231
+ <field name="is_voidable">False</field>
1232
+ <field name="name">A1834 - Gestione scarti da cruscotto forzato</field>
1233
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
1234
+ <field name="is_externally_integrated">False</field>
1235
+ <field name="is_process_cancellable_relaunchable">False</field>
1236
+ <field name="wizard_info">{"key":"value"}</field>
1237
+ <field name="phase_code">F-CC01-0012</field>
1238
+ <field name="check_closed_child_tickets">False</field>
1239
+ </record>
1240
+ <record id="symple_triplet_phase_A0816_-_In_attesa_esito_ammissibilit_" model="symple.triplet.phase">
1241
+ <field name="active">True</field>
1242
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C1037_-_Ammissibilit__OK_E-CC01-0025'),ref('symple_triplet_phase_result_C1038_-_Ammissibilit__KO_E-CC01-0026')])]"/>
1243
+ <field name="child_case">False</field>
1244
+ <field name="code"># Available variables:
1245
+ # - case_id: the case that just reached this phase
1246
+ # - request: allows you to make HTTP requests (method, url, headers, data)
1247
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
1248
+ # - json_load: allows you to use JSON.load to convert a json into an object
1249
+ # - env: Odoo Environment on which the action is triggered
1250
+ # - time, datetime, dateutil, timezone: useful Python libraries
1251
+ # - float_compare: Odoo function to compare floats based on specific precisions
1252
+ # - ValidationError: Warning Exception to use with raise
1253
+ # - Command: x2Many commands namespace
1254
+ # - OrderedDict: ordered dictionaries
1255
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
1256
+ # (line = case id, func = phase name)
1257
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
1258
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
1259
+ # To return a result, assign: result = {...}
1260
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
1261
+ # phase result will not be set.
1262
+
1263
+
1264
+
1265
+ </field>
1266
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
1267
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
1268
+ <field name="is_a_postalizer_phase">False</field>
1269
+ <field name="is_compute_refund">False</field>
1270
+ <field name="is_dl">False</field>
1271
+ <field name="is_needs_child_case">False</field>
1272
+ <field name="is_pick_refund_template">False</field>
1273
+ <field name="is_process_managed">False</field>
1274
+ <field name="is_quote_accepted">False</field>
1275
+ <field name="is_quote_sent">False</field>
1276
+ <field name="is_timeout">False</field>
1277
+ <field name="is_voidable">False</field>
1278
+ <field name="name">A0816 - In attesa esito ammissibilità</field>
1279
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
1280
+ <field name="is_externally_integrated">False</field>
1281
+ <field name="is_process_cancellable_relaunchable">False</field>
1282
+ <field name="wizard_info">{"key":"value"}</field>
1283
+ <field name="phase_code">F-CC01-0013</field>
1284
+ <field name="check_closed_child_tickets">False</field>
1285
+ </record>
1286
+ <record id="symple_triplet_phase_A1004_-_Verifica_RCU___Data_decorrenza" model="symple.triplet.phase">
1287
+ <field name="active">True</field>
1288
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C1448_-_OK_controlli_RCU___Data_decorrenza_E-CC01-0027'),ref('symple_triplet_phase_result_C1449_-_KO_controlli_RCU___Data_decorrenza_E-CC01-0028'),ref('symple_triplet_phase_result_C2549_-_annullamento_attivo_E-CC01-0029'),ref('symple_triplet_phase_result_C1763_-_Annullamento_passivo_dal_SII_E-CC01-0030')])]"/>
1289
+ <field name="allowed_process_ids" model="symple.pb.process" eval="[(6, 0, obj().search([('name','in',('ml_annullamento_cessazione',)),]).ids)]" />
1290
+ <field name="child_case">False</field>
1291
+ <field name="code"># Available variables:
1292
+ # - case_id: the case that just reached this phase
1293
+ # - request: allows you to make HTTP requests (method, url, headers, data)
1294
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
1295
+ # - json_load: allows you to use JSON.load to convert a json into an object
1296
+ # - env: Odoo Environment on which the action is triggered
1297
+ # - time, datetime, dateutil, timezone: useful Python libraries
1298
+ # - float_compare: Odoo function to compare floats based on specific precisions
1299
+ # - ValidationError: Warning Exception to use with raise
1300
+ # - Command: x2Many commands namespace
1301
+ # - OrderedDict: ordered dictionaries
1302
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
1303
+ # (line = case id, func = phase name)
1304
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
1305
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
1306
+ # To return a result, assign: result = {...}
1307
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
1308
+ # phase result will not be set.
1309
+
1310
+
1311
+
1312
+ </field>
1313
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','BOT')])" />
1314
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
1315
+ <field name="is_a_postalizer_phase">False</field>
1316
+ <field name="is_compute_refund">False</field>
1317
+ <field name="is_dl">False</field>
1318
+ <field name="is_needs_child_case">False</field>
1319
+ <field name="is_pick_refund_template">False</field>
1320
+ <field name="is_process_managed">False</field>
1321
+ <field name="is_quote_accepted">False</field>
1322
+ <field name="is_quote_sent">False</field>
1323
+ <field name="is_timeout">False</field>
1324
+ <field name="is_voidable">False</field>
1325
+ <field name="name">A1004 - Verifica RCU + Data decorrenza</field>
1326
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
1327
+ <field name="is_externally_integrated">False</field>
1328
+ <field name="is_process_cancellable_relaunchable">False</field>
1329
+ <field name="wizard_info">{"key":"value"}</field>
1330
+ <field name="phase_code">F-CC01-0014</field>
1331
+ <field name="check_closed_child_tickets">False</field>
1332
+ </record>
1333
+ <record id="symple_triplet_phase_A2397_-_OK_RCU___verifica_data_decorrenza" model="symple.triplet.phase">
1334
+ <field name="active">True</field>
1335
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C1936_-_Data_raggiunta_E-CC01-0031')])]"/>
1336
+ <field name="child_case">False</field>
1337
+ <field name="code"><![CDATA[# RES1 = C1936 - Data raggiunta
1338
+
1339
+ RES1 = "RES1"
1340
+
1341
+ logs = []
1342
+ debug_logs = []
1343
+ error_occurred = False
1344
+
1345
+
1346
+ def make_log(message, data=None, always=False):
1347
+ log_entry = {"message": message}
1348
+ if data is not None:
1349
+ log_entry["data"] = data
1350
+
1351
+ if always:
1352
+ logs.append(log_entry)
1353
+ else:
1354
+ debug_logs.append(log_entry)
1355
+
1356
+
1357
+ # --------------------------------------
1358
+
1359
+
1360
+ def main():
1361
+ date_to_check = case_id.disconnect_date
1362
+ today = datetime.date.today()
1363
+ cutoff = today.replace(day=1) - datetime.timedelta(days=1)
1364
+ date_reached = date_to_check <= cutoff
1365
+ if date_reached:
1366
+ return RES1
1367
+
1368
+
1369
+ try:
1370
+ result = main()
1371
+ except Exception as e:
1372
+ error_occurred = True
1373
+ make_log(
1374
+ "Error occurred in phase",
1375
+ {"error": str(e), "traceback": format_exc()},
1376
+ always=True,
1377
+ )
1378
+ case_id.write({"error_message": str(e)})
1379
+
1380
+
1381
+ if error_occurred and debug_logs:
1382
+ logs.append({"message": "debug_logs", "logs": debug_logs})
1383
+
1384
+ if logs:
1385
+ log(json_dumps(logs, indent=2))]]></field>
1386
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
1387
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
1388
+ <field name="is_a_postalizer_phase">False</field>
1389
+ <field name="is_compute_refund">False</field>
1390
+ <field name="is_dl">False</field>
1391
+ <field name="is_needs_child_case">False</field>
1392
+ <field name="is_pick_refund_template">False</field>
1393
+ <field name="is_process_managed">False</field>
1394
+ <field name="is_quote_accepted">False</field>
1395
+ <field name="is_quote_sent">False</field>
1396
+ <field name="is_timeout">False</field>
1397
+ <field name="is_voidable">False</field>
1398
+ <field name="name">A2397 - OK RCU + verifica data decorrenza</field>
1399
+ <field name="set_result_automatically">from_code</field>
1400
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
1401
+ <field name="is_externally_integrated">False</field>
1402
+ <field name="is_process_cancellable_relaunchable">False</field>
1403
+ <field name="wizard_info">{"key":"value"}</field>
1404
+ <field name="phase_code">F-CC01-0015</field>
1405
+ <field name="check_closed_child_tickets">False</field>
1406
+ </record>
1407
+ <record id="symple_triplet_phase_A1577_-_Chiusura_Ordine_CRM" model="symple.triplet.phase">
1408
+ <field name="active">True</field>
1409
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C2242_-_Chiusura_Ordine_OK_E-CC01-0032'),ref('symple_triplet_phase_result_C1899_-_Errore_CRM_durante_Chiusura_Ordine_E-CC01-0033')])]"/>
1410
+ <field name="child_case">False</field>
1411
+ <field name="code"># Available variables:
1412
+ # - case_id: the case that just reached this phase
1413
+ # - request: allows you to make HTTP requests (method, url, headers, data)
1414
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
1415
+ # - json_load: allows you to use JSON.load to convert a json into an object
1416
+ # - env: Odoo Environment on which the action is triggered
1417
+ # - time, datetime, dateutil, timezone: useful Python libraries
1418
+ # - float_compare: Odoo function to compare floats based on specific precisions
1419
+ # - ValidationError: Warning Exception to use with raise
1420
+ # - Command: x2Many commands namespace
1421
+ # - OrderedDict: ordered dictionaries
1422
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
1423
+ # (line = case id, func = phase name)
1424
+ # To return a result, assign: result = {...}
1425
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
1426
+ # phase result will not be set.
1427
+
1428
+ logs = []
1429
+
1430
+
1431
+ def log_and_parse_response(response, log_message):
1432
+ try:
1433
+ json_data = response.json()
1434
+ logs.append({"message": log_message, "data": json_data})
1435
+ return json_data
1436
+ except Exception:
1437
+ logs.append({"message": log_message, "response_text": response.text})
1438
+ return response.text
1439
+
1440
+
1441
+ def create_order_disconnect(asset_id, token):
1442
+ url = "http://b2w-cpq-order-management-service/v1/order"
1443
+ headers = {
1444
+ "X-Auth-Request-Access-Token": "" + token,
1445
+ "Content-Type": "application/json",
1446
+ "generatesession": "true",
1447
+ }
1448
+ body = {
1449
+ "obj_type": "Order",
1450
+ "crm_accountcode": case_id.customer_id.user_sequence,
1451
+ "accountcode": str(case_id.customer_id.id),
1452
+ "type": "Disconnect",
1453
+ "subtype": case_id.ticket_type_id.name,
1454
+ "industry": "BSP Utility",
1455
+ "commodity": "power" if case_id.service_point_ids[0].pod_id else "gas",
1456
+ "order_date": case_id.disconnect_date.strftime("%Y-%m-%d"),
1457
+ "contract": True,
1458
+ "singlecontract": True,
1459
+ "assets": [asset_id],
1460
+ "options": {
1461
+ "userLanguage": "en-US",
1462
+ "remotePagination": True,
1463
+ "itemsForPage": 10,
1464
+ "cartItemsForPage": 10,
1465
+ },
1466
+ }
1467
+
1468
+ logs.append({"message": "Creating order", "data": {"body": body}})
1469
+
1470
+ response = request("POST", url, headers=headers, data=json_dumps(body))
1471
+ json = log_and_parse_response(
1472
+ response,
1473
+ "Order creation response",
1474
+ )
1475
+
1476
+ if response.status_code != 200:
1477
+ raise ValidationError("Failed to create order")
1478
+
1479
+ return json
1480
+
1481
+
1482
+ def bind_catalog(config_id, catalog_id, token):
1483
+ logs.append(
1484
+ {
1485
+ "message": "Binding catalog and order",
1486
+ "data": {
1487
+ "config_id": config_id,
1488
+ "catalog_id": catalog_id,
1489
+ },
1490
+ }
1491
+ )
1492
+
1493
+ headers = {
1494
+ "X-Auth-Request-Access-Token": "" + token,
1495
+ "Content-Type": "application/json",
1496
+ "generatesession": "true",
1497
+ }
1498
+ url = "http://b2w-cpq-catalog-navigator-node-service/v1/configurations/{}/catalogs/{}".format(
1499
+ config_id, catalog_id
1500
+ )
1501
+
1502
+ response = request("GET", url, headers=headers)
1503
+ json = log_and_parse_response(
1504
+ response,
1505
+ "Catalog binding response",
1506
+ )
1507
+
1508
+ if response.status_code != 200:
1509
+ raise ValidationError("Failed to set catalog id on order")
1510
+
1511
+ return json
1512
+
1513
+
1514
+ def checkout(config_id, token):
1515
+ logs.append(
1516
+ {
1517
+ "message": "Binding catalog and order",
1518
+ "data": {
1519
+ "config_id": config_id,
1520
+ },
1521
+ }
1522
+ )
1523
+
1524
+ headers = {
1525
+ "X-Auth-Request-Access-Token": "" + token,
1526
+ "Content-Type": "application/json",
1527
+ "generatesession": "true",
1528
+ }
1529
+ url = "http://b2w-cpq-order-management-service/v1/order/{}".format(config_id)
1530
+
1531
+ response = request("POST", url, headers=headers, data="{}")
1532
+ json = log_and_parse_response(
1533
+ response,
1534
+ "Checkout response",
1535
+ )
1536
+
1537
+ if response.status_code != 200:
1538
+ raise ValidationError("Failed to checkout")
1539
+
1540
+ return json
1541
+
1542
+
1543
+ try:
1544
+ StagingArea = env["symple.pb.process.data"]
1545
+ IrConfigParam = env["ir.config_parameter"].sudo()
1546
+ token = IrConfigParam.get_b2w_access_token()
1547
+
1548
+ code = case_id.service_point_ids[0].code
1549
+ asset = case_id.sudo().kv_store().get("asset")
1550
+ catalog_id = asset["catalogid"]
1551
+ logs.append({"message": "Asset loaded", "data": asset})
1552
+ order = create_order_disconnect(asset["_id"], token)
1553
+ order_id = order["_id"]
1554
+ config_id = order["conf_id"]
1555
+ logs.append({"message": "Order created", "data": order})
1556
+ bind_catalog(config_id, catalog_id, token)
1557
+ checkout(config_id, token)
1558
+
1559
+ kv_store = case_id.sudo().kv_store()
1560
+ kv_store.set("order_id", order_id)
1561
+ kv_store.set("asset_id", asset["_id"])
1562
+ kv_store.set("config_id", order["conf_id"])
1563
+ kv_store.set("contract_id", asset["contract_id"])
1564
+
1565
+ result = "OK"
1566
+
1567
+ except Exception as e:
1568
+ logs.append({"message": str(e), "traceback": format_exc()})
1569
+ case_id.write(
1570
+ {"error_message": "Errore durante l'esecuzione della fase: {}".format(str(e))}
1571
+ )
1572
+
1573
+
1574
+ if logs:
1575
+ log(json_dumps(logs))</field>
1576
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
1577
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
1578
+ <field name="is_a_postalizer_phase">False</field>
1579
+ <field name="is_compute_refund">False</field>
1580
+ <field name="is_dl">False</field>
1581
+ <field name="is_needs_child_case">False</field>
1582
+ <field name="is_pick_refund_template">False</field>
1583
+ <field name="is_process_managed">False</field>
1584
+ <field name="is_quote_accepted">False</field>
1585
+ <field name="is_quote_sent">False</field>
1586
+ <field name="is_timeout">False</field>
1587
+ <field name="is_voidable">False</field>
1588
+ <field name="name">A1577 - Chiusura Ordine CRM</field>
1589
+ <field name="set_result_automatically">from_code</field>
1590
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
1591
+ <field name="is_externally_integrated">False</field>
1592
+ <field name="is_process_cancellable_relaunchable">False</field>
1593
+ <field name="wizard_info">{"key":"value"}</field>
1594
+ <field name="phase_code">F-CC01-0016</field>
1595
+ <field name="check_closed_child_tickets">False</field>
1596
+ </record>
1597
+ <record id="symple_triplet_phase_A1321_-_Errore_CRM__RC1_" model="symple.triplet.phase">
1598
+ <field name="active">True</field>
1599
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C1616_-_Risoluzione_Errore_E-CC01-0034')])]"/>
1600
+ <field name="child_case">False</field>
1601
+ <field name="code"># Available variables:
1602
+ # - case_id: the case that just reached this phase
1603
+ # - request: allows you to make HTTP requests (method, url, headers, data)
1604
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
1605
+ # - json_load: allows you to use JSON.load to convert a json into an object
1606
+ # - env: Odoo Environment on which the action is triggered
1607
+ # - time, datetime, dateutil, timezone: useful Python libraries
1608
+ # - float_compare: Odoo function to compare floats based on specific precisions
1609
+ # - ValidationError: Warning Exception to use with raise
1610
+ # - Command: x2Many commands namespace
1611
+ # - OrderedDict: ordered dictionaries
1612
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
1613
+ # (line = case id, func = phase name)
1614
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
1615
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
1616
+ # To return a result, assign: result = {...}
1617
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
1618
+ # phase result will not be set.
1619
+
1620
+
1621
+
1622
+ </field>
1623
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','AMS')])" />
1624
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
1625
+ <field name="is_a_postalizer_phase">False</field>
1626
+ <field name="is_compute_refund">False</field>
1627
+ <field name="is_dl">False</field>
1628
+ <field name="is_needs_child_case">False</field>
1629
+ <field name="is_pick_refund_template">False</field>
1630
+ <field name="is_process_managed">False</field>
1631
+ <field name="is_quote_accepted">False</field>
1632
+ <field name="is_quote_sent">False</field>
1633
+ <field name="is_timeout">False</field>
1634
+ <field name="is_voidable">False</field>
1635
+ <field name="name">A1321 - Errore CRM (RC1)</field>
1636
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
1637
+ <field name="is_externally_integrated">False</field>
1638
+ <field name="is_process_cancellable_relaunchable">False</field>
1639
+ <field name="wizard_info">{"key":"value"}</field>
1640
+ <field name="phase_code">F-CC01-0017</field>
1641
+ <field name="check_closed_child_tickets">False</field>
1642
+ </record>
1643
+ <record id="symple_triplet_phase_A2398_-_Invio_ordine_CRM" model="symple.triplet.phase">
1644
+ <field name="active">True</field>
1645
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C1900_-_Integrazione_M2C_E-CC01-0035')])]"/>
1646
+ <field name="child_case">False</field>
1647
+ <field name="code"># Available variables:
1648
+ # - case_id: the case that just reached this phase
1649
+ # - request: allows you to make HTTP requests (method, url, headers, data)
1650
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
1651
+ # - json_load: allows you to use JSON.load to convert a json into an object
1652
+ # - env: Odoo Environment on which the action is triggered
1653
+ # - time, datetime, dateutil, timezone: useful Python libraries
1654
+ # - float_compare: Odoo function to compare floats based on specific precisions
1655
+ # - ValidationError: Warning Exception to use with raise
1656
+ # - Command: x2Many commands namespace
1657
+ # - OrderedDict: ordered dictionaries
1658
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
1659
+ # (line = case id, func = phase name)
1660
+ # To return a result, assign: result = {...}
1661
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
1662
+ # phase result will not be set.
1663
+
1664
+ logs = []
1665
+
1666
+
1667
+ def log_and_parse_response(response, log_message):
1668
+ try:
1669
+ json_data = response.json()
1670
+ logs.append({"message": log_message, "data": json_data})
1671
+ return json_data
1672
+ except Exception:
1673
+ logs.append({"message": log_message, "response_text": response.text})
1674
+ return response.text
1675
+
1676
+
1677
+ def get_contract(contract_id, token):
1678
+ response = request(
1679
+ "GET",
1680
+ "http://b2w-cpq-order-management-service/v1/contract/{}".format(contract_id),
1681
+ headers={"X-Auth-Request-Access-Token": "" + token},
1682
+ )
1683
+
1684
+ json = log_and_parse_response(response, "get_contract")
1685
+
1686
+ if response.status_code != 200:
1687
+ raise ValidationError("Failed to download contract from B2W API")
1688
+
1689
+ return json
1690
+
1691
+
1692
+ def write_disconnect_date(asset_id, token):
1693
+ dt = "{}T00:00:00.000+00:00".format(case_id.disconnect_date.isoformat())
1694
+ body = {"disconnectdate": dt}
1695
+
1696
+ response = request(
1697
+ "PATCH",
1698
+ "http://b2w-cpq-order-management-service/v1/asset/{}".format(asset_id),
1699
+ headers={"X-Auth-Request-Access-Token": "" + token},
1700
+ data=json_dumps(body),
1701
+ )
1702
+
1703
+ log_and_parse_response(response, "patch asset")
1704
+
1705
+ if response.status_code != 200:
1706
+ raise ValidationError("Failed to patch asset")
1707
+
1708
+
1709
+ def order2asset(order_id, token):
1710
+ url = "http://b2w-cpq-order-management-service/v1/order/asset/{}".format(order_id)
1711
+ headers = {
1712
+ "X-Auth-Request-Access-Token": "" + token,
1713
+ "Content-Type": "application/json",
1714
+ "generatesession": "true",
1715
+ }
1716
+
1717
+ response = request("POST", url, headers=headers, data=json_dumps([]))
1718
+ json = log_and_parse_response(
1719
+ response,
1720
+ "Order2Asset response",
1721
+ )
1722
+
1723
+ if response.status_code != 200:
1724
+ raise ValidationError("Failed to launch order2asset")
1725
+
1726
+ return json
1727
+
1728
+
1729
+ try:
1730
+ IrConfigParam = env["ir.config_parameter"].sudo()
1731
+ token = IrConfigParam.get_b2w_access_token()
1732
+
1733
+ kv_store = case_id.sudo().kv_store()
1734
+
1735
+ order_id = kv_store.get("order_id")
1736
+ contract_id = kv_store.get("contract_id")
1737
+ asset_id = kv_store.get("asset_id")
1738
+
1739
+ if not order_id or not contract_id:
1740
+ raise ValidationError("Order ID or Contract ID not found on case")
1741
+
1742
+ order2asset(order_id, token)
1743
+ logs.append({"message": "order2asset done"})
1744
+
1745
+ date_fmt = (case_id.disconnect_date or datetime.datetime.now()).strftime(
1746
+ "%Y-%m-%dT%H:%M:%S.%f"
1747
+ ) + "Z"
1748
+
1749
+ statemodel_result = IrConfigParam.update_b2w_statemodel(
1750
+ "cessato",
1751
+ sm_reason=case_id.ticket_type_id.name,
1752
+ expected_date=date_fmt,
1753
+ asset_id=asset_id,
1754
+ token=token,
1755
+ )
1756
+ logs.append({"message": "Statemodel updates on asset", "data": statemodel_result})
1757
+
1758
+ write_disconnect_date(asset_id, token)
1759
+
1760
+ case_id.service_point_ids[0].sudo().write(
1761
+ {
1762
+ "state": "inactive",
1763
+ "supply_end_date": datetime.datetime.today().strftime("%Y-%m-%d"),
1764
+ }
1765
+ )
1766
+
1767
+ contract = get_contract(contract_id, token)
1768
+
1769
+ if contract.get("status") == "disconnected":
1770
+ statemodel_result = IrConfigParam.update_b2w_statemodel(
1771
+ "cessato",
1772
+ sm_reason=case_id.ticket_type_id.name,
1773
+ expected_date=date_fmt,
1774
+ contract_id=contract_id,
1775
+ token=token,
1776
+ )
1777
+ logs.append(
1778
+ {"message": "Statemodel updates on contract", "data": statemodel_result}
1779
+ )
1780
+ kv_store.set("is_contract_disconnected", True)
1781
+ else:
1782
+ kv_store.set("is_contract_disconnected", False)
1783
+
1784
+ logs.append({"message": "service point updated"})
1785
+
1786
+ result = "OK"
1787
+
1788
+ except Exception as e:
1789
+ logs.append({"message": str(e), "traceback": format_exc()})
1790
+ case_id.write(
1791
+ {"error_message": "Errore durante l'esecuzione della fase: {}".format(str(e))}
1792
+ )
1793
+
1794
+
1795
+ if logs:
1796
+ log(json_dumps(logs))</field>
1797
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
1798
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
1799
+ <field name="is_a_postalizer_phase">False</field>
1800
+ <field name="is_compute_refund">False</field>
1801
+ <field name="is_dl">False</field>
1802
+ <field name="is_needs_child_case">False</field>
1803
+ <field name="is_pick_refund_template">False</field>
1804
+ <field name="is_process_managed">False</field>
1805
+ <field name="is_quote_accepted">False</field>
1806
+ <field name="is_quote_sent">False</field>
1807
+ <field name="is_timeout">False</field>
1808
+ <field name="is_voidable">False</field>
1809
+ <field name="name">A2398 - Invio ordine CRM</field>
1810
+ <field name="set_result_automatically">from_code</field>
1811
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
1812
+ <field name="is_externally_integrated">False</field>
1813
+ <field name="is_process_cancellable_relaunchable">False</field>
1814
+ <field name="wizard_info">{"key":"value"}</field>
1815
+ <field name="phase_code">F-CC01-0018</field>
1816
+ <field name="check_closed_child_tickets">False</field>
1817
+ </record>
1818
+ <record id="symple_triplet_phase_A0802_-_Integrazione_M2C" model="symple.triplet.phase">
1819
+ <field name="active">True</field>
1820
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C1904_-_In_attesa_esito_M2C_E-CC01-0036')])]"/>
1821
+ <field name="child_case">False</field>
1822
+ <field name="code"># Available variables:
1823
+ # - case_id: the case that just reached this phase
1824
+ # - request: allows you to make HTTP requests (method, url, headers, data)
1825
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
1826
+ # - json_load: allows you to use JSON.load to convert a json into an object
1827
+ # - env: Odoo Environment on which the action is triggered
1828
+ # - time, datetime, dateutil, timezone: useful Python libraries
1829
+ # - float_compare: Odoo function to compare floats based on specific precisions
1830
+ # - ValidationError: Warning Exception to use with raise
1831
+ # - Command: x2Many commands namespace
1832
+ # - OrderedDict: ordered dictionaries
1833
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
1834
+ # (line = case id, func = phase name)
1835
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
1836
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
1837
+ # To return a result, assign: result = {...}
1838
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
1839
+ # phase result will not be set.
1840
+
1841
+
1842
+ logs = []
1843
+
1844
+ ServicePoint = env["service.point"]
1845
+
1846
+ try:
1847
+ is_contract_done, contract_id = case_id.sudo().kv_store().get_many(
1848
+ "is_contract_disconnected", "contract_id"
1849
+ )
1850
+ date_fmt = case_id.disconnect_date.strftime("%d%m%Y")
1851
+
1852
+ logs.append({"date": date_fmt})
1853
+
1854
+ next_phase_result = (
1855
+ case_id.triplet_active_phase_id.allowed_phase_result_ids.filtered(
1856
+ lambda x: x.wizard_result == "SUCCESS"
1857
+ )[0]
1858
+ )
1859
+ ending_phase_result = (
1860
+ next_phase_result.next_phase_id.allowed_phase_result_ids.filtered(
1861
+ lambda x: x.wizard_result == "SUCCESS"
1862
+ )[0].state_code
1863
+ )
1864
+
1865
+ sp = case_id.service_point_ids[0]
1866
+ bp = sp.billing_profile_id
1867
+ podPdr = sp.pod_id if sp.pod_id else sp.pdr_id
1868
+
1869
+ json_dict = {
1870
+ "caseId": str(case_id.id),
1871
+ "flow": "m2c_passthrough",
1872
+ "azione": {
1873
+ "protocollo": str(case_id.id),
1874
+ "case": case_id.ticket_type_id.name,
1875
+ "cliente": {
1876
+ "cCodiceBP": case_id.customer_id.golden_key,
1877
+ "cCodiceCrm": case_id.customer_code,
1878
+ "contrattiMandato": [
1879
+ {
1880
+ "cCodiceContrattoMandato": bp.name,
1881
+ "contratti": {
1882
+ "cCodiceContratto": contract_id,
1883
+ "forniture": [
1884
+ {
1885
+ "cPodPdr": podPdr.code,
1886
+ "cCodicePR": sp.code,
1887
+ "cCausaleCessazione": case_id.ticket_type_id.name,
1888
+ "cStatoFornitura": "CESSATO",
1889
+ "dFineContrattoFornitura": date_fmt,
1890
+ }
1891
+ ],
1892
+ },
1893
+ }
1894
+ ],
1895
+ },
1896
+ },
1897
+ "m2c_callback_esito": ending_phase_result,
1898
+ }
1899
+
1900
+ if is_contract_done:
1901
+ json_dict["azione"]["cliente"]["contrattiMandato"][0]["contratti"][
1902
+ "dFineContratto"
1903
+ ] = date_fmt
1904
+
1905
+ has_active_points = ServicePoint.search(
1906
+ [("client_id", "=", case_id.customer_id.id), ("state", "!=", "inactive")]
1907
+ ).exists()
1908
+
1909
+ if not has_active_points:
1910
+ json_dict["azione"]["cliente"]["xStatoBp"] = "CESSATO"
1911
+
1912
+ tenant_id = env["ir.config_parameter"].sudo().get_param("m2c_header_tenant_id")
1913
+ org_token = env["ir.config_parameter"].sudo().get_param("m2c_header_org_token")
1914
+ token = env["symple.pb.launcher"].get_access_token()
1915
+ headers = {
1916
+ "tenantId": tenant_id,
1917
+ "orgToken": org_token,
1918
+ "Content-Type": "application/json",
1919
+ "X-Auth-Request-Access-Token": token,
1920
+ }
1921
+
1922
+ logs.append({"message": "m2c", "data": json_dict})
1923
+
1924
+ m2c_url = "http://b2w-symphony-rest-service/api/symphony/process-instances/M2C_passthrough"
1925
+ response = request("POST", m2c_url, headers=headers, data=json_dumps(json_dict))
1926
+ result = "OK"
1927
+
1928
+
1929
+ except Exception as e:
1930
+ logs.append({"message": str(e), "traceback": format_exc()})
1931
+ prev = case_id.info_message + "\n" if case_id.info_message else ""
1932
+ case_id.write({"info_message": prev + str(e)})
1933
+
1934
+ if logs:
1935
+ log(json_dumps(logs))</field>
1936
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
1937
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
1938
+ <field name="is_a_postalizer_phase">False</field>
1939
+ <field name="is_compute_refund">False</field>
1940
+ <field name="is_dl">False</field>
1941
+ <field name="is_needs_child_case">False</field>
1942
+ <field name="is_pick_refund_template">False</field>
1943
+ <field name="is_process_managed">False</field>
1944
+ <field name="is_quote_accepted">False</field>
1945
+ <field name="is_quote_sent">False</field>
1946
+ <field name="is_timeout">False</field>
1947
+ <field name="is_voidable">False</field>
1948
+ <field name="name">A0802 - Integrazione M2C</field>
1949
+ <field name="set_result_automatically">from_code</field>
1950
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
1951
+ <field name="is_externally_integrated">False</field>
1952
+ <field name="is_process_cancellable_relaunchable">False</field>
1953
+ <field name="wizard_info">{"key":"value"}</field>
1954
+ <field name="phase_code">F-CC01-0019</field>
1955
+ <field name="check_closed_child_tickets">False</field>
1956
+ </record>
1957
+ <record id="symple_triplet_phase_A0803_-_In_attesa_esito_M2C" model="symple.triplet.phase">
1958
+ <field name="active">True</field>
1959
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C1006_-_OK_Integrazione_M2C_E-CC01-0037'),ref('symple_triplet_phase_result_C2551_-_OK_Intregrazione_M2C_-_Fatture_di_Storno_da_emettere_E-CC01-0038'),ref('symple_triplet_phase_result_C2552_-_Elaborazione_bloccata_nel_M2C_E-CC01-0039')])]"/>
1960
+ <field name="child_case">False</field>
1961
+ <field name="code"># Available variables:
1962
+ # - case_id: the case that just reached this phase
1963
+ # - request: allows you to make HTTP requests (method, url, headers, data)
1964
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
1965
+ # - json_load: allows you to use JSON.load to convert a json into an object
1966
+ # - env: Odoo Environment on which the action is triggered
1967
+ # - time, datetime, dateutil, timezone: useful Python libraries
1968
+ # - float_compare: Odoo function to compare floats based on specific precisions
1969
+ # - ValidationError: Warning Exception to use with raise
1970
+ # - Command: x2Many commands namespace
1971
+ # - OrderedDict: ordered dictionaries
1972
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
1973
+ # (line = case id, func = phase name)
1974
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
1975
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
1976
+ # To return a result, assign: result = {...}
1977
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
1978
+ # phase result will not be set.
1979
+
1980
+
1981
+
1982
+ </field>
1983
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
1984
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
1985
+ <field name="is_a_postalizer_phase">False</field>
1986
+ <field name="is_compute_refund">False</field>
1987
+ <field name="is_dl">False</field>
1988
+ <field name="is_needs_child_case">False</field>
1989
+ <field name="is_pick_refund_template">False</field>
1990
+ <field name="is_process_managed">False</field>
1991
+ <field name="is_quote_accepted">False</field>
1992
+ <field name="is_quote_sent">False</field>
1993
+ <field name="is_timeout">False</field>
1994
+ <field name="is_voidable">False</field>
1995
+ <field name="name">A0803 - In attesa esito M2C</field>
1996
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
1997
+ <field name="is_externally_integrated">False</field>
1998
+ <field name="is_process_cancellable_relaunchable">False</field>
1999
+ <field name="wizard_info">{"key":"value"}</field>
2000
+ <field name="phase_code">F-CC01-0020</field>
2001
+ <field name="check_closed_child_tickets">False</field>
2002
+ </record>
2003
+ <record id="symple_triplet_phase_A1836_-_Apertura_case_figlio" model="symple.triplet.phase">
2004
+ <field name="active">True</field>
2005
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C2550_-_case_creato_E-CC01-0040')])]"/>
2006
+ <field name="child_case">False</field>
2007
+ <field name="code"># Available variables:
2008
+ # - case_id: the case that just reached this phase
2009
+ # - request: allows you to make HTTP requests (method, url, headers, data)
2010
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
2011
+ # - json_load: allows you to use JSON.load to convert a json into an object
2012
+ # - env: Odoo Environment on which the action is triggered
2013
+ # - time, datetime, dateutil, timezone: useful Python libraries
2014
+ # - float_compare: Odoo function to compare floats based on specific precisions
2015
+ # - ValidationError: Warning Exception to use with raise
2016
+ # - Command: x2Many commands namespace
2017
+ # - OrderedDict: ordered dictionaries
2018
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
2019
+ # (line = case id, func = phase name)
2020
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
2021
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
2022
+ # To return a result, assign: result = {...}
2023
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
2024
+ # phase result will not be set.
2025
+
2026
+
2027
+
2028
+ </field>
2029
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
2030
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
2031
+ <field name="is_a_postalizer_phase">False</field>
2032
+ <field name="is_compute_refund">False</field>
2033
+ <field name="is_dl">False</field>
2034
+ <field name="is_needs_child_case">False</field>
2035
+ <field name="is_pick_refund_template">False</field>
2036
+ <field name="is_process_managed">False</field>
2037
+ <field name="is_quote_accepted">False</field>
2038
+ <field name="is_quote_sent">False</field>
2039
+ <field name="is_timeout">False</field>
2040
+ <field name="is_voidable">False</field>
2041
+ <field name="name">A1836 - Apertura case figlio</field>
2042
+ <field name="set_result_automatically">from_code</field>
2043
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
2044
+ <field name="is_externally_integrated">False</field>
2045
+ <field name="is_process_cancellable_relaunchable">False</field>
2046
+ <field name="wizard_info">{"key":"value"}</field>
2047
+ <field name="phase_code">F-CC01-0021</field>
2048
+ <field name="check_closed_child_tickets">False</field>
2049
+ </record>
2050
+ <record id="symple_triplet_phase_A1595_-_Invio_Annullamento_alla_Market_Communication" model="symple.triplet.phase">
2051
+ <field name="active">True</field>
2052
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C1019_-_Inviata_E-CC01-0041')])]"/>
2053
+ <field name="child_case">False</field>
2054
+ <field name="code"># Available variables:
2055
+ # - case_id: the case that just reached this phase
2056
+ # - request: allows you to make HTTP requests (method, url, headers, data)
2057
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
2058
+ # - json_load: allows you to use JSON.load to convert a json into an object
2059
+ # - env: Odoo Environment on which the action is triggered
2060
+ # - time, datetime, dateutil, timezone: useful Python libraries
2061
+ # - float_compare: Odoo function to compare floats based on specific precisions
2062
+ # - ValidationError: Warning Exception to use with raise
2063
+ # - Command: x2Many commands namespace
2064
+ # - OrderedDict: ordered dictionaries
2065
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
2066
+ # (line = case id, func = phase name)
2067
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
2068
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
2069
+ # To return a result, assign: result = {...}
2070
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
2071
+ # phase result will not be set.
2072
+
2073
+ logs = []
2074
+ bypass = False
2075
+
2076
+
2077
+ def _hub(x):
2078
+ return x.flow_code == "HUB"
2079
+
2080
+
2081
+ def _0100(x):
2082
+ return x.flow_code == "0100"
2083
+
2084
+
2085
+ def get_apr_reason():
2086
+ kv_store = case_id.sudo().kv_store()
2087
+ reason_code = kv_store.get("annulment_wizard_motivation")
2088
+ map_motivazione = {
2089
+ "RC01": "Annullamento RC per esecuzione di altra prestazione",
2090
+ "RC02": "Annullamento RC per disattivazione della fornitura",
2091
+ "RC04": "Revoca risoluzione per pratica errata",
2092
+ "RG01": "Revoca RCG per esecuzione di altra prestazione",
2093
+ "RG03": "Revoca risoluzione per errata trasmissione",
2094
+ }
2095
+
2096
+ return reason_code, map_motivazione.get(reason_code, "")
2097
+
2098
+
2099
+ def get_last_hub():
2100
+ return case_id.market_comm_event_log_ids.filtered(_hub)
2101
+
2102
+
2103
+ def get_last_0100():
2104
+ logs = case_id.market_comm_event_log_ids.filtered(_0100)
2105
+ return logs[-1]
2106
+
2107
+
2108
+ def main():
2109
+ ifs_data_message = None
2110
+ sp = case_id.service_point_ids[0]
2111
+ is_ele = sp.pod_id.exists()
2112
+
2113
+ log_hub = get_last_hub()
2114
+ log_100 = get_last_0100()
2115
+
2116
+ if not log_hub or not log_100:
2117
+ raise Exception("Payload HUB e 0100 non recuperati.")
2118
+
2119
+ content_hub = json_loads(log_hub.inner_payload)
2120
+ content_100 = json_loads(log_100.inner_payload)
2121
+
2122
+ causale, motivazione = get_apr_reason()
2123
+ cp_utente = content_hub.get("CP_UTENTE")
2124
+ cp_gestore = content_100.get("CP_GESTORE")
2125
+
2126
+ ifs_data_message = {
2127
+ "COD_SERVIZIO": "APR",
2128
+ "COD_FLUSSO": "0050",
2129
+ "CP_GESTORE_ANN": cp_gestore,
2130
+ "CP_UTENTE_ANN": cp_utente,
2131
+ "COD_CAUSALE": causale,
2132
+ "MOTIVAZIONE": motivazione,
2133
+ "COD_POD_PDR": sp.pod_id.code if is_ele else sp.pdr_id.code,
2134
+ "SETTORE": "G",
2135
+ "NOTE": "",
2136
+ "EMAIL": "",
2137
+ "COD_RICHIESTA": content_hub.get("COD_RICHIESTA"),
2138
+ "OWNER": "SORGE",
2139
+ }
2140
+
2141
+ ifs_dict = {
2142
+ "ifs_code": "APR",
2143
+ "case_id": str(case_id.id),
2144
+ "ifs_data_message": ifs_data_message,
2145
+ "is_annullment": True,
2146
+ "cp_utente": cp_utente,
2147
+ "cp_gestore": cp_gestore,
2148
+ }
2149
+
2150
+ ifs_json = json_dumps(ifs_dict)
2151
+ tenant_id = env["ir.config_parameter"].sudo().get_param("m2c_header_tenant_id")
2152
+ org_token = env["ir.config_parameter"].sudo().get_param("m2c_header_org_token")
2153
+ headers = {"tenantId": tenant_id, "orgToken": org_token}
2154
+ btw_url = "http://b2w-symphony-rest-service/api/symphony/process-instances/ml_IFS_passthrough"
2155
+ response = request("POST", btw_url, headers=headers, data=ifs_json)
2156
+
2157
+ if str(response.status_code) != "200":
2158
+ raise ValidationError(str(response.status_code) + " " + str(response.text))
2159
+
2160
+ return "OK"
2161
+
2162
+
2163
+ try:
2164
+ result = main()
2165
+ except Exception as e:
2166
+ logs.append({"message": str(e), "traceback": format_exc()})
2167
+ prev = case_id.info_message + "\n" if case_id.info_message else ""
2168
+ case_id.write({"error_message": str(e)})
2169
+
2170
+ result = "KO"
2171
+
2172
+
2173
+ if logs:
2174
+ log(json_dumps(logs))</field>
2175
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
2176
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
2177
+ <field name="is_a_postalizer_phase">False</field>
2178
+ <field name="is_compute_refund">False</field>
2179
+ <field name="is_dl">False</field>
2180
+ <field name="is_needs_child_case">False</field>
2181
+ <field name="is_pick_refund_template">False</field>
2182
+ <field name="is_process_managed">False</field>
2183
+ <field name="is_quote_accepted">False</field>
2184
+ <field name="is_quote_sent">False</field>
2185
+ <field name="is_timeout">False</field>
2186
+ <field name="is_voidable">False</field>
2187
+ <field name="name">A1595 - Invio Annullamento alla Market Communication</field>
2188
+ <field name="set_result_automatically">from_code</field>
2189
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
2190
+ <field name="is_externally_integrated">False</field>
2191
+ <field name="is_process_cancellable_relaunchable">False</field>
2192
+ <field name="wizard_info">{"key":"value"}</field>
2193
+ <field name="phase_code">F-CC01-0022</field>
2194
+ <field name="check_closed_child_tickets">False</field>
2195
+ </record>
2196
+ <record id="symple_triplet_phase_A1767_-_In_attesa_check_IFS_Annullamento" model="symple.triplet.phase">
2197
+ <field name="active">True</field>
2198
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C2475_-_OK_-_Ammissibilit__Annullamento_Hub_E-CC01-0042'),ref('symple_triplet_phase_result_C2476_-_KO_-_Ammissibilit__Annullamento_Hub_E-CC01-0043'),ref('symple_triplet_phase_result_C1449_-_KO_controlli_RCU___Data_decorrenza_E-CC01-0045'),ref('symple_triplet_phase_result_C1448_-_OK_controlli_RCU_E-CC01-0046'),ref('symple_triplet_phase_result_C1763_-_Annullamento_passivo_dal_SII_E-CC01-0047'),ref('symple_triplet_phase_result_C2599_-_annullamento_confermato_E-CC01-00082')])]"/>
2199
+ <field name="child_case">False</field>
2200
+ <field name="code"># Available variables:
2201
+ # - case_id: the case that just reached this phase
2202
+ # - request: allows you to make HTTP requests (method, url, headers, data)
2203
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
2204
+ # - json_load: allows you to use JSON.load to convert a json into an object
2205
+ # - env: Odoo Environment on which the action is triggered
2206
+ # - time, datetime, dateutil, timezone: useful Python libraries
2207
+ # - float_compare: Odoo function to compare floats based on specific precisions
2208
+ # - ValidationError: Warning Exception to use with raise
2209
+ # - Command: x2Many commands namespace
2210
+ # - OrderedDict: ordered dictionaries
2211
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
2212
+ # (line = case id, func = phase name)
2213
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
2214
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
2215
+ # To return a result, assign: result = {...}
2216
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
2217
+ # phase result will not be set.
2218
+
2219
+
2220
+
2221
+ </field>
2222
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
2223
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
2224
+ <field name="is_a_postalizer_phase">False</field>
2225
+ <field name="is_compute_refund">False</field>
2226
+ <field name="is_dl">False</field>
2227
+ <field name="is_needs_child_case">False</field>
2228
+ <field name="is_pick_refund_template">False</field>
2229
+ <field name="is_process_managed">False</field>
2230
+ <field name="is_quote_accepted">False</field>
2231
+ <field name="is_quote_sent">False</field>
2232
+ <field name="is_timeout">False</field>
2233
+ <field name="is_voidable">False</field>
2234
+ <field name="name">A1767 - In attesa check IFS Annullamento</field>
2235
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
2236
+ <field name="is_externally_integrated">False</field>
2237
+ <field name="is_process_cancellable_relaunchable">False</field>
2238
+ <field name="wizard_info">{"key":"value"}</field>
2239
+ <field name="phase_code">F-CC01-0023</field>
2240
+ <field name="check_closed_child_tickets">False</field>
2241
+ </record>
2242
+ <record id="symple_triplet_phase_A2562_-_verifica_avvio_gestione_manuale_annullamento" model="symple.triplet.phase">
2243
+ <field name="active">True</field>
2244
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C2508_-_gestione_fuori_linea_E-CC01-0048'),ref('symple_triplet_phase_result_C2509_-_Da_gestire_nuovo_invio_automatico_E-CC01-0049'),ref('symple_triplet_phase_result_C1449_-_KO_controlli_RCU___Data_decorrenza_E-CC01-0050'),ref('symple_triplet_phase_result_C1448_-_OK_controlli_RCU_E-CC01-0051'),ref('symple_triplet_phase_result_C1763_-_Annullamento_passivo_dal_SII_E-CC01-0052')])]"/>
2245
+ <field name="child_case">False</field>
2246
+ <field name="code"># Available variables:
2247
+ # - case_id: the case that just reached this phase
2248
+ # - request: allows you to make HTTP requests (method, url, headers, data)
2249
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
2250
+ # - json_load: allows you to use JSON.load to convert a json into an object
2251
+ # - env: Odoo Environment on which the action is triggered
2252
+ # - time, datetime, dateutil, timezone: useful Python libraries
2253
+ # - float_compare: Odoo function to compare floats based on specific precisions
2254
+ # - ValidationError: Warning Exception to use with raise
2255
+ # - Command: x2Many commands namespace
2256
+ # - OrderedDict: ordered dictionaries
2257
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
2258
+ # (line = case id, func = phase name)
2259
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
2260
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
2261
+ # To return a result, assign: result = {...}
2262
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
2263
+ # phase result will not be set.
2264
+
2265
+
2266
+
2267
+ </field>
2268
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','BOT')])" />
2269
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
2270
+ <field name="is_a_postalizer_phase">False</field>
2271
+ <field name="is_compute_refund">False</field>
2272
+ <field name="is_dl">False</field>
2273
+ <field name="is_needs_child_case">False</field>
2274
+ <field name="is_pick_refund_template">False</field>
2275
+ <field name="is_process_managed">False</field>
2276
+ <field name="is_quote_accepted">False</field>
2277
+ <field name="is_quote_sent">False</field>
2278
+ <field name="is_timeout">False</field>
2279
+ <field name="is_voidable">False</field>
2280
+ <field name="name">A2562 - verifica avvio gestione manuale annullamento</field>
2281
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
2282
+ <field name="is_externally_integrated">False</field>
2283
+ <field name="is_process_cancellable_relaunchable">False</field>
2284
+ <field name="wizard_info">{"key":"value"}</field>
2285
+ <field name="phase_code">F-CC01-0024</field>
2286
+ <field name="check_closed_child_tickets">False</field>
2287
+ </record>
2288
+ <record id="symple_triplet_phase_A2142_-_Invio_alla_marketcom_annullamento_forzato" model="symple.triplet.phase">
2289
+ <field name="active">True</field>
2290
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C1019_-_Inviata_E-CC01-0053')])]"/>
2291
+ <field name="child_case">False</field>
2292
+ <field name="code"># Available variables:
2293
+ # - case_id: the case that just reached this phase
2294
+ # - request: allows you to make HTTP requests (method, url, headers, data)
2295
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
2296
+ # - json_load: allows you to use JSON.load to convert a json into an object
2297
+ # - env: Odoo Environment on which the action is triggered
2298
+ # - time, datetime, dateutil, timezone: useful Python libraries
2299
+ # - float_compare: Odoo function to compare floats based on specific precisions
2300
+ # - ValidationError: Warning Exception to use with raise
2301
+ # - Command: x2Many commands namespace
2302
+ # - OrderedDict: ordered dictionaries
2303
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
2304
+ # (line = case id, func = phase name)
2305
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
2306
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
2307
+ # To return a result, assign: result = {...}
2308
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
2309
+ # phase result will not be set.
2310
+
2311
+ logs = []
2312
+ bypass = True
2313
+
2314
+
2315
+ def get_apr_reason():
2316
+ kv_store = case_id.sudo().kv_store()
2317
+ reason_code = kv_store.get("annulment_wizard_motivation")
2318
+ map_motivazione = {
2319
+ "RC01": "Annullamento RC per esecuzione di altra prestazione",
2320
+ "RC02": "Annullamento RC per disattivazione della fornitura",
2321
+ "RC04": "Revoca risoluzione per pratica errata",
2322
+ "RG01": "Revoca RCG per esecuzione di altra prestazione",
2323
+ "RG03": "Revoca risoluzione per errata trasmissione",
2324
+ }
2325
+
2326
+ return reason_code, map_motivazione.get(reason_code, "")
2327
+
2328
+
2329
+ try:
2330
+ sp = case_id.service_point_ids[0]
2331
+ podPdr = sp.pod_id if sp.pod_id else sp.pdr_id
2332
+ cod_causale, motivazione = get_apr_reason()
2333
+
2334
+ tenant_id = env["ir.config_parameter"].sudo().get_param("m2c_header_tenant_id")
2335
+ org_token = env["ir.config_parameter"].sudo().get_param("m2c_header_org_token")
2336
+ headers = {"tenantId": tenant_id, "orgToken": org_token}
2337
+ ok_payload = {
2338
+ "refName": "Annulment",
2339
+ "refId": case_id.symphonie_process,
2340
+ "messageProcessVars": {
2341
+ "ifs_code": "APR",
2342
+ "bypass": bypass,
2343
+ "aprInfo": {
2344
+ "COD_CAUSALE": cod_causale,
2345
+ "MOTIVAZIONE": motivazione,
2346
+ "COD_POD_PDR": podPdr.code,
2347
+ },
2348
+ },
2349
+ }
2350
+
2351
+ url = env["ir.config_parameter"].sudo().get_param("b2w_wake_up_process_url")
2352
+ payload = json_dumps(ok_payload)
2353
+ response = request("POST", url, data=payload, headers=headers)
2354
+
2355
+ if response.status_code != 200:
2356
+ raise ValidationError("Failed to launch VT.0040")
2357
+
2358
+ result = "OK"
2359
+
2360
+ except Exception as e:
2361
+ prev = case_id.info_message + "\n" if case_id.info_message else ""
2362
+ case_id.write({"info_message": prev + str(e)})
2363
+
2364
+ log(json_dumps(logs))</field>
2365
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
2366
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
2367
+ <field name="is_a_postalizer_phase">False</field>
2368
+ <field name="is_compute_refund">False</field>
2369
+ <field name="is_dl">False</field>
2370
+ <field name="is_needs_child_case">False</field>
2371
+ <field name="is_pick_refund_template">False</field>
2372
+ <field name="is_process_managed">False</field>
2373
+ <field name="is_quote_accepted">False</field>
2374
+ <field name="is_quote_sent">False</field>
2375
+ <field name="is_timeout">False</field>
2376
+ <field name="is_voidable">False</field>
2377
+ <field name="name">A2142 - Invio alla marketcom annullamento forzato</field>
2378
+ <field name="set_result_automatically">from_code</field>
2379
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
2380
+ <field name="is_externally_integrated">False</field>
2381
+ <field name="is_process_cancellable_relaunchable">False</field>
2382
+ <field name="wizard_info">{"key":"value"}</field>
2383
+ <field name="phase_code">F-CC01-0025</field>
2384
+ <field name="check_closed_child_tickets">False</field>
2385
+ </record>
2386
+ <record id="symple_triplet_phase_A2143_-_In_attesa_check_IFS_Annullamento_forzato" model="symple.triplet.phase">
2387
+ <field name="active">True</field>
2388
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C2225_-_KO_-_Ammissibilit__Hub_E-CC01-0054'),ref('symple_triplet_phase_result_C2224_-_OK_-_Ammissibilit__Hub_E-CC01-0055')])]"/>
2389
+ <field name="child_case">False</field>
2390
+ <field name="code"># Available variables:
2391
+ # - case_id: the case that just reached this phase
2392
+ # - request: allows you to make HTTP requests (method, url, headers, data)
2393
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
2394
+ # - json_load: allows you to use JSON.load to convert a json into an object
2395
+ # - env: Odoo Environment on which the action is triggered
2396
+ # - time, datetime, dateutil, timezone: useful Python libraries
2397
+ # - float_compare: Odoo function to compare floats based on specific precisions
2398
+ # - ValidationError: Warning Exception to use with raise
2399
+ # - Command: x2Many commands namespace
2400
+ # - OrderedDict: ordered dictionaries
2401
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
2402
+ # (line = case id, func = phase name)
2403
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
2404
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
2405
+ # To return a result, assign: result = {...}
2406
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
2407
+ # phase result will not be set.
2408
+
2409
+
2410
+
2411
+ </field>
2412
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
2413
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
2414
+ <field name="is_a_postalizer_phase">False</field>
2415
+ <field name="is_compute_refund">False</field>
2416
+ <field name="is_dl">False</field>
2417
+ <field name="is_needs_child_case">False</field>
2418
+ <field name="is_pick_refund_template">False</field>
2419
+ <field name="is_process_managed">False</field>
2420
+ <field name="is_quote_accepted">False</field>
2421
+ <field name="is_quote_sent">False</field>
2422
+ <field name="is_timeout">False</field>
2423
+ <field name="is_voidable">False</field>
2424
+ <field name="name">A2143 - In attesa check IFS Annullamento forzato</field>
2425
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
2426
+ <field name="is_externally_integrated">False</field>
2427
+ <field name="is_process_cancellable_relaunchable">False</field>
2428
+ <field name="wizard_info">{"key":"value"}</field>
2429
+ <field name="phase_code">F-CC01-0026</field>
2430
+ <field name="check_closed_child_tickets">False</field>
2431
+ </record>
2432
+ <record id="symple_triplet_phase_A1732_-_Gestione_scarti_da_cruscotto_annullamento" model="symple.triplet.phase">
2433
+ <field name="active">True</field>
2434
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C2416_-_risottomessa_da_cruscotto_E-CC01-0056'),ref('symple_triplet_phase_result_C1931_-_Errore_non_rilavorabile_E-CC01-0057'),ref('symple_triplet_phase_result_C1449_-_KO_controlli_RCU___Data_decorrenza_E-CC01-0058'),ref('symple_triplet_phase_result_C1448_-_OK_controlli_RCU_E-CC01-0059'),ref('symple_triplet_phase_result_C1763_-_Annullamento_passivo_dal_SII_E-CC01-0060')])]"/>
2435
+ <field name="child_case">False</field>
2436
+ <field name="code"># Available variables:
2437
+ # - case_id: the case that just reached this phase
2438
+ # - request: allows you to make HTTP requests (method, url, headers, data)
2439
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
2440
+ # - json_load: allows you to use JSON.load to convert a json into an object
2441
+ # - env: Odoo Environment on which the action is triggered
2442
+ # - time, datetime, dateutil, timezone: useful Python libraries
2443
+ # - float_compare: Odoo function to compare floats based on specific precisions
2444
+ # - ValidationError: Warning Exception to use with raise
2445
+ # - Command: x2Many commands namespace
2446
+ # - OrderedDict: ordered dictionaries
2447
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
2448
+ # (line = case id, func = phase name)
2449
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
2450
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
2451
+ # To return a result, assign: result = {...}
2452
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
2453
+ # phase result will not be set.
2454
+
2455
+
2456
+
2457
+ </field>
2458
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
2459
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
2460
+ <field name="is_a_postalizer_phase">False</field>
2461
+ <field name="is_compute_refund">False</field>
2462
+ <field name="is_dl">False</field>
2463
+ <field name="is_needs_child_case">False</field>
2464
+ <field name="is_pick_refund_template">False</field>
2465
+ <field name="is_process_managed">False</field>
2466
+ <field name="is_quote_accepted">False</field>
2467
+ <field name="is_quote_sent">False</field>
2468
+ <field name="is_timeout">False</field>
2469
+ <field name="is_voidable">False</field>
2470
+ <field name="name">A1732 - Gestione scarti da cruscotto annullamento</field>
2471
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
2472
+ <field name="is_externally_integrated">False</field>
2473
+ <field name="is_process_cancellable_relaunchable">False</field>
2474
+ <field name="wizard_info">{"key":"value"}</field>
2475
+ <field name="phase_code">F-CC01-0027</field>
2476
+ <field name="check_closed_child_tickets">False</field>
2477
+ </record>
2478
+ <record id="symple_triplet_phase_A1832_-_gestione_scarti_da_cruscotto_annullamento_forzato" model="symple.triplet.phase">
2479
+ <field name="active">True</field>
2480
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C2416_-_risottomessa_da_cruscotto_E-CC01-0061'),ref('symple_triplet_phase_result_C1931_-_Errore_non_rilavorabile_E-CC01-0062'),ref('symple_triplet_phase_result_C1449_-_KO_controlli_RCU___Data_decorrenza_E-CC01-0063'),ref('symple_triplet_phase_result_C1448_-_OK_controlli_RCU_E-CC01-0064')])]"/>
2481
+ <field name="child_case">False</field>
2482
+ <field name="code"># Available variables:
2483
+ # - case_id: the case that just reached this phase
2484
+ # - request: allows you to make HTTP requests (method, url, headers, data)
2485
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
2486
+ # - json_load: allows you to use JSON.load to convert a json into an object
2487
+ # - env: Odoo Environment on which the action is triggered
2488
+ # - time, datetime, dateutil, timezone: useful Python libraries
2489
+ # - float_compare: Odoo function to compare floats based on specific precisions
2490
+ # - ValidationError: Warning Exception to use with raise
2491
+ # - Command: x2Many commands namespace
2492
+ # - OrderedDict: ordered dictionaries
2493
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
2494
+ # (line = case id, func = phase name)
2495
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
2496
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
2497
+ # To return a result, assign: result = {...}
2498
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
2499
+ # phase result will not be set.
2500
+
2501
+
2502
+
2503
+ </field>
2504
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
2505
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
2506
+ <field name="is_a_postalizer_phase">False</field>
2507
+ <field name="is_compute_refund">False</field>
2508
+ <field name="is_dl">False</field>
2509
+ <field name="is_needs_child_case">False</field>
2510
+ <field name="is_pick_refund_template">False</field>
2511
+ <field name="is_process_managed">False</field>
2512
+ <field name="is_quote_accepted">False</field>
2513
+ <field name="is_quote_sent">False</field>
2514
+ <field name="is_timeout">False</field>
2515
+ <field name="is_voidable">False</field>
2516
+ <field name="name">A1832 - gestione scarti da cruscotto annullamento forzato</field>
2517
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
2518
+ <field name="is_externally_integrated">False</field>
2519
+ <field name="is_process_cancellable_relaunchable">False</field>
2520
+ <field name="wizard_info">{"key":"value"}</field>
2521
+ <field name="phase_code">F-CC01-0028</field>
2522
+ <field name="check_closed_child_tickets">False</field>
2523
+ </record>
2524
+ <record id="symple_triplet_phase_A0833_-_In_attesa_ricezione_Ammissibilit__Annullamento" model="symple.triplet.phase">
2525
+ <field name="active">True</field>
2526
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C1037_-_Ammissibilit__OK_E-CC01-0065'),ref('symple_triplet_phase_result_C1038_-_Ammissibilit__KO_E-CC01-0066'),ref('symple_triplet_phase_result_C1449_-_KO_controlli_RCU___Data_decorrenza_E-CC01-0067'),ref('symple_triplet_phase_result_C1448_-_OK_controlli_RCU_E-CC01-0068'),ref('symple_triplet_phase_result_C1763_-_Annullamento_passivo_dal_SII_E-CC01-0069')])]"/>
2527
+ <field name="child_case">False</field>
2528
+ <field name="code"># Available variables:
2529
+ # - case_id: the case that just reached this phase
2530
+ # - request: allows you to make HTTP requests (method, url, headers, data)
2531
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
2532
+ # - json_load: allows you to use JSON.load to convert a json into an object
2533
+ # - env: Odoo Environment on which the action is triggered
2534
+ # - time, datetime, dateutil, timezone: useful Python libraries
2535
+ # - float_compare: Odoo function to compare floats based on specific precisions
2536
+ # - ValidationError: Warning Exception to use with raise
2537
+ # - Command: x2Many commands namespace
2538
+ # - OrderedDict: ordered dictionaries
2539
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
2540
+ # (line = case id, func = phase name)
2541
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
2542
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
2543
+ # To return a result, assign: result = {...}
2544
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
2545
+ # phase result will not be set.
2546
+
2547
+
2548
+
2549
+ </field>
2550
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
2551
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
2552
+ <field name="is_a_postalizer_phase">False</field>
2553
+ <field name="is_compute_refund">False</field>
2554
+ <field name="is_dl">False</field>
2555
+ <field name="is_needs_child_case">False</field>
2556
+ <field name="is_pick_refund_template">False</field>
2557
+ <field name="is_process_managed">False</field>
2558
+ <field name="is_quote_accepted">False</field>
2559
+ <field name="is_quote_sent">False</field>
2560
+ <field name="is_timeout">False</field>
2561
+ <field name="is_voidable">False</field>
2562
+ <field name="name">A0833 - In attesa ricezione Ammissibilità Annullamento</field>
2563
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
2564
+ <field name="is_externally_integrated">False</field>
2565
+ <field name="is_process_cancellable_relaunchable">False</field>
2566
+ <field name="wizard_info">{"key":"value"}</field>
2567
+ <field name="phase_code">F-CC01-0029</field>
2568
+ <field name="check_closed_child_tickets">False</field>
2569
+ </record>
2570
+ <record id="symple_triplet_phase_A0366_-_In_attesa_Esito_finale_annullamento" model="symple.triplet.phase">
2571
+ <field name="active">True</field>
2572
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C1063_-_Esito_finale_Annullamento_OK_E-CC01-0070'),ref('symple_triplet_phase_result_C1064_-_Esito_finale_Annullamento_KO_E-CC01-0071'),ref('symple_triplet_phase_result_C1449_-_KO_controlli_RCU___Data_decorrenza_E-CC01-0072'),ref('symple_triplet_phase_result_C1448_-_OK_controlli_RCU_E-CC01-0073'),ref('symple_triplet_phase_result_C1763_-_Annullamento_passivo_dal_SII_E-CC01-0074')])]"/>
2573
+ <field name="child_case">False</field>
2574
+ <field name="code"># Available variables:
2575
+ # - case_id: the case that just reached this phase
2576
+ # - request: allows you to make HTTP requests (method, url, headers, data)
2577
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
2578
+ # - json_load: allows you to use JSON.load to convert a json into an object
2579
+ # - env: Odoo Environment on which the action is triggered
2580
+ # - time, datetime, dateutil, timezone: useful Python libraries
2581
+ # - float_compare: Odoo function to compare floats based on specific precisions
2582
+ # - ValidationError: Warning Exception to use with raise
2583
+ # - Command: x2Many commands namespace
2584
+ # - OrderedDict: ordered dictionaries
2585
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
2586
+ # (line = case id, func = phase name)
2587
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
2588
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
2589
+ # To return a result, assign: result = {...}
2590
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
2591
+ # phase result will not be set.
2592
+
2593
+
2594
+
2595
+ </field>
2596
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
2597
+ <field name="is_a_postalizer_phase">False</field>
2598
+ <field name="is_compute_refund">False</field>
2599
+ <field name="is_dl">False</field>
2600
+ <field name="is_needs_child_case">False</field>
2601
+ <field name="is_pick_refund_template">False</field>
2602
+ <field name="is_process_managed">False</field>
2603
+ <field name="is_quote_accepted">False</field>
2604
+ <field name="is_quote_sent">False</field>
2605
+ <field name="is_timeout">False</field>
2606
+ <field name="is_voidable">False</field>
2607
+ <field name="name">A0366 - In attesa Esito finale annullamento</field>
2608
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
2609
+ <field name="is_externally_integrated">False</field>
2610
+ <field name="is_process_cancellable_relaunchable">False</field>
2611
+ <field name="wizard_info">{"key":"value"}</field>
2612
+ <field name="phase_code">F-CC01-0030</field>
2613
+ <field name="check_closed_child_tickets">False</field>
2614
+ </record>
2615
+ <record id="symple_triplet_phase_A0809_-_Case_Annullato" model="symple.triplet.phase">
2616
+ <field name="active">True</field>
2617
+ <field name="child_case">False</field>
2618
+ <field name="code"># Available variables:
2619
+ # - case_id: the case that just reached this phase
2620
+ # - request: allows you to make HTTP requests (method, url, headers, data)
2621
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
2622
+ # - json_load: allows you to use JSON.load to convert a json into an object
2623
+ # - env: Odoo Environment on which the action is triggered
2624
+ # - time, datetime, dateutil, timezone: useful Python libraries
2625
+ # - float_compare: Odoo function to compare floats based on specific precisions
2626
+ # - ValidationError: Warning Exception to use with raise
2627
+ # - Command: x2Many commands namespace
2628
+ # - OrderedDict: ordered dictionaries
2629
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
2630
+ # (line = case id, func = phase name)
2631
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
2632
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
2633
+ # To return a result, assign: result = {...}
2634
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
2635
+ # phase result will not be set.
2636
+
2637
+ if case_id.matrix_process_id:
2638
+ case_id.close_matrix_process()
2639
+
2640
+ </field>
2641
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
2642
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','Cancelled')])" />
2643
+ <field name="is_a_postalizer_phase">False</field>
2644
+ <field name="is_compute_refund">False</field>
2645
+ <field name="is_dl">False</field>
2646
+ <field name="is_needs_child_case">False</field>
2647
+ <field name="is_pick_refund_template">False</field>
2648
+ <field name="is_process_managed">False</field>
2649
+ <field name="is_quote_accepted">False</field>
2650
+ <field name="is_quote_sent">False</field>
2651
+ <field name="is_timeout">False</field>
2652
+ <field name="is_voidable">False</field>
2653
+ <field name="name">A0809 - Case Annullato</field>
2654
+ <field name="set_result_automatically">from_code</field>
2655
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
2656
+ <field name="is_externally_integrated">False</field>
2657
+ <field name="is_process_cancellable_relaunchable">False</field>
2658
+ <field name="wizard_info">{"key":"value"}</field>
2659
+ <field name="phase_code">F-CC01-0031</field>
2660
+ <field name="check_closed_child_tickets">False</field>
2661
+ </record>
2662
+ <record id="symple_triplet_phase_A0810_-_Case_Lavorato" model="symple.triplet.phase">
2663
+ <field name="active">True</field>
2664
+ <field name="child_case">False</field>
2665
+ <field name="code">if case_id.matrix_process_id:
2666
+ case_id.close_matrix_process()</field>
2667
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
2668
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','Done')])" />
2669
+ <field name="is_a_postalizer_phase">False</field>
2670
+ <field name="is_compute_refund">False</field>
2671
+ <field name="is_dl">False</field>
2672
+ <field name="is_needs_child_case">False</field>
2673
+ <field name="is_pick_refund_template">False</field>
2674
+ <field name="is_process_managed">False</field>
2675
+ <field name="is_quote_accepted">False</field>
2676
+ <field name="is_quote_sent">False</field>
2677
+ <field name="is_timeout">False</field>
2678
+ <field name="is_voidable">False</field>
2679
+ <field name="name">A0810 - Case Lavorato</field>
2680
+ <field name="set_result_automatically">from_code</field>
2681
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
2682
+ <field name="is_externally_integrated">False</field>
2683
+ <field name="is_process_cancellable_relaunchable">False</field>
2684
+ <field name="wizard_info">{"key":"value"}</field>
2685
+ <field name="phase_code">F-CC01-0032</field>
2686
+ <field name="check_closed_child_tickets">False</field>
2687
+ </record>
2688
+ <record id="symple_triplet_phase_A1833_-_Case_annullato_da_APR" model="symple.triplet.phase">
2689
+ <field name="active">True</field>
2690
+ <field name="child_case">False</field>
2691
+ <field name="code"># Available variables:
2692
+ # - case_id: the case that just reached this phase
2693
+ # - request: allows you to make HTTP requests (method, url, headers, data)
2694
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
2695
+ # - json_load: allows you to use JSON.load to convert a json into an object
2696
+ # - env: Odoo Environment on which the action is triggered
2697
+ # - time, datetime, dateutil, timezone: useful Python libraries
2698
+ # - float_compare: Odoo function to compare floats based on specific precisions
2699
+ # - ValidationError: Warning Exception to use with raise
2700
+ # - Command: x2Many commands namespace
2701
+ # - OrderedDict: ordered dictionaries
2702
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
2703
+ # (line = case id, func = phase name)
2704
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
2705
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
2706
+ # To return a result, assign: result = {...}
2707
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
2708
+ # phase result will not be set.
2709
+
2710
+
2711
+
2712
+ </field>
2713
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
2714
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','Cancelled')])" />
2715
+ <field name="is_a_postalizer_phase">False</field>
2716
+ <field name="is_compute_refund">False</field>
2717
+ <field name="is_dl">False</field>
2718
+ <field name="is_needs_child_case">False</field>
2719
+ <field name="is_pick_refund_template">False</field>
2720
+ <field name="is_process_managed">False</field>
2721
+ <field name="is_quote_accepted">False</field>
2722
+ <field name="is_quote_sent">False</field>
2723
+ <field name="is_timeout">False</field>
2724
+ <field name="is_voidable">False</field>
2725
+ <field name="name">A1833 - Case annullato da APR</field>
2726
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
2727
+ <field name="is_externally_integrated">False</field>
2728
+ <field name="is_process_cancellable_relaunchable">False</field>
2729
+ <field name="wizard_info">{"key":"value"}</field>
2730
+ <field name="phase_code">F-CC01-0033</field>
2731
+ <field name="check_closed_child_tickets">False</field>
2732
+ </record>
2733
+ <record id="symple_triplet_phase_A1835_-_Case_annullato_da_APN" model="symple.triplet.phase">
2734
+ <field name="active">True</field>
2735
+ <field name="child_case">False</field>
2736
+ <field name="code"># Available variables:
2737
+ # - case_id: the case that just reached this phase
2738
+ # - request: allows you to make HTTP requests (method, url, headers, data)
2739
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
2740
+ # - json_load: allows you to use JSON.load to convert a json into an object
2741
+ # - env: Odoo Environment on which the action is triggered
2742
+ # - time, datetime, dateutil, timezone: useful Python libraries
2743
+ # - float_compare: Odoo function to compare floats based on specific precisions
2744
+ # - ValidationError: Warning Exception to use with raise
2745
+ # - Command: x2Many commands namespace
2746
+ # - OrderedDict: ordered dictionaries
2747
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
2748
+ # (line = case id, func = phase name)
2749
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
2750
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
2751
+ # To return a result, assign: result = {...}
2752
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
2753
+ # phase result will not be set.
2754
+
2755
+
2756
+
2757
+ </field>
2758
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
2759
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','Cancelled')])" />
2760
+ <field name="is_a_postalizer_phase">False</field>
2761
+ <field name="is_compute_refund">False</field>
2762
+ <field name="is_dl">False</field>
2763
+ <field name="is_needs_child_case">False</field>
2764
+ <field name="is_pick_refund_template">False</field>
2765
+ <field name="is_process_managed">False</field>
2766
+ <field name="is_quote_accepted">False</field>
2767
+ <field name="is_quote_sent">False</field>
2768
+ <field name="is_timeout">False</field>
2769
+ <field name="is_voidable">False</field>
2770
+ <field name="name">A1835 - Case annullato da APN</field>
2771
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
2772
+ <field name="is_externally_integrated">False</field>
2773
+ <field name="is_process_cancellable_relaunchable">False</field>
2774
+ <field name="wizard_info">{"key":"value"}</field>
2775
+ <field name="phase_code">F-CC01-0034</field>
2776
+ <field name="check_closed_child_tickets">False</field>
2777
+ </record>
2778
+ <record id="symple_triplet_phase_A0811_-_Lavorato_KO" model="symple.triplet.phase">
2779
+ <field name="active">True</field>
2780
+ <field name="child_case">False</field>
2781
+ <field name="code">if case_id.matrix_process_id:
2782
+ case_id.close_matrix_process(status="ERROR")</field>
2783
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
2784
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','Done KO')])" />
2785
+ <field name="is_a_postalizer_phase">False</field>
2786
+ <field name="is_compute_refund">False</field>
2787
+ <field name="is_dl">False</field>
2788
+ <field name="is_needs_child_case">False</field>
2789
+ <field name="is_pick_refund_template">False</field>
2790
+ <field name="is_process_managed">False</field>
2791
+ <field name="is_quote_accepted">False</field>
2792
+ <field name="is_quote_sent">False</field>
2793
+ <field name="is_timeout">False</field>
2794
+ <field name="is_voidable">False</field>
2795
+ <field name="name">A0811 - Lavorato KO</field>
2796
+ <field name="set_result_automatically">from_code</field>
2797
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
2798
+ <field name="is_externally_integrated">False</field>
2799
+ <field name="is_process_cancellable_relaunchable">False</field>
2800
+ <field name="wizard_info">{"key":"value"}</field>
2801
+ <field name="phase_code">F-CC01-0035</field>
2802
+ <field name="check_closed_child_tickets">False</field>
2803
+ </record>
2804
+ <record id="symple_triplet_phase_A1590_-_Verifica_Tipologia_Apertura_Case" model="symple.triplet.phase">
2805
+ <field name="active">True</field>
2806
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C2251_-_Apertura_Case_Manuale_E-CC01-0001-01'),ref('symple_triplet_phase_result_C2252_-_Apertura_Case_Automatica_C')])]"/>
2807
+ <field name="child_case">False</field>
2808
+ <field name="code"># Available variables:
2809
+ # - case_id: the case that just reached this phase
2810
+ # - request: allows you to make HTTP requests (method, url, headers, data)
2811
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
2812
+ # - json_load: allows you to use JSON.load to convert a json into an object
2813
+ # - env: Odoo Environment on which the action is triggered
2814
+ # - time, datetime, dateutil, timezone: useful Python libraries
2815
+ # - float_compare: Odoo function to compare floats based on specific precisions
2816
+ # - ValidationError: Warning Exception to use with raise
2817
+ # - Command: x2Many commands namespace
2818
+ # - OrderedDict: ordered dictionaries
2819
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
2820
+ # (line = case id, func = phase name)
2821
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
2822
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
2823
+ # To return a result, assign: result = {...}
2824
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
2825
+ # phase result will not be set.
2826
+ try:
2827
+ is_automatic = case_id.is_automatic_case
2828
+ if is_automatic:
2829
+ result = "AUTOMATICO"
2830
+ else:
2831
+ result = "MANUALE"
2832
+ except Exception as e :
2833
+ case_id.write({
2834
+ 'info_message':(case_id.info_message + "\n" + str(e)) if case_id.info_message else str(e)
2835
+ })
2836
+
2837
+
2838
+ </field>
2839
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
2840
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','New')])" />
2841
+ <field name="is_a_postalizer_phase">False</field>
2842
+ <field name="is_compute_refund">False</field>
2843
+ <field name="is_dl">False</field>
2844
+ <field name="is_needs_child_case">False</field>
2845
+ <field name="is_pick_refund_template">False</field>
2846
+ <field name="is_process_managed">False</field>
2847
+ <field name="is_quote_accepted">False</field>
2848
+ <field name="is_quote_sent">False</field>
2849
+ <field name="is_timeout">False</field>
2850
+ <field name="is_voidable">False</field>
2851
+ <field name="name">A1590 - Verifica Tipologia Apertura Case</field>
2852
+ <field name="set_result_automatically">from_code</field>
2853
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
2854
+ <field name="is_externally_integrated">False</field>
2855
+ <field name="is_process_cancellable_relaunchable">False</field>
2856
+ <field name="wizard_info">{"key":"value"}</field>
2857
+ <field name="check_closed_child_tickets">False</field>
2858
+ </record>
2859
+ <record id="symple_triplet_phase_A1001___Creazione_Case_di_Risoluzione_Contrattuale_Automatica" model="symple.triplet.phase">
2860
+ <field name="active">True</field>
2861
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C1401_-_Risoluzione_contrattuale_OK_E-CC01-0001-03')])]"/>
2862
+ <field name="child_case">False</field>
2863
+ <field name="code"># Available variables:
2864
+ # - case_id: the case that just reached this phase
2865
+ # - request: allows you to make HTTP requests (method, url, headers, data)
2866
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
2867
+ # - json_load: allows you to use JSON.load to convert a json into an object
2868
+ # - env: Odoo Environment on which the action is triggered
2869
+ # - time, datetime, dateutil, timezone: useful Python libraries
2870
+ # - float_compare: Odoo function to compare floats based on specific precisions
2871
+ # - ValidationError: Warning Exception to use with raise
2872
+ # - Command: x2Many commands namespace
2873
+ # - OrderedDict: ordered dictionaries
2874
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
2875
+ # (line = case id, func = phase name)
2876
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
2877
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
2878
+ # To return a result, assign: result = {...}
2879
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
2880
+ # phase result will not be set.
2881
+
2882
+
2883
+ logs = []
2884
+
2885
+
2886
+ def main():
2887
+ if not case_id.service_point_ids:
2888
+ raise ValidationError(
2889
+ "Il case è stato aperto senza service point"
2890
+ )
2891
+
2892
+ sp = case_id.service_point_ids[0]
2893
+
2894
+ if sp.state != "active":
2895
+ raise ValidationError("Il service point non è in stato attivo.")
2896
+
2897
+ return "OK"
2898
+
2899
+
2900
+ try:
2901
+ result = main()
2902
+
2903
+
2904
+ except Exception as e:
2905
+ logs.append({"message": str(e), "traceback": format_exc()})
2906
+ case_id.write(
2907
+ {"error_message": "Errore durante l'esecuzione della fase: {}".format(str(e))}
2908
+ )
2909
+
2910
+ if logs:
2911
+ log(json_dumps(logs))</field>
2912
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
2913
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
2914
+ <field name="is_a_postalizer_phase">False</field>
2915
+ <field name="is_compute_refund">False</field>
2916
+ <field name="is_dl">False</field>
2917
+ <field name="is_needs_child_case">False</field>
2918
+ <field name="is_pick_refund_template">False</field>
2919
+ <field name="is_process_managed">False</field>
2920
+ <field name="is_quote_accepted">False</field>
2921
+ <field name="is_quote_sent">False</field>
2922
+ <field name="is_timeout">False</field>
2923
+ <field name="is_voidable">False</field>
2924
+ <field name="name">A1001 – Creazione Case di Risoluzione Contrattuale Automatica</field>
2925
+ <field name="set_result_automatically">from_code</field>
2926
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
2927
+ <field name="is_externally_integrated">False</field>
2928
+ <field name="is_process_cancellable_relaunchable">False</field>
2929
+ <field name="wizard_info">{"key":"value"}</field>
2930
+ <field name="check_closed_child_tickets">False</field>
2931
+ </record>
2932
+ <record id="symple_triplet_phase_A1556_-_Verica_commodity" model="symple.triplet.phase">
2933
+ <field name="active">True</field>
2934
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C2222___Commodity_Gas_E-CC01-0001-04'),ref('symple_triplet_phase_result_C2221_-_Commodity_Elettricit__E-CC01-0001-06')])]"/>
2935
+ <field name="child_case">False</field>
2936
+ <field name="code"># Available variables:
2937
+ # - case_id: the case that just reached this phase
2938
+ # - request: allows you to make HTTP requests (method, url, headers, data)
2939
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
2940
+ # - json_load: allows you to use JSON.load to convert a json into an object
2941
+ # - env: Odoo Environment on which the action is triggered
2942
+ # - time, datetime, dateutil, timezone: useful Python libraries
2943
+ # - float_compare: Odoo function to compare floats based on specific precisions
2944
+ # - ValidationError: Warning Exception to use with raise
2945
+ # - Command: x2Many commands namespace
2946
+ # - OrderedDict: ordered dictionaries
2947
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
2948
+ # (line = case id, func = phase name)
2949
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
2950
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
2951
+ # To return a result, assign: result = {...}
2952
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
2953
+ # phase result will not be set.
2954
+
2955
+ sp = case_id.service_point_ids[0]
2956
+
2957
+ if sp.pod_id:
2958
+ result = "ELE"
2959
+ elif sp.pdr_id:
2960
+ result= "GAS"</field>
2961
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
2962
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
2963
+ <field name="is_a_postalizer_phase">False</field>
2964
+ <field name="is_compute_refund">False</field>
2965
+ <field name="is_dl">False</field>
2966
+ <field name="is_needs_child_case">False</field>
2967
+ <field name="is_pick_refund_template">False</field>
2968
+ <field name="is_process_managed">False</field>
2969
+ <field name="is_quote_accepted">False</field>
2970
+ <field name="is_quote_sent">False</field>
2971
+ <field name="is_timeout">False</field>
2972
+ <field name="is_voidable">False</field>
2973
+ <field name="name">A1556 - Verica commodity</field>
2974
+ <field name="set_result_automatically">from_code</field>
2975
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
2976
+ <field name="is_externally_integrated">False</field>
2977
+ <field name="is_process_cancellable_relaunchable">False</field>
2978
+ <field name="wizard_info">{"key":"value"}</field>
2979
+ <field name="check_closed_child_tickets">False</field>
2980
+ </record>
2981
+ <record id="symple_triplet_phase_A2598_-_Invio_Pec" model="symple.triplet.phase">
2982
+ <field name="active">True</field>
2983
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C1019_-_Inviata_E-CC01-0001-05')])]"/>
2984
+ <field name="automatic_phase_result_id" ref="symple_triplet_phase_result_C1019_-_Inviata_E-CC01-0001-05"/>
2985
+ <field name="automatic_template_id" model="mail.template" eval="obj().search([('name','=','TEST PEC TG (copia)')])" />
2986
+ <field name="child_case">False</field>
2987
+ <field name="code"># Available variables:
2988
+ # - case_id: the case that just reached this phase
2989
+ # - request: allows you to make HTTP requests (method, url, headers, data)
2990
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
2991
+ # - json_load: allows you to use JSON.load to convert a json into an object
2992
+ # - env: Odoo Environment on which the action is triggered
2993
+ # - time, datetime, dateutil, timezone: useful Python libraries
2994
+ # - float_compare: Odoo function to compare floats based on specific precisions
2995
+ # - ValidationError: Warning Exception to use with raise
2996
+ # - Command: x2Many commands namespace
2997
+ # - OrderedDict: ordered dictionaries
2998
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
2999
+ # (line = case id, func = phase name)
3000
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
3001
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
3002
+ # To return a result, assign: result = {...}
3003
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
3004
+ # phase result will not be set.
3005
+
3006
+
3007
+
3008
+ </field>
3009
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','Customer Care')])" />
3010
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
3011
+ <field name="is_a_postalizer_phase">False</field>
3012
+ <field name="is_compute_refund">False</field>
3013
+ <field name="is_dl">False</field>
3014
+ <field name="is_mail_managed">manually</field>
3015
+ <field name="is_needs_child_case">False</field>
3016
+ <field name="is_pick_refund_template">False</field>
3017
+ <field name="is_process_managed">True</field>
3018
+ <field name="is_quote_accepted">False</field>
3019
+ <field name="is_quote_sent">False</field>
3020
+ <field name="is_timeout">False</field>
3021
+ <field name="is_voidable">False</field>
3022
+ <field name="name">A2598 - Invio Pec</field>
3023
+ <field name="set_result_automatically">from_email</field>
3024
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
3025
+ <field name="is_externally_integrated">False</field>
3026
+ <field name="is_process_cancellable_relaunchable">False</field>
3027
+ <field name="wizard_info">{"key":"value"}</field>
3028
+ <field name="check_closed_child_tickets">False</field>
3029
+ </record>
3030
+ <record id="symple_triplet_phase_A2338_-_Inserimento_Pratica" model="symple.triplet.phase">
3031
+ <field name="active">True</field>
3032
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C3118_-_KO_AtoA_pdc_E-CC01-0014'),ref('symple_triplet_phase_result_C3117_-_OK_pratica_inserita_E-CC01-00081')])]"/>
3033
+ <field name="child_case">False</field>
3034
+ <field name="code"># Available variables:
3035
+ # - case_id: the case that just reached this phase
3036
+ # - request: allows you to make HTTP requests (method, url, headers, data)
3037
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
3038
+ # - json_load: allows you to use JSON.load to convert a json into an object
3039
+ # - env: Odoo Environment on which the action is triggered
3040
+ # - time, datetime, dateutil, timezone: useful Python libraries
3041
+ # - float_compare: Odoo function to compare floats based on specific precisions
3042
+ # - ValidationError: Warning Exception to use with raise
3043
+ # - Command: x2Many commands namespace
3044
+ # - OrderedDict: ordered dictionaries
3045
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
3046
+ # (line = case id, func = phase name)
3047
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
3048
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
3049
+ # To return a result, assign: result = {...}
3050
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
3051
+ # phase result will not be set.
3052
+
3053
+
3054
+
3055
+ </field>
3056
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
3057
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
3058
+ <field name="is_a_postalizer_phase">False</field>
3059
+ <field name="is_compute_refund">False</field>
3060
+ <field name="is_dl">False</field>
3061
+ <field name="is_needs_child_case">False</field>
3062
+ <field name="is_pick_refund_template">False</field>
3063
+ <field name="is_process_managed">False</field>
3064
+ <field name="is_quote_accepted">False</field>
3065
+ <field name="is_quote_sent">False</field>
3066
+ <field name="is_timeout">False</field>
3067
+ <field name="is_voidable">False</field>
3068
+ <field name="name">A2338 - Inserimento Pratica</field>
3069
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
3070
+ <field name="is_externally_integrated">False</field>
3071
+ <field name="is_process_cancellable_relaunchable">False</field>
3072
+ <field name="wizard_info">{"key":"value"}</field>
3073
+ <field name="check_closed_child_tickets">False</field>
3074
+ </record>
3075
+ <record id="symple_triplet_phase_A2561_-_verifica_stato_invio_pratica_da_annullare" model="symple.triplet.phase">
3076
+ <field name="active">True</field>
3077
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C3120_-_annullamento_da_gestire_E-CC01-00083'),ref('symple_triplet_phase_result_C2599_-_annullamento_confermato_E-CC01-00084')])]"/>
3078
+ <field name="child_case">False</field>
3079
+ <field name="code"># Available variables:
3080
+ # - case_id: the case that just reached this phase
3081
+ # - request: allows you to make HTTP requests (method, url, headers, data)
3082
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
3083
+ # - json_load: allows you to use JSON.load to convert a json into an object
3084
+ # - env: Odoo Environment on which the action is triggered
3085
+ # - time, datetime, dateutil, timezone: useful Python libraries
3086
+ # - float_compare: Odoo function to compare floats based on specific precisions
3087
+ # - ValidationError: Warning Exception to use with raise
3088
+ # - Command: x2Many commands namespace
3089
+ # - OrderedDict: ordered dictionaries
3090
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
3091
+ # (line = case id, func = phase name)
3092
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
3093
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
3094
+ # To return a result, assign: result = {...}
3095
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
3096
+ # phase result will not be set.
3097
+
3098
+
3099
+
3100
+ </field>
3101
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
3102
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
3103
+ <field name="is_a_postalizer_phase">False</field>
3104
+ <field name="is_compute_refund">False</field>
3105
+ <field name="is_dl">False</field>
3106
+ <field name="is_needs_child_case">False</field>
3107
+ <field name="is_pick_refund_template">False</field>
3108
+ <field name="is_process_managed">False</field>
3109
+ <field name="is_quote_accepted">False</field>
3110
+ <field name="is_quote_sent">False</field>
3111
+ <field name="is_timeout">False</field>
3112
+ <field name="is_voidable">False</field>
3113
+ <field name="name">A2561 - verifica stato invio pratica da annullare</field>
3114
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
3115
+ <field name="is_externally_integrated">False</field>
3116
+ <field name="is_process_cancellable_relaunchable">False</field>
3117
+ <field name="wizard_info">{"key":"value"}</field>
3118
+ <field name="check_closed_child_tickets">False</field>
3119
+ </record>
3120
+ <record id="symple_triplet_phase_A0832_-_Invio_Richiesta_Annullamento" model="symple.triplet.phase">
3121
+ <field name="active">True</field>
3122
+ <field name="allowed_phase_result_ids" model="symple.triplet.phase.result" eval="[(6, 0, [ref('symple_triplet_phase_result_C3118_-_KO_AtoA_pdc_E-CC01-0044'),ref('symple_triplet_phase_result_C2875_-_OK_-_Inviato_Annullamento_al_SII_E-CC01-00085')])]"/>
3123
+ <field name="child_case">False</field>
3124
+ <field name="code"># Available variables:
3125
+ # - case_id: the case that just reached this phase
3126
+ # - request: allows you to make HTTP requests (method, url, headers, data)
3127
+ # - json_dumps: allows you to use JSON.dumps to convert an object into a json
3128
+ # - json_load: allows you to use JSON.load to convert a json into an object
3129
+ # - env: Odoo Environment on which the action is triggered
3130
+ # - time, datetime, dateutil, timezone: useful Python libraries
3131
+ # - float_compare: Odoo function to compare floats based on specific precisions
3132
+ # - ValidationError: Warning Exception to use with raise
3133
+ # - Command: x2Many commands namespace
3134
+ # - OrderedDict: ordered dictionaries
3135
+ # - log: log(message, level='info'): logging function to record debug information in ir.logging table
3136
+ # (line = case id, func = phase name)
3137
+ # - format_exc: forwarded from traceback.format_exc - returns str stack trace of last exception thrown
3138
+ # - first: forwarded from odoo.fields.first - safely gets first element of recordset
3139
+ # To return a result, assign: result = {...}
3140
+ # WARNING: if return = False or return value is not in the result table or no result is returned at all,
3141
+ # phase result will not be set.
3142
+
3143
+
3144
+
3145
+ </field>
3146
+ <field name="helpdesk_group_id" model="helpdesk.team" eval="obj().search([('name','=','SYSTEM-Sorgenia')])" />
3147
+ <field name="helpdesk_stage_id" model="helpdesk.stage" eval="obj().search([('name','=','In Progress')])" />
3148
+ <field name="is_a_postalizer_phase">False</field>
3149
+ <field name="is_compute_refund">False</field>
3150
+ <field name="is_dl">False</field>
3151
+ <field name="is_needs_child_case">False</field>
3152
+ <field name="is_pick_refund_template">False</field>
3153
+ <field name="is_process_managed">False</field>
3154
+ <field name="is_quote_accepted">False</field>
3155
+ <field name="is_quote_sent">False</field>
3156
+ <field name="is_timeout">False</field>
3157
+ <field name="is_voidable">False</field>
3158
+ <field name="name">A0832 - Invio Richiesta Annullamento</field>
3159
+ <field name="workflow_id" ref="symple_workflow_ML_-_RISOLUZIONE_CONTRATTUALE"/>
3160
+ <field name="is_externally_integrated">False</field>
3161
+ <field name="is_process_cancellable_relaunchable">False</field>
3162
+ <field name="wizard_info">{"key":"value"}</field>
3163
+ <field name="check_closed_child_tickets">False</field>
3164
+ </record>
3165
+
3166
+ </data>
3167
+ </odoo>
3168
+
3169
+ Processed_records: 42
3170
+ Managed records: 42