From 164b034ac4e33bb14b36f18179ba88e843dead4d Mon Sep 17 00:00:00 2001 From: Manoj Kumar <80808962+mkumar-02@users.noreply.github.com> Date: Thu, 26 Sep 2024 13:30:48 +0530 Subject: [PATCH] Updated cron job method --- g2p_odk_importer/models/odk_import.py | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/g2p_odk_importer/models/odk_import.py b/g2p_odk_importer/models/odk_import.py index 26a4e0a..0a487e9 100644 --- a/g2p_odk_importer/models/odk_import.py +++ b/g2p_odk_importer/models/odk_import.py @@ -172,25 +172,6 @@ def import_records(self): }, } - def import_records_by_cron(self, _id): - config = self.env["odk.config"].browse(_id) - if not config.base_url: - raise UserError(_("Please configure the ODK.")) - client = ODKClient( - self.env, - config.id, - config.base_url, - config.username, - config.password, - config.project, - config.form_id, - self.target_registry, - self.json_formatter, - ) - client.login() - client.import_delta_records(last_sync_timestamp=config.last_sync_time) - config.update({"last_sync_time": fields.Datetime.now()}) - def odk_import_action_trigger(self): for rec in self: if rec.job_status == "draft" or rec.job_status == "completed": @@ -205,7 +186,7 @@ def odk_import_action_trigger(self): "interval_type": "minutes", "model_id": self.env["ir.model"].search([("model", "=", "odk.import")]).id, "state": "code", - "code": "model.import_records_by_cron(" + str(rec.id) + ")", + "code": "model.browse(" + str(rec.id) + ").import_records()", "doall": False, "numbercall": -1, }