summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2023-09-01 10:31:23 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2023-09-01 10:31:23 +0700
commit41e76bb5b668473c8086ba82ea8f405315b8e5ae (patch)
treedcc9d5dadc971f6c38942af7e4522dcec6af9d0f
parentfb2ee6f00d4b8caf351b05db92af7bf0e4774ec8 (diff)
change cost_centre to analytic_account
-rw-r--r--indoteknik_custom/models/account_account.py3
-rw-r--r--indoteknik_custom/models/account_move_line.py14
-rw-r--r--indoteknik_custom/views/account_account_views.xml3
-rw-r--r--indoteknik_custom/views/account_move_line.xml6
4 files changed, 17 insertions, 9 deletions
diff --git a/indoteknik_custom/models/account_account.py b/indoteknik_custom/models/account_account.py
index 584c38f8..e2988625 100644
--- a/indoteknik_custom/models/account_account.py
+++ b/indoteknik_custom/models/account_account.py
@@ -3,4 +3,5 @@ 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
+ cost_centre_id = fields.Many2one('cost.centre', string='Cost Centre')
+ analytic_account_ids = fields.Many2many('account.analytic.account', string='Analytic Account') \ No newline at end of file
diff --git a/indoteknik_custom/models/account_move_line.py b/indoteknik_custom/models/account_move_line.py
index 87e5a182..cb969855 100644
--- a/indoteknik_custom/models/account_move_line.py
+++ b/indoteknik_custom/models/account_move_line.py
@@ -6,6 +6,13 @@ class AccountMoveLine(models.Model):
cost_centre_id = fields.Many2one('cost.centre', string='Cost Centre')
is_required = fields.Boolean(string='Is Required', compute='_compute_is_required')
+ analytic_account_ids = fields.Many2many('account.analytic.account', string='Analytic Account')
+
+ @api.onchange('account_id')
+ def _onchange_analytic_account_ids(self):
+ for account in self:
+ analytic_account = account.account_id.analytic_account_ids
+ account.analytic_account_ids = analytic_account
@api.onchange('account_id')
def _compute_is_required(self):
@@ -14,9 +21,4 @@ class AccountMoveLine(models.Model):
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/views/account_account_views.xml b/indoteknik_custom/views/account_account_views.xml
index 45d8a19c..20886787 100644
--- a/indoteknik_custom/views/account_account_views.xml
+++ b/indoteknik_custom/views/account_account_views.xml
@@ -7,7 +7,8 @@
<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 name="cost_centre_id" optional="hide"/>
+ <field name="analytic_account_ids" widget="many2many_tags" options="{'no_create': True}"/>
</field>
</field>
</record>
diff --git a/indoteknik_custom/views/account_move_line.xml b/indoteknik_custom/views/account_move_line.xml
index f4db8d86..f8d5db05 100644
--- a/indoteknik_custom/views/account_move_line.xml
+++ b/indoteknik_custom/views/account_move_line.xml
@@ -8,7 +8,11 @@
<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" />
+ <field name="cost_centre_id" optional="hide"/>
+ <field name="analytic_account_ids" widget="many2many_tags" options="{'no_create': True}" domain="[('id', 'in', analytic_account_ids)]"/>
+ </xpath>
+ <xpath expr="//page[@id='aml_tab']/field[@name='line_ids']/tree/field[@name='analytic_account_id']" position="attributes">
+ <attribute name="invisible">1</attribute>
</xpath>
</field>
</record>