-
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.
Lista acumulado a fin de cada mes (#343)
* Lista acumulado a fin de cada mes * Lista acumulado a fin de cada mes
- Loading branch information
Showing
7 changed files
with
151 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,34 @@ | ||
############################################################################### | ||
# | ||
# 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': 'Listado con balance acumulado por cuenta', | ||
'summary': 'Vista para listar de saldos acumulados por cuenta.', | ||
'author': 'Sergio Lop Sanz', | ||
'website': 'https://www.sidoo.es', | ||
'license': 'AGPL-3', | ||
'category': 'account', | ||
'version': '14.0.0', | ||
'depends': [ | ||
'account', | ||
], | ||
'data': [ | ||
'security/ir.model.access.csv', | ||
'views/account_global_balance_views.xml', | ||
], | ||
} |
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_global_balance |
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,56 @@ | ||
############################################################################### | ||
# For copyright and license notices, see __manifest__.py file in root directory | ||
############################################################################### | ||
from odoo import fields, models, tools | ||
|
||
|
||
class AccountGlobalBalance(models.Model): | ||
_name = 'account.global.balance' | ||
_description = 'Apuntes con acumulado global mensual' | ||
_auto = False | ||
_table = 'account_global_balance' | ||
|
||
id = fields.Integer(string='ID', readonly=True) | ||
account_id = fields.Many2one('account.account', string='Account') | ||
month = fields.Date(string='Month') | ||
balance = fields.Float(string='Balance', group_operator='avg') | ||
|
||
def init(self): | ||
tools.drop_view_if_exists(self._cr, self._table) | ||
self._cr.execute(""" | ||
CREATE OR REPLACE VIEW account_global_balance AS ( | ||
WITH monthly_balance AS ( | ||
SELECT | ||
account_id, | ||
DATE_TRUNC('MONTH', date) AS month, | ||
SUM(debit) - SUM(credit) AS balance | ||
FROM | ||
account_move_line | ||
WHERE | ||
parent_state = 'posted' | ||
GROUP BY | ||
account_id, | ||
DATE_TRUNC('MONTH', date) | ||
), | ||
cumulative_balance AS ( | ||
SELECT | ||
account_id, | ||
month, | ||
SUM(balance) OVER ( | ||
PARTITION BY account_id | ||
ORDER BY month | ||
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW | ||
) AS balance | ||
FROM | ||
monthly_balance | ||
), | ||
numbered_balance AS ( | ||
SELECT | ||
ROW_NUMBER() OVER (ORDER BY account_id, month) AS id, | ||
* | ||
FROM | ||
cumulative_balance | ||
) | ||
SELECT * FROM numbered_balance | ||
); | ||
""") |
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,3 @@ | ||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
access_account_global_balance_all,access_account_global_balance_all,model_account_global_balance,base.group_user,1,0,0,0 | ||
access_account_global_balance_accountant,access_account_global_balance_accountant,model_account_global_balance,account.group_account_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.
50 changes: 50 additions & 0 deletions
50
account_global_balance/views/account_global_balance_views.xml
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,50 @@ | ||
<!-- account_global_balance_views.xml --> | ||
<odoo> | ||
<record id="view_account_global_balance_tree" model="ir.ui.view"> | ||
<field name="name">account.global.balance.tree</field> | ||
<field name="model">account.global.balance</field> | ||
<field name="arch" type="xml"> | ||
<tree string="Saldos acumulados mes" create="0"> | ||
<field name="account_id"/> | ||
<field name="month"/> | ||
<field name="balance" avg="Promedio"/> | ||
</tree> | ||
</field> | ||
</record> | ||
|
||
<record id="view_account_global_balance_form" model="ir.ui.view"> | ||
<field name="name">account.global.balance.form</field> | ||
<field name="model">account.global.balance</field> | ||
<field name="arch" type="xml"> | ||
<form string="Account Global Balance"> | ||
<sheet> | ||
<group> | ||
<field name="account_id"/> | ||
<field name="month"/> | ||
<field name="balance"/> | ||
</group> | ||
</sheet> | ||
</form> | ||
</field> | ||
</record> | ||
|
||
|
||
<record id="action_account_global_balance" model="ir.actions.act_window"> | ||
<field name="name">Account Global Balance</field> | ||
<field name="type">ir.actions.act_window</field> | ||
<field name="res_model">account.global.balance</field> | ||
<field name="view_mode">tree,pivot,form</field> | ||
<field name="help" type="html"> | ||
<p class="o_view_nocontent_smiling_face"> | ||
Create a new Account Global Balance | ||
</p><p> | ||
Here, you can create and manage your Account Global Balances. | ||
</p> | ||
</field> | ||
</record> | ||
|
||
<menuitem id="menu_account_global_balance" name="Account Global Balance" | ||
parent="account.menu_finance_entries_accounting_miscellaneous" sequence="10" | ||
action="action_account_global_balance"/> | ||
|
||
</odoo> |