Skip to content

Commit

Permalink
Removed process and tasks (#113)
Browse files Browse the repository at this point in the history
* removed process and tasks

* removed only integrations of task and process
  • Loading branch information
truthfool authored Apr 27, 2022
1 parent 728da8a commit cd0cc44
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 31 deletions.
3 changes: 1 addition & 2 deletions odk-connector/models/odk.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ def auth_call(self, url, data):

if response.status_code == _CODE_401:
raise exceptions.Warning(
_("401 - Unable to authenticate to ODK with the user '%s'.\n")
% self.user
_("401 - Unable to authenticate to ODK with the given user.\nq")
)
elif response.status_code not in [_CODE_200, _CODE_201]:
raise exceptions.Warning(
Expand Down
8 changes: 1 addition & 7 deletions odk-connector/models/odk_config_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ODKConfig(models.Model):
# readonly=True
)
odk_email = fields.Char(
string="ODK User EMail",
string="ODK User Email",
required=True,
# readonly=True
)
Expand Down Expand Up @@ -76,12 +76,6 @@ def odk_button_update_all_form_submissions(self):
def call_submission(self):
submissions_obj = self.env["odk.submissions"]
regd_ids = submissions_obj.update_submissions(self)
self.env["openg2p.process"].handle_tasks(
[
("task_subtype_odk_pull", self.id),
("task_subtype_regd_create", regd_ids),
]
)
print("Call Submission ends")

def write(self, vals):
Expand Down
8 changes: 6 additions & 2 deletions odk-connector/models/odk_submissions_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,12 @@ def save_data_into_all(self, odk_response_data, odk_config, odk_batch_id):
)

else:
value.update({"odk_batch_id": odk_batch_id})
value.update(
{
"odk_batch_id": odk_batch_id,
"program_ids": odk_config.program_id.ids,
}
)
registration = self.create_registration_from_submission(value)
if registration is not None:
self.odk_create_submissions_data(
Expand Down Expand Up @@ -214,7 +219,6 @@ def get_conversion_dict(self):
def create(self, vals_list):
try:
res = super().create(vals_list)
# self.env["openg2p.workflow"].handle_tasks("odk_pull", res.id)
return res
except BaseException as e:
print(e)
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ class BatchTransaction(models.Model):

total_transactions = fields.Char(string="Total Transactions", readonly=True)

ongoing = fields.Char(string="Ongoing", readonly=True)
ongoing = fields.Char(string="Reconcile", readonly=True)

failed = fields.Char(string="Failed", readonly=True)

total_amount = fields.Char(string="Total Amount Transacted", readonly=True)

completed_amount = fields.Char(string="Completed Amount", readonly=True)

ongoing_amount = fields.Char(string="Ongoing Amount", readonly=True)
ongoing_amount = fields.Char(string="Pending Amount", readonly=True)

failed_amount = fields.Char(string="Failed Amount", readonly=True)

Expand Down Expand Up @@ -152,9 +152,6 @@ def _all_beneficiaries(self):
def action_confirm(self):
for rec in self:
rec.state = "confirm"
self.env["openg2p.process"].handle_tasks(
[("task_subtype_disbursement_approve_batch", self.id)]
)

def action_pending(self):
for rec in self:
Expand Down Expand Up @@ -265,13 +262,6 @@ def create_bulk_transfer(self):

self.transaction_status = response_data["status"]
self.transaction_batch_id = response_data["batch_id"]
self.env["openg2p.process"].handle_tasks(
[
("task_subtype_disbursement_send_batch", self.id),
("task_subtype_disbursement_review_settlement_report", self.id),
("task_subtype_disbursement_complete_reconciliation", self.id),
]
)
except BaseException as e:
print(e)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,13 @@ def create_batch_transaction(self, beneficiaries_selected):
"bank_account_id": bank_id.id,
"batch_id": batch.id,
"state": "draft",
"name": str(b.id),
"name": str(b.name),
"beneficiary_id": b.id,
"amount": b.grand_total,
"program_id": b.program_ids.ids[0],
"date_start": datetime.now(),
"date_end": datetime.now(),
"currency_id": 1,
"currency_id": bank_id.currency_id,
"payment_mode": bank_id.payment_mode,
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<button name="action_pending" type="object" states="confirm" string="Pending" class="oe_highlight"/>
<button name="action_transaction" type="object" states="pending" string="Complete" class="oe_highlight"/>
<button name="create_bulk_transfer" type="object" states="confirm" string="Make Transfer" class="oe_highlight"/>
<button name="bulk_transfer_status" type="object" states="pending" string="Check Status" class="oe_highlight"/>
<button name="bulk_transfer_status" type="object" states="pending" string="Reconcile" class="oe_highlight"/>
<field name="state" widget="statusbar"/>
</header>
<sheet>
Expand Down
2 changes: 1 addition & 1 deletion openg2p_program/views/openg2p_program.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
</group>
</group>
<notebook>
<page name="notes" string="Description">
<page name="notes" string="Criteria">
<field name="note" nolabel="1" placeholder="Description of program..."/>
</page>
</notebook>
Expand Down
25 changes: 21 additions & 4 deletions openg2p_registration/models/openg2p_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@ def _default_company_id(self):

odk_batch_id = fields.Char(default=lambda *args: uuid.uuid4().hex)

program_ids = fields.Many2many(
comodel_name="openg2p.program",
relation="regd_programs",
string="Active Programs",
help="Active programs enrolled to",
store=True,
required=False,
)
# will be return registration details on api call
def api_json(self):
data = {
Expand Down Expand Up @@ -495,12 +503,16 @@ def create_registration_from_odk(self, odk_data):
if not str(k).startswith("_"):
temp[str(k).replace("-", "_").lower()] = v

country_id = (
self.env["res.country"].search([("name", "=", "Sierra Leone")])[0].id
country_name = (
temp["country"] if "country" in temp.keys() else "Sierra Leone"
)
state_name = temp["state"] if "state" in temp.keys() else "Freetown"

country_id = self.env["res.country"].search([("name", "=", country_name)])[0].id
state_id = (
self.env["res.country.state"].search([("name", "=", "Freetown")])[0].id
self.env["res.country.state"].search([("name", "=", state_name)])[0].id
)

try:
regd = self.create(
{
Expand Down Expand Up @@ -676,6 +688,8 @@ def create_registration_from_odk(self, odk_data):
print(e)
try:
regd.write(data)
# Updating Program for Registration
regd.program_ids = [(6, 0, temp["program_ids"])]
except BaseException as e:
print(e)
return regd
Expand Down Expand Up @@ -876,9 +890,12 @@ def create_beneficiary_from_registration(self):
"emergency_contact": self.emergency_contact,
"emergency_phone": self.emergency_phone,
"odk_batch_id": self.odk_batch_id,
"program_ids": self.program_ids.ids,
}
beneficiary = self.env["openg2p.beneficiary"].create(data)

# Updating Program for beneficiary
beneficiary.program_ids = [(6, 0, self.program_ids.ids)]

org_fields = self.env["openg2p.registration.orgmap"].search(
[("regd_id", "=", self.id)]
)
Expand Down

0 comments on commit cd0cc44

Please sign in to comment.