From 83d559fbbe5f6ff04538f6238fda8e614dfc0daf Mon Sep 17 00:00:00 2001 From: Sergio Lop Sanz Date: Tue, 11 Jun 2024 11:18:46 +0200 Subject: [PATCH] Haciendo que cuadre --- .../models/account_move_line_group.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/mis_report_por_grupo/models/account_move_line_group.py b/mis_report_por_grupo/models/account_move_line_group.py index 1a8e7fa..26977ca 100644 --- a/mis_report_por_grupo/models/account_move_line_group.py +++ b/mis_report_por_grupo/models/account_move_line_group.py @@ -50,7 +50,8 @@ def init(self): acc2.name AS acc2_name, acc.code AS original_code, acc.name AS original_name, - aml.id AS move_line_id, + aml.id AS move_line_id, + aml.id AS id, aml.date AS date, aml.debit AS debit, aml.credit AS credit, @@ -75,8 +76,12 @@ def init(self): aa.group_id, aa.company_id, aa.id, aa.code, aa.name ) AS acc2 ON acc2.group_id = acc.group_id AND acc2.company_id = aml.company_id + WHERE aml.parent_state != 'cancel' ) """) + self.recreate_accounts() + + def recreate_accounts(self): accounts = self.env['account.account'] for acc in self.env['account.account'].search([ ('user_type_id', '!=', 'Current Year Earnings'), @@ -84,10 +89,12 @@ def init(self): if not accounts.search([ ('company_id', '=', acc.company_id.id), ('code', '=', acc.group_id.code_prefix_start)]): - acc.copy({ + values = { 'company_id': acc.company_id.id, 'name': acc.group_id.name or '', 'code': acc.group_id.code_prefix_start, 'deprecated': True, - 'asset_profile_id': False, - }) + } + if 'asset_profile_id' in acc._fields: + values['asset_profile_id'] = False + acc.copy(values)