summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
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 /indoteknik_custom/models
parentfb2ee6f00d4b8caf351b05db92af7bf0e4774ec8 (diff)
change cost_centre to analytic_account
Diffstat (limited to 'indoteknik_custom/models')
-rw-r--r--indoteknik_custom/models/account_account.py3
-rw-r--r--indoteknik_custom/models/account_move_line.py14
2 files changed, 10 insertions, 7 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
+