Skip to content

Commit

Permalink
Balance a 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Lopsanz committed Jun 10, 2024
1 parent 63efb19 commit e7cc62a
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 0 deletions.
4 changes: 4 additions & 0 deletions mis_report_por_grupo/__init__.py
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
33 changes: 33 additions & 0 deletions mis_report_por_grupo/__manifest__.py
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',
],
}
4 changes: 4 additions & 0 deletions mis_report_por_grupo/models/__init__.py
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
82 changes: 82 additions & 0 deletions mis_report_por_grupo/models/account_move_line_group.py
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

Check failure on line 63 in mis_report_por_grupo/models/account_move_line_group.py

View workflow job for this annotation

GitHub Actions / flake8_py3

mis_report_por_grupo/models/account_move_line_group.py#L63

[E501] line too long
)
GROUP BY aa.group_id, aa.company_id, aa.id, aa.code, aa.name

Check failure on line 65 in mis_report_por_grupo/models/account_move_line_group.py

View workflow job for this annotation

GitHub Actions / flake8_py3

mis_report_por_grupo/models/account_move_line_group.py#L65

[E501] line too long
) AS acc2 ON acc2.group_id = acc.group_id AND acc2.company_id = aml.company_id

Check failure on line 66 in mis_report_por_grupo/models/account_move_line_group.py

View workflow job for this annotation

GitHub Actions / flake8_py3

mis_report_por_grupo/models/account_move_line_group.py#L66

[E501] line too long
)
""")
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,
})
2 changes: 2 additions & 0 deletions mis_report_por_grupo/security/ir.model.access.csv
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
Binary file added mis_report_por_grupo/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e7cc62a

Please sign in to comment.