From 41e76bb5b668473c8086ba82ea8f405315b8e5ae Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 1 Sep 2023 10:31:23 +0700 Subject: change cost_centre to analytic_account --- indoteknik_custom/models/account_account.py | 3 ++- indoteknik_custom/models/account_move_line.py | 14 ++++++++------ indoteknik_custom/views/account_account_views.xml | 3 ++- indoteknik_custom/views/account_move_line.xml | 6 +++++- 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 @@ - + + 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 @@ - + + + + + 1 -- cgit v1.2.3