Skip to content

Commit

Permalink
1. Menambahkan workflow policy
Browse files Browse the repository at this point in the history
2. Menambahkan Tier Validation
3. Menambahkan ir.rule sesuai dengan CB Group
4. Menambahkan relasi ke operating units dari CB Group
5. Memfilter isian dari CB Group sesuai dengan OU tiap users
6. Menambahkan tombol Test Connection pada backend CB
7. Pengisian Description pada CB Asset Batch dibuat flexible
8. Validasi isian date dan date_end pada CB Asset Batch
  • Loading branch information
mikevhe18 committed Jan 6, 2025
1 parent 5902998 commit bc292de
Show file tree
Hide file tree
Showing 14 changed files with 521 additions and 17 deletions.
3 changes: 3 additions & 0 deletions bssb_core_banking_asset/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@
],
"data": [
"security/ir.model.access.csv",
"security/cb_asset_batch_security.xml",
"menu.xml",
"data/base_workflow_policy_data.xml",
"data/ir_sequence_data.xml",
"data/base_sequence_configurator_data.xml",
"data/tier_definition_data.xml",
"views/cb_asset_backend_views.xml",
"views/res_company_views.xml",
"views/operating_unit_views.xml",
Expand Down
63 changes: 63 additions & 0 deletions bssb_core_banking_asset/data/base_workflow_policy_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2020 OpenSynergy Indonesia
Copyright 2020 PT. Simetri Sinergi Indonesia
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<openerp>
<data>
<record id="base_workflow_cb_asset_batch" model="base.workflow_policy">
<field name="model_id" ref="bssb_core_banking_asset.model_cb_asset_batch" />
</record>
<record
id="base_workflow_line_cb_asset_batch_confirm"
model="base.workflow_policy_line"
>
<field name="workflow_id" ref="base_workflow_cb_asset_batch" />
<field
name="field_id"
search="[('model_id.model','=','cb_asset_batch'),('name','=','confirm_ok')]"
/>
<field
name="python_code"
>result = document.cb_group_id.cb_asset_confirm_group_ids.ids</field>
</record>
<record
id="base_workflow_line_cb_asset_batch_send"
model="base.workflow_policy_line"
>
<field name="workflow_id" ref="base_workflow_cb_asset_batch" />
<field
name="field_id"
search="[('model_id.model','=','cb_asset_batch'),('name','=','send_ok')]"
/>
<field
name="python_code"
>result = document.cb_group_id.cb_asset_send_group_ids.ids</field>
</record>
<record
id="base_workflow_line_cb_asset_batch_cancel"
model="base.workflow_policy_line"
>
<field name="workflow_id" ref="base_workflow_cb_asset_batch" />
<field
name="field_id"
search="[('model_id.model','=','cb_asset_batch'),('name','=','cancel_ok')]"
/>
<field
name="python_code"
>result = document.cb_group_id.cb_asset_cancel_group_ids.ids</field>
</record>
<record
id="base_workflow_line_cb_asset_batch_restart"
model="base.workflow_policy_line"
>
<field name="workflow_id" ref="base_workflow_cb_asset_batch" />
<field
name="field_id"
search="[('model_id.model','=','cb_asset_batch'),('name','=','restart_ok')]"
/>
<field
name="python_code"
>result = document.cb_group_id.cb_asset_restart_group_ids.ids</field>
</record>
</data>
</openerp>
38 changes: 38 additions & 0 deletions bssb_core_banking_asset/data/res_group_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2024 OpenSynergy Indonesia
Copyright 2024 PT. Simetri Sinergi Indonesia
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->

<openerp>
<data>
<record id="group_cb_asset_batch_user" model="res.groups">
<field name="name">Core Banking Depreciation - All User</field>
<field name="category_id" ref="base_user_role.ir_module_category_role" />
</record>
<record id="group_cb_asset_batch_entri" model="res.groups">
<field name="name">Core Banking Depreciation - Entri</field>
<field name="category_id" ref="base_user_role.ir_module_category_role" />
<field name="implied_ids" eval="[(6,0,[
ref('group_cb_asset_batch_user'),
])]" />
</record>

<record id="group_cb_asset_batch_validator" model="res.groups">
<field name="name">Core Banking Depreciation - Validator</field>
<field name="category_id" ref="base_user_role.ir_module_category_role" />
<field name="implied_ids" eval="[(6,0,[
ref('group_cb_asset_batch_entri'),
])]" />
</record>

<record id="group_cb_asset_batch_administrator" model="res.groups">
<field name="name">Core Banking Depreciation - Administrator</field>
<field name="category_id" ref="base_user_role.ir_module_category_role" />
<field name="implied_ids" eval="[(6,0,[
ref('base.group_system'),ref('group_cb_asset_batch_user')
])]" />
</record>

</data>
</openerp>

24 changes: 24 additions & 0 deletions bssb_core_banking_asset/data/res_users_role_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Copyright 2024 OpenSynergy Indonesia
Copyright 2021 PT. Simetri Sinergi Indonesia
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
pylint: disable=locally-disabled, file-not-used -->
<openerp>
<data>

<record id="cb_asset_user_role" model="res.users.role">
<field name="name">Core Banking Depreciation - Entri</field>
<field name="group_id" ref="group_cb_asset_batch_entri" />
</record>

<record id="cb_asset_validator_role" model="res.users.role">
<field name="name">Core Banking Depreciation - Validator</field>
<field name="group_id" ref="group_cb_asset_batch_validator" />
</record>

<record id="cb_asset_admnistrator_role" model="res.users.role">
<field name="name">Core Banking Depreciation - Administrator</field>
<field name="group_id" ref="group_cb_asset_batch_administrator" />
</record>
</data>
</openerp>
21 changes: 21 additions & 0 deletions bssb_core_banking_asset/data/tier_definition_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2024 OpenSynergy Indonesia
Copyright 2024 PT. Simetri Sinergi Indonesia
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<openerp>
<data>
<!-- Core Banking -->
<record id="tier_def_cb_asset_batch" model="tier.definition">
<field name="name">Core Banking Depreciation - Normal</field>
<field name="model_id" search="[('model','=','cb_asset_batch')]" />
<field name="python_code">True</field>
<field name="validate_sequence" eval="1" />
</record>

<record id="tier_def_review_cb_asset_batch" model="tier.definition.review">
<field name="definition_id" ref="tier_def_cb_asset_batch" />
<field name="review_type">group</field>
<field name="reviewer_group_ids" eval="[(6,0,[ref('bssb.group_pat_validator')])]" />
</record>
</data>
</openerp>
1 change: 1 addition & 0 deletions bssb_core_banking_asset/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import (
tier_definition,
cb_asset_backend,
operating_unit,
res_company,
Expand Down
104 changes: 103 additions & 1 deletion bssb_core_banking_asset/models/cb_asset_backend.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Copyright 2024 OpenSynergy Indonesia
# Copyright 2024 PT. Simetri Sinergi Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import base64
import json

from openerp import api, fields, models
import requests
from openerp import _, api, fields, models


class CoreBankingAssetBackend(models.Model):
Expand Down Expand Up @@ -76,6 +79,10 @@ def _default_company_id(self):
app_id = fields.Char(
string="App ID",
)
response_msg = fields.Text(
string="Response",
copy=True,
)

@api.multi
def name_get(self):
Expand Down Expand Up @@ -108,3 +115,98 @@ def action_restart(self):
for record in self:
record.company_id.write({"cb_asset_backend_id": False})
record.write({"state": "draft"})

@api.multi
def _set_response(self, resp_type, response_msg):
self.ensure_one()
self.write(
{
"response_msg": response_msg,
}
)
if resp_type == "failed":
return False
else:
return True

@api.multi
def _get_token(self):
self.ensure_one()

url = self.base_url + self.api_token

payload = json.dumps({
"user": self.username,
"password": self.password,
})
headers = {
"Content-Type": "application/json",
}

try:
response = requests.request(
"POST", url, headers=headers, data=payload
)
result = response.json()
code = result["code"]
if code == "00":
backend.token = result["message"]
msg_err = _(
"""
Status: Success
API: %s
Payload: %s
Response: %s
"""
% (url, payload, response.text)
)
return self._set_response("success", msg_err)
else:
msg_err = _(
"""
Status: Error
API: %s
Payload: %s
Response: %s
"""
% (url, payload, response.text)
)
return self._set_response("failed", msg_err)
except requests.exceptions.Timeout as e:
msg_err = _(
"""
Status: Timeout
API: %s
Payload: %s
Massage Error: %s
"""
% (url, payload, e)
)
return self._set_response("failed", msg_err)
except requests.exceptions.ConnectionError as e:
msg_err = _(
"""
Status: ConnectionError
API: %s
Payload: %s
Massage Error: %s
"""
% (url, payload, e)
)
return self._set_response("failed", msg_err)
except ValueError as e:
msg_err = _(
"""
Status: ValueError
API: %s
Payload: %s
Massage Error: %s
"""
% (url, payload, e)
)
return self._set_response("failed", msg_err)

@api.multi
def action_test_connection(self):
for record in self:
record._get_token()
Loading

0 comments on commit bc292de

Please sign in to comment.