From b7dba2d8eed3c2af22dca53a916f12e9b842c2aa Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 31 Aug 2023 11:51:50 +0700 Subject: coa cost centre --- indoteknik_custom/__manifest__.py | 3 ++ indoteknik_custom/models/__init__.py | 3 ++ indoteknik_custom/models/account_account.py | 6 ++++ indoteknik_custom/models/account_move_line.py | 22 ++++++++++++ indoteknik_custom/models/cost_centre.py | 11 ++++++ indoteknik_custom/security/ir.model.access.csv | 1 + indoteknik_custom/views/account_account_views.xml | 15 +++++++++ indoteknik_custom/views/account_move_line.xml | 16 +++++++++ indoteknik_custom/views/cost_centre.xml | 41 +++++++++++++++++++++++ 9 files changed, 118 insertions(+) create mode 100644 indoteknik_custom/models/account_account.py create mode 100644 indoteknik_custom/models/account_move_line.py create mode 100644 indoteknik_custom/models/cost_centre.py create mode 100644 indoteknik_custom/views/account_account_views.xml create mode 100644 indoteknik_custom/views/account_move_line.xml create mode 100644 indoteknik_custom/views/cost_centre.xml diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 0d38a7d7..e1be8910 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -93,6 +93,9 @@ 'views/price_group.xml', 'views/mrp_production.xml', 'views/apache_solr_queue.xml', + 'views/cost_centre.xml', + 'views/account_account_views.xml', + 'views/account_move_line.xml', 'report/report.xml', 'report/report_banner_banner.xml', 'report/report_banner_banner2.xml', diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index cf2597b0..b8be14ba 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -85,3 +85,6 @@ from . import base_import_import from . import product_attribute from . import mrp_production from . import solr +from . import cost_centre +from . import account_account +from . import account_move_line diff --git a/indoteknik_custom/models/account_account.py b/indoteknik_custom/models/account_account.py new file mode 100644 index 00000000..584c38f8 --- /dev/null +++ b/indoteknik_custom/models/account_account.py @@ -0,0 +1,6 @@ +from odoo import fields, models, api, _ + +class AccountAccount(models.Model): + _inherit = 'account.account' + + cost_centre_id = fields.Many2one('cost.centre', string='Cost Centre') \ No newline at end of file diff --git a/indoteknik_custom/models/account_move_line.py b/indoteknik_custom/models/account_move_line.py new file mode 100644 index 00000000..87e5a182 --- /dev/null +++ b/indoteknik_custom/models/account_move_line.py @@ -0,0 +1,22 @@ +from odoo import models, api, fields + + +class AccountMoveLine(models.Model): + _inherit = "account.move.line" + + cost_centre_id = fields.Many2one('cost.centre', string='Cost Centre') + is_required = fields.Boolean(string='Is Required', compute='_compute_is_required') + + @api.onchange('account_id') + def _compute_is_required(self): + for account in self: + if account.account_id.code and account.account_id.code[0] in ['6', '7']: + account.is_required = True + else: + account.is_required = False + + @api.onchange('account_id') + def _onchange_cost_centre_id(self): + for account in self: + cost_centre = account.account_id.cost_centre_id + account.cost_centre_id = cost_centre diff --git a/indoteknik_custom/models/cost_centre.py b/indoteknik_custom/models/cost_centre.py new file mode 100644 index 00000000..eaf518d5 --- /dev/null +++ b/indoteknik_custom/models/cost_centre.py @@ -0,0 +1,11 @@ +from odoo import fields, models, api +from datetime import datetime, timedelta +import logging + +_logger = logging.getLogger(__name__) + + +class CostCentre(models.Model): + _name = 'cost.centre' + name = fields.Char(string="Name") + description = fields.Text(string="Description") diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index c41587c0..e1480dd3 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -71,3 +71,4 @@ access_po_sync_price,access.po.sync.price,model_po_sync_price,,1,1,1,1 access_product_attribute_value,access.product.attribute.value,model_product_attribute_value,,1,1,1,1 access_mrp_production,access.mrp.production,model_mrp_production,,1,1,1,1 access_apache_solr_queue,access.apache.solr.queue,model_apache_solr_queue,,1,1,1,1 +access_cost_centre,access.cost.centre,model_cost_centre,,1,1,1,1 diff --git a/indoteknik_custom/views/account_account_views.xml b/indoteknik_custom/views/account_account_views.xml new file mode 100644 index 00000000..45d8a19c --- /dev/null +++ b/indoteknik_custom/views/account_account_views.xml @@ -0,0 +1,15 @@ + + + + + account.account.list + account.account + + + + + + + + + \ No newline at end of file diff --git a/indoteknik_custom/views/account_move_line.xml b/indoteknik_custom/views/account_move_line.xml new file mode 100644 index 00000000..f4db8d86 --- /dev/null +++ b/indoteknik_custom/views/account_move_line.xml @@ -0,0 +1,16 @@ + + + + + account.move.form.inherit + account.move + + + + + + + + + + diff --git a/indoteknik_custom/views/cost_centre.xml b/indoteknik_custom/views/cost_centre.xml new file mode 100644 index 00000000..665b0025 --- /dev/null +++ b/indoteknik_custom/views/cost_centre.xml @@ -0,0 +1,41 @@ + + + + cost.centre.tree + cost.centre + + + + + + + + + + cost.centre.form + cost.centre + +
+ + + + + + + + +
+
+
+ + + Cost Centre + ir.actions.act_window + cost.centre + tree,form + + + +
\ No newline at end of file -- cgit v1.2.3