Skip to content

Commit

Permalink
[UPD] bssb_core_banking_asset
Browse files Browse the repository at this point in the history
* Menambahkan fungsionalitas
  • Loading branch information
andhit-r committed Dec 26, 2024
1 parent 35dd8d9 commit efe7004
Show file tree
Hide file tree
Showing 9 changed files with 231 additions and 11 deletions.
2 changes: 2 additions & 0 deletions bssb_core_banking_asset/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
"data/base_sequence_configurator_data.xml",
"views/cb_asset_backend_views.xml",
"views/res_company_views.xml",
"views/operating_unit_views.xml",
"views/cb_asset_batch_views.xml",
"views/cb_group_views.xml",
],
"demo": [
],
Expand Down
2 changes: 2 additions & 0 deletions bssb_core_banking_asset/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

from . import (
cb_asset_backend,
operating_unit,
res_company,
cb_group,
cb_asset_batch,
)
81 changes: 75 additions & 6 deletions bssb_core_banking_asset/models/cb_asset_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,24 @@ class CoreBankingAssetBatch(models.Model):
},
default=datetime.now().strftime("%Y-%m-%d"),
)
warehouse_id = fields.Many2one(
string="Warehouse",
comodel_name="stock.warehouse",
cb_group_id = fields.Many2one(
string="Core Bankking Group",
comodel_name="cb_group",
readonly=True,
required=True,
states={
"draft": [("readonly", False)],
},
)
accounting_category_id = fields.Many2one(
string="Accounting Category",
comodel_name="fixed_asset_accounting_category",
readonly=True,
required=True,
states={
"draft": [("readonly", False)],
},
)
depreciation_account_id = fields.Many2one(
string="Depreciation Account",
comodel_name="account.account",
Expand Down Expand Up @@ -93,13 +102,30 @@ class CoreBankingAssetBatch(models.Model):
default="manual",
)

depreciation_line_ids = fields.Many2many(
string="Depreciation Lines",
comodel_name="account.asset.depreciation.line",
rel="rel_asset_batch_2_depr_line",
col1="batch_id",
col2="line_id",
required=False,
states={
"draft": [("readonly", False)],
},
)


@api.multi
@api.depends(
"depreciation_amount_method",
"depreciation_line_ids",
"depreciation_line_ids.amount",
)
def _compute_automatic_depreciation_amount(self):
for document in self:
result = 0.0
for line in document.depreciation_line_ids:
result += line.amount
document.automatic_depreciation_amount = result

automatic_depreciation_amount = fields.Float(
Expand Down Expand Up @@ -142,7 +168,7 @@ def _compute_final_depreciation_amount(self):
description = fields.Text(
string="Description",
readonly=True,
required=True,
required=False,
states={
"draft": [("readonly", False)],
},
Expand All @@ -159,6 +185,23 @@ def _compute_final_depreciation_amount(self):
copy=False,
)

@api.onchange(
"accounting_category_id"
)
def onchange_depreciation_account_id(self):
self.depreciation_account_id = False
if self.accounting_category_id:
self.depreciation_account_id = self.accounting_category_id.account_depreciation_id

@api.onchange(
"accounting_category_id"
)
def onchange_depreciation_expense_account_id(self):
self.depreciation_expense_account_id = False
if self.accounting_category_id:
self.depreciation_expense_account_id = self.accounting_category_id.account_expense_depreciation_id


@api.model
def _get_cb_asset_backend_id(self):
company = self.env.user.company_id
Expand Down Expand Up @@ -198,6 +241,7 @@ def _check_tanggal(self):
if record.date_start > record.date_end:
msg_err = _("Date Start cannot be greater than Date End")
raise UserError(msg_err)


@api.multi
def _set_response(self, resp_type, response_msg):
Expand Down Expand Up @@ -268,18 +312,43 @@ def action_done(self):
for document in self:
document.write(document._prepare_done_data())

@api.multi
def action_load_depreciation_line(self):
for document in self:
document._load_depreciation_line()

@api.multi
def _load_depreciation_line(self):
self.ensure_one()
Line = self.env["account.asset.depreciation.line"]
criteria = [
("type", "=", "depreciate"),
("subtype_id", "=", False),
("move_check", "=", False),
("init_entry", "=", False),
("line_date", ">=", self.date_start),
("line_date", "<=", self.date_end),
("asset_id.state", "=", "open"),
("asset_id.operating_unit_id.cb_group_id", "=", self.cb_group_id.id),
]
lines = Line.search(criteria)
# raise UserError(str(lines))
self.write({
"depreciation_line_ids": [(6, 0, lines.ids)]
})

@api.multi
def _prepare_data_core_banking(self):
backend = self.cb_asset_backend_id
data = {
"APP_ID": backend.app_id,
"NO_TRANS": self.name,
"REK_DEBET": self.warehouse_id.code + self.depreciation_expense_account_id.code,
"REK_DEBET": self.cb_group_id.code + self.depreciation_expense_account_id.code,
"NOMINAL_DEBET": self.final_depreciation_amount,
"KET_DEBET": self.description,
"NOTLP_DEBET": "",
"JENIS_TRANS": "0200",
"REK_KREDIT1": self.warehouse_id.code + self.depreciation_account_id.code,
"REK_KREDIT1": self.cb_group_id.code + self.depreciation_account_id.code,
"NOMINAL_KREDIT1": self.final_depreciation_amount,
"KET_KREDIT1": self.description,
"NOTLP_KREDIT1": "",
Expand Down
26 changes: 26 additions & 0 deletions bssb_core_banking_asset/models/cb_group.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# Copyright 2020 OpenSynergy Indonesia
# Copyright 2020 PT. Simetri Sinergi Indonesia
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from openerp import _, api, fields, models
from openerp.exceptions import Warning as UserError


class CoreBankingGroup(models.Model):
_name = "cb_group"
_description = "Core Banking Group"


name = fields.Char(
string="Name",
required=True,
)
code = fields.Char(
string="Code",
required=True,
)
active = fields.Boolean(
string="Active",
default=True,
)
13 changes: 13 additions & 0 deletions bssb_core_banking_asset/models/operating_unit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2024 OpenSynergy Indonesia
# Copyright 2024 PT. Simetri Sinergi Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import api, fields, models


class OperatingUnit(models.Model):
_inherit = "operating.unit"

cb_group_id = fields.Many2one(
string="Core Banking Group",
comodel_name="cb_group",
)
3 changes: 3 additions & 0 deletions bssb_core_banking_asset/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ cb_asset_backend_user,cb_asset_backend – User,model_cb_asset_backend,base.grou
cb_asset_backend_all,cb_asset_backend - All,model_cb_asset_backend,,1,0,0,0
cb_asset_batch_user,cb_asset_batch – User,model_cb_asset_batch,base.group_user,1,1,1,1
cb_asset_batch_all,cb_asset_batch - All,model_cb_asset_batch,,1,0,0,0
cb_group_all,cb_group_all - All,model_cb_group,,1,0,0,0
cb_group_admin,cb_group_all - Admin,model_cb_group,base.group_system,1,1,1,1
cb_group_ati_admin,cb_group_all - ATI Admin,model_cb_group,bssb.group_pat_administrator,1,1,1,1
26 changes: 21 additions & 5 deletions bssb_core_banking_asset/views/cb_asset_batch_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@
<field name="model">cb_asset_batch</field>
<field name="arch" type="xml">
<tree>
<field name="id" optional="hide" />
<field name="id"/>
<field name="name" />
<field name="cb_group_id" />
<field name="accounting_category_id" />
<field name="date"/>
<field name="date_start"/>
<field name="date_end"/>
<field name="state" />
</tree>
</field>
Expand Down Expand Up @@ -76,7 +81,8 @@
<group name="header" colspan="4" col="2">
<group name="header_left">
<field name="name" />
<field name="warehouse_id" />
<field name="cb_group_id" />
<field name="accounting_category_id" />
<field name="depreciation_account_id" />
<field name="depreciation_expense_account_id" />
</group>
Expand All @@ -96,6 +102,16 @@
<field name="manual_depreciation_amount" />
<field name="final_depreciation_amount" />
</group>
<button name="action_load_depreciation_line" type="object" string="Load" help="Load depreciation line with matching criteria"/>
<field name="depreciation_line_ids">
<tree>
<field name="asset_id"/>
<field name="line_date"/>
<field name="asset_value"/>
<field name="amount"/>
<field name="remaining_value"/>
</tree>
</field>
</page>
<page name="description" string="Description">
<field name="description" colspan="4" nolabel="1" />
Expand All @@ -118,7 +134,7 @@
</record>

<record id="cb_asset_batch_action" model="ir.actions.act_window">
<field name="name">Asset Batches</field>
<field name="name">Core Banking Depreciation</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">cb_asset_batch</field>
<field name="view_type">form</field>
Expand All @@ -127,8 +143,8 @@

<menuitem
id="cb_asset_batch_menu"
name="Asset Batches"
parent="fixed_asset.menu_finance_assets"
name="Core Banking Depreciation"
parent="bssb.ati_fixed_asset_menu"
action="cb_asset_batch_action"
sequence="30"
/>
Expand Down
69 changes: 69 additions & 0 deletions bssb_core_banking_asset/views/cb_group_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?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="cb_group_view_form" model="ir.ui.view">
<field name="name">cb_group - form</field>
<field name="model">cb_group</field>
<field name="arch" type="xml">
<form>
<header />
<sheet>
<div
class="oe_right oe_button_box"
style="width: 300px;"
name="buttons"
/>
<group name="group_1" colspan="4" col="2">
<group name="group_1_1" colspan="1" col="2">
<field name="name" />
<field name="active" />
<field name="code" />
</group>
</group>
<notebook>
</notebook>
</sheet>
</form>
</field>
</record>

<record id="cb_group_view_tree" model="ir.ui.view">
<field name="name">cb_group - tree</field>
<field name="model">cb_group</field>
<field name="arch" type="xml">
<tree>
<field name="name" />
<field name="code" />
</tree>
</field>
</record>

<record id="cb_group_view_search" model="ir.ui.view">
<field name="name">cb_group - search</field>
<field name="model">cb_group</field>
<field name="arch" type="xml">
<search>
<field name="name"/>
</search>
</field>
</record>

<record id="cb_group_action" model="ir.actions.act_window">
<field name="name">Core Banking Group</field>
<field name="res_model">cb_group</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>

<menuitem
id="menu_cb_group"
name="Core Banking Group"
parent="bssb.ati_configuration_user_management"
action="cb_group_action"
/>

</data>
</openerp>
20 changes: 20 additions & 0 deletions bssb_core_banking_asset/views/operating_unit_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--Copyright 2024 OpenSynergy Indonesia-->
<!--Copyright 2024 PT. Simetri Sinergi Indonesia-->
<!--License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).-->
<openerp>
<data>
<record id="operating_unit_view_form" model="ir.ui.view">
<field name="name">operating.unit - Form</field>
<field name="model">operating.unit</field>
<field name="inherit_id" ref="operating_unit.view_operating_unit_form" />
<field name="arch" type="xml">
<data>
<xpath expr="//field[@name='partner_id']" position="after">
<field name="cb_group_id"/>
</xpath>
</data>
</field>
</record>
</data>
</openerp>

0 comments on commit efe7004

Please sign in to comment.