Skip to content

Commit

Permalink
[IMP]connector_pms_wubook: folio message_post with sudo
Browse files Browse the repository at this point in the history
  • Loading branch information
DarioLodeiros committed Apr 2, 2024
1 parent 963a596 commit d98d1f8
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions connector_pms_wubook/models/pms_folio/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def _after_import(self, binding):
if folio.state == "cancel" and folio.amount_total == 0:
ota_payments.action_draft()
ota_payments.action_cancel()
folio.message_post(
folio.sudo().message_post(
body=_(
"The folio and the OTA payment have been cancelled."
),
Expand All @@ -107,7 +107,7 @@ def _after_import(self, binding):
ota_payments[0].action_post()
if len(ota_payments) > 1:
ota_payments[1:].action_cancel()
folio.message_post(
folio.sudo().message_post(
body=_(
"The amount of the payment has been updated to %s by OTA modification"
% binding.payment_gateway_fee
Expand Down Expand Up @@ -143,14 +143,17 @@ def _after_import(self, binding):
# in availability and force to update Wubook avail changes
# (Wubook add/delete avail by itself)
dates = folio.mapped("reservation_ids.reservation_line_ids.date")
avails = self.env["channel.wubook.pms.availability"].search([
("backend_id", "=", binding.backend_id.id),
("date", ">=", min(dates)),
("date", "<=", max(dates)),
("room_type_id", "in", folio.mapped("reservation_ids.room_type_id.id")),
])
query = 'UPDATE "channel_wubook_pms_availability" SET "actual_write_date"=%s WHERE id IN %%s' % (
AsIs("(now() at time zone 'UTC')"),
avails = self.env["channel.wubook.pms.availability"].search(
[
("backend_id", "=", binding.backend_id.id),
("date", ">=", min(dates)),
("date", "<=", max(dates)),
("room_type_id", "in", folio.mapped("reservation_ids.room_type_id.id")),
]
)
query = (
'UPDATE "channel_wubook_pms_availability" SET "actual_write_date"=%s WHERE id IN %%s'
% (AsIs("(now() at time zone 'UTC')"),)
)
cr = self.env.cr
for sub_ids in cr.split_for_in_conditions(
Expand Down

0 comments on commit d98d1f8

Please sign in to comment.