-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
############################################################################### | ||
# For copyright and license notices, see __manifest__.py file in root directory | ||
############################################################################### | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
############################################################################### | ||
# | ||
# Copyright (C) 2024-Today SIDOO Soluciones SL | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################### | ||
{ | ||
'name': 'MIS Report por Grupo', | ||
'summary': 'Vista para sacar balances MIS por grupo en lugar de cuenta.', | ||
'author': 'Sergio Lop Sanz', | ||
'website': 'https://www.sidoo.es', | ||
'license': 'AGPL-3', | ||
'category': 'MIS Report', | ||
'version': '12.0.0', | ||
'depends': [ | ||
'account', | ||
], | ||
'data': [ | ||
'security/ir.model.access.csv', | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
############################################################################### | ||
# For copyright and license notices, see __manifest__.py file in root directory | ||
############################################################################### | ||
from . import account_move_line_group |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
############################################################################### | ||
# For copyright and license notices, see __manifest__.py file in root directory | ||
############################################################################### | ||
from odoo import fields, models, tools, api | ||
|
||
|
||
class AccountMoveLineGroup(models.Model): | ||
_name = 'account.move.line.group' | ||
_description = 'Apuntes por Grupo de Cuentas' | ||
_auto = False | ||
_table = 'account_move_line_group' | ||
|
||
account_id = fields.Many2one('account.account', string='Account') | ||
date = fields.Date(string='Date') | ||
credit = fields.Float(string='Credit') | ||
debit = fields.Float(string='Debit') | ||
company_id = fields.Many2one('res.company', string='Company') | ||
user_type_id = fields.Many2one( | ||
'account.account.type', | ||
auto_join=True, | ||
readonly=True, | ||
index=True, | ||
) | ||
reconciled = fields.Boolean( | ||
readonly=True, | ||
) | ||
full_reconcile_id = fields.Many2one( | ||
'account.full.reconcile', | ||
string="Matching Number", | ||
readonly=True, | ||
index=True, | ||
) | ||
partner_id = fields.Many2one('res.partner', string='Partner') | ||
|
||
@api.model_cr | ||
def init(self): | ||
tools.drop_view_if_exists(self._cr, self._table) | ||
self._cr.execute(""" | ||
CREATE OR REPLACE VIEW account_move_line_group AS ( | ||
SELECT | ||
acc2.id AS account_id, | ||
acc2.code AS acc2_code, | ||
acc2.name AS acc2_name, | ||
acc.code AS original_code, | ||
acc.name AS original_name, | ||
aml.id AS id, | ||
aml.date AS date, | ||
aml.debit AS debit, | ||
aml.credit AS credit, | ||
aml.company_id AS company_id, | ||
aml.user_type_id AS user_type_id, | ||
aml.reconciled AS reconciled, | ||
aml.full_reconcile_id AS full_reconcile_id, | ||
aml.partner_id AS partner_id | ||
FROM account_move_line aml | ||
JOIN account_account acc ON aml.account_id = acc.id | ||
LEFT JOIN ( | ||
SELECT aa.group_id, aa.company_id, aa.id, aa.code, aa.name | ||
FROM account_account aa | ||
WHERE aa.code = ( | ||
SELECT MIN(code) | ||
FROM account_account aa2 | ||
WHERE aa2.group_id = aa.group_id AND aa2.company_id = aa.company_id | ||
) | ||
GROUP BY 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 | ||
) | ||
""") | ||
accounts = self.env['account.account'] | ||
for acc in self.env['account.account'].search([ | ||
('user_type_id', '!=', 'Current Year Earnings'), | ||
('group_id', '!=', False),]): | ||
if not accounts.search([ | ||
('company_id', '=', acc.company_id.id), | ||
('code', '=', acc.group_id.code_prefix)]): | ||
acc.copy({ | ||
'company_id': acc.company_id.id, | ||
'name': acc.group_id.name or '', | ||
'code': acc.group_id.code_prefix, | ||
'deprecated': True, | ||
'asset_profile_id': False, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
access_account_move_line_group,access_account_move_line_group,model_account_move_line_group,base.group_user,1,1,1,1 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.