implement async restaurant database provisioning model with background worker and automated setup process
This commit is contained in:
parent
b7ba123f03
commit
4a31f0d9f3
@ -68,6 +68,16 @@ def _async_provisioning_worker(parent_db, saas_res_id, db_name, modules, company
|
|||||||
source_ref=template,
|
source_ref=template,
|
||||||
subtype_xmlid='mail.mt_comment'
|
subtype_xmlid='mail.mt_comment'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Send real-time bus notification to the backend UI to refresh the form view
|
||||||
|
try:
|
||||||
|
env['bus.bus']._sendone('saas_provisioning', 'saas_provisioning', {
|
||||||
|
'saas_record_id': saas_record.id,
|
||||||
|
'status': 'active'
|
||||||
|
})
|
||||||
|
except Exception as bus_err:
|
||||||
|
_logger.error(f"Failed to send success bus notification: {str(bus_err)}")
|
||||||
|
|
||||||
cr.commit()
|
cr.commit()
|
||||||
|
|
||||||
_logger.info(f"Background thread: Async provisioning finished successfully for {db_name}!")
|
_logger.info(f"Background thread: Async provisioning finished successfully for {db_name}!")
|
||||||
@ -88,6 +98,16 @@ def _async_provisioning_worker(parent_db, saas_res_id, db_name, modules, company
|
|||||||
saas_record = env['saas.restaurant'].browse(saas_res_id)
|
saas_record = env['saas.restaurant'].browse(saas_res_id)
|
||||||
saas_record.write({'status': 'failed'})
|
saas_record.write({'status': 'failed'})
|
||||||
saas_record.message_post(body=f"Failed background database provisioning: {str(e)}")
|
saas_record.message_post(body=f"Failed background database provisioning: {str(e)}")
|
||||||
|
|
||||||
|
# Send real-time bus notification to the backend UI to refresh the form view
|
||||||
|
try:
|
||||||
|
env['bus.bus']._sendone('saas_provisioning', 'saas_provisioning', {
|
||||||
|
'saas_record_id': saas_record.id,
|
||||||
|
'status': 'failed'
|
||||||
|
})
|
||||||
|
except Exception as bus_err:
|
||||||
|
_logger.error(f"Failed to send failure bus notification: {str(bus_err)}")
|
||||||
|
|
||||||
cr.commit()
|
cr.commit()
|
||||||
except Exception as update_err:
|
except Exception as update_err:
|
||||||
_logger.error(f"Background thread: Failed to mark status as failed on SaaS record: {str(update_err)}")
|
_logger.error(f"Background thread: Failed to mark status as failed on SaaS record: {str(update_err)}")
|
||||||
@ -225,7 +245,7 @@ class SaasRestaurant(models.Model):
|
|||||||
'title': 'Database Provisioning Started',
|
'title': 'Database Provisioning Started',
|
||||||
'message': 'Your database creation has started in the background. Please wait 1-2 minutes for completion before logging in.',
|
'message': 'Your database creation has started in the background. Please wait 1-2 minutes for completion before logging in.',
|
||||||
'sticky': False,
|
'sticky': False,
|
||||||
'next': {'type': 'ir.actions.act_window_close'},
|
'next': {'type': 'ir.actions.client', 'tag': 'reload'},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user