T3165 ADD FCP reservations#2097
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for FCP Intervention Reservations, adding fields, views, and GMC actions to handle creating, updating, and cancelling reservations, as well as converting them to holds. The code review identified several critical issues: newly created messages in handle_reservation are left unprocessed; potential AttributeError exceptions could occur in reservation_to_hold and intervention_hold_removal_notification due to unsafe dictionary access; overriding write in compassion_reservation.py may lead to duplicate GMC messages; and comparing a Many2one field (category_id) directly to a string in XML attrs will fail.
Confidence Score: 4/5Safe to merge with one fix: reservation_to_hold() triggers an unintended outgoing hold update every time a reservation converts to a hold. Adding intervention_compassion/models/compassion_intervention.py — specifically the reservation_to_hold() method and its interaction with hold_fields / update_hold(). Important Files Changed
Reviews (2): Last reviewed commit: "T3165 ADD FCP reservations" | Re-trigger Greptile |
2de4519 to
d72439e
Compare
d72439e to
0b295a9
Compare
| def reservation_to_hold(self, reservation_vals=None): | ||
| if reservation_vals is None: | ||
| reservation_vals = {} | ||
| intervention_vals = self.json_to_data( | ||
| reservation_vals.get( | ||
| "InterventionReservationConvertedToHoldNotification", {} | ||
| ), | ||
| "Hold Update", | ||
| ) | ||
| intervention_id = intervention_vals.get("intervention_id") | ||
| if not intervention_id: | ||
| raise UserError(_("No intervention id provided")) | ||
| intervention = self.search([("intervention_id", "=", intervention_id)]) | ||
| intervention_vals.update( | ||
| {"hold_expiration_date": False, "reservation_id": False} | ||
| ) | ||
| if intervention: | ||
| intervention.write(intervention_vals) | ||
| else: | ||
| intervention = self.create(intervention_vals) | ||
| return intervention.ids |
There was a problem hiding this comment.
Incoming notification triggers unconditional outgoing hold update
reservation_to_hold always writes hold_expiration_date: False to the intervention. Because hold_expiration_date is now listed in hold_fields, the write() override sees it in vals and unconditionally sets update_hold = True. After super().write() completes, hold_id is populated from the mapped notification data while reservation_id is False, so update_hold() dispatches a live intervention_update_hold_action message to the Connect API every time this incoming notification is processed. Before this PR, update_hold() was only triggered if the notification payload happened to include ExpirationDate; now it fires unconditionally. The write should use with_context(hold_update=False) the same way hold_sent does in the wizard.
No description provided.