diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2023-08-31 11:51:50 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2023-08-31 11:51:50 +0700 |
| commit | b7dba2d8eed3c2af22dca53a916f12e9b842c2aa (patch) | |
| tree | 3ca984df1c729378f463cedef6f6e7c95ec591da | |
| parent | 403b86d1a3cc168680069b0d8fc499048583da8f (diff) | |
coa cost centre
| -rwxr-xr-x | indoteknik_custom/__manifest__.py | 3 | ||||
| -rwxr-xr-x | indoteknik_custom/models/__init__.py | 3 | ||||
| -rw-r--r-- | indoteknik_custom/models/account_account.py | 6 | ||||
| -rw-r--r-- | indoteknik_custom/models/account_move_line.py | 22 | ||||
| -rw-r--r-- | indoteknik_custom/models/cost_centre.py | 11 | ||||
| -rwxr-xr-x | indoteknik_custom/security/ir.model.access.csv | 1 | ||||
| -rw-r--r-- | indoteknik_custom/views/account_account_views.xml | 15 | ||||
| -rw-r--r-- | indoteknik_custom/views/account_move_line.xml | 16 | ||||
| -rw-r--r-- | indoteknik_custom/views/cost_centre.xml | 41 |
9 files changed, 118 insertions, 0 deletions
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 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<odoo> + <data> + <record id="account_account_view_inherit" model="ir.ui.view"> + <field name="name">account.account.list</field> + <field name="model">account.account</field> + <field name="inherit_id" ref="account.view_account_list"/> + <field name="arch" type="xml"> + <field name="currency_id" position="after"> + <field name="cost_centre_id" options="{'no_create': True}"/> + </field> + </field> + </record> + </data> +</odoo>
\ 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 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<odoo> + <data> + <record id="view_move_form_inherit" model="ir.ui.view"> + <field name="name">account.move.form.inherit</field> + <field name="model">account.move</field> + <field name="inherit_id" ref="account.view_move_form"/> + <field name="arch" type="xml"> + <xpath expr="//page[@id='aml_tab']/field[@name='line_ids']/tree/field[@name='currency_id']" position="before"> + <field name="is_required" invisible="1"/> + <field name="cost_centre_id" /> + </xpath> + </field> + </record> + </data> +</odoo> 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 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<odoo> + <record id="cost_centre_tree" model="ir.ui.view"> + <field name="name">cost.centre.tree</field> + <field name="model">cost.centre</field> + <field name="arch" type="xml"> + <tree editable="top"> + <field name="name"/> + <field name="description"/> + </tree> + </field> + </record> + + <record id="cost_centre_form" model="ir.ui.view"> + <field name="name">cost.centre.form</field> + <field name="model">cost.centre</field> + <field name="arch" type="xml"> + <form> + <sheet string="Cost Centre"> + <group> + <group> + <field name="name"/> + <field name="description"/> + </group> + </group> + </sheet> + </form> + </field> + </record> + + <record id="cost_centre_action" model="ir.actions.act_window"> + <field name="name">Cost Centre</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">cost.centre</field> + <field name="view_mode">tree,form</field> + </record> + + <menuitem name="Cost Centre" action="cost_centre_action" + id="menu_cost_centre" + parent="account.menu_finance_entries" sequence="112"/> +</odoo>
\ No newline at end of file |
