From db775b28969f76e257e3b58569969c907751abf5 Mon Sep 17 00:00:00 2001 From: Sergio Lop Sanz Date: Tue, 11 Jun 2024 20:11:20 +0200 Subject: [PATCH] Lista acumulado a fin de cada mes (#343) * Lista acumulado a fin de cada mes * Lista acumulado a fin de cada mes --- account_global_balance/__init__.py | 4 ++ account_global_balance/__manifest__.py | 34 +++++++++++ account_global_balance/models/__init__.py | 4 ++ .../models/account_global_balance.py | 56 ++++++++++++++++++ .../security/ir.model.access.csv | 3 + .../static/description/icon.png | Bin 0 -> 9250 bytes .../views/account_global_balance_views.xml | 50 ++++++++++++++++ 7 files changed, 151 insertions(+) create mode 100644 account_global_balance/__init__.py create mode 100644 account_global_balance/__manifest__.py create mode 100644 account_global_balance/models/__init__.py create mode 100644 account_global_balance/models/account_global_balance.py create mode 100644 account_global_balance/security/ir.model.access.csv create mode 100644 account_global_balance/static/description/icon.png create mode 100644 account_global_balance/views/account_global_balance_views.xml diff --git a/account_global_balance/__init__.py b/account_global_balance/__init__.py new file mode 100644 index 0000000..0018867 --- /dev/null +++ b/account_global_balance/__init__.py @@ -0,0 +1,4 @@ +############################################################################### +# For copyright and license notices, see __manifest__.py file in root directory +############################################################################### +from . import models diff --git a/account_global_balance/__manifest__.py b/account_global_balance/__manifest__.py new file mode 100644 index 0000000..08c4df8 --- /dev/null +++ b/account_global_balance/__manifest__.py @@ -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 . +# +############################################################################### +{ + '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', + ], +} diff --git a/account_global_balance/models/__init__.py b/account_global_balance/models/__init__.py new file mode 100644 index 0000000..a081c3a --- /dev/null +++ b/account_global_balance/models/__init__.py @@ -0,0 +1,4 @@ +############################################################################### +# For copyright and license notices, see __manifest__.py file in root directory +############################################################################### +from . import account_global_balance diff --git a/account_global_balance/models/account_global_balance.py b/account_global_balance/models/account_global_balance.py new file mode 100644 index 0000000..f8f6ad4 --- /dev/null +++ b/account_global_balance/models/account_global_balance.py @@ -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 + ); + """) diff --git a/account_global_balance/security/ir.model.access.csv b/account_global_balance/security/ir.model.access.csv new file mode 100644 index 0000000..84cf1e5 --- /dev/null +++ b/account_global_balance/security/ir.model.access.csv @@ -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 \ No newline at end of file diff --git a/account_global_balance/static/description/icon.png b/account_global_balance/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..32738e6d80c493b8b2224bff5de0bc493583e111 GIT binary patch literal 9250 zcmbt)bx<5#^kqZvAcNcBPLRRf9RdM@1a}GU1Sc@TEw}^^5FogF2oPk@5G=S`fB?bm z*WdoPRl8MNwLR0*HLts8y5GC++;h(DXiW_z94rbf003}Ql;yR-?YsY03}o=L8LjXG zxIwX#QI`RLy2R)A7O3ENS}SF3bpY^Z27pjF0NjF2p?d(}4FiA!a{v&{1OQUEPwiUb z;0`oPH6?lA>AzP&S6K?!g6XDg;0XZF3I1D=el7>!gN^83D(VX8JI@HPk=XtFnlS)? z0bfO4M(5q{qafcvotfq*N#~uHr7d1R+1MH(81yp$vZ?$#_(qp0L=7NTkd{7a2rV-8 zi&-PAC515k8!w3!I+R?mC(Ne?^6MViTxs+u(f7CzZ)7Uk0~Ar|UzlE@UkLXAEtW~7B8`G) z^8e2Ve5Cprli$w}VG(jk_Qbho8X5tyBtug`0lv8#f77{6+x7dWMf=ZXv14z3%IDA5 z*o8g-2&Qx$H1EGY6HnX}PS~`RhhcB}Q3o+Z5I=1DncnL~;w|F!*>?}bH3f|XHDSJ^ zmIg4O0PX$as|IJ}-{Dqaw39~6Ddn{V|1F_=meoDlvb4DXCQ_K|bto3o;pqvSH5Wyj_vJU13~V zWv$dH`#%c}yP0)Xg9(&&Ffv*=bPyA-1MW-;^jO9_0kTCNvdL(fmk{NGCiWD5B9)6j_YB?573$%KogcIb#=nGkM zP4hD|g`KYdx^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-@yzt}^o;yEYt&;B+O2%~fxL8d>nQ?`XXodK2L~|h!{M#egFEEWHi?w zezN$FA3qxAYG{hFryX?QP_CFZ|Jj==UJbdT`b}BCGwSEpi);<+1l`K8n{%)ib3O0h zDJu_E%v4?-EicYb7U)$@vE>;y_^lTyfW~M|&n;*f6;BD<9QOk0Mw`V*v%4s2k>?HYhz+!Mq;p%iwFn^ zCYgGyTF{oa=(unNwnjh=ldw=+1u%*!^Ip6;za| zOGNf}=6kN`F?GV<^hn=G3L-@<1B0wjnP0S7B@G(T{62p_?4Cz66cokCBay4 za-1uDnFl4O=3-J|Qy{;%onlbR8yd#XBoW$}iiMH&J62-9+cpsXvC(Ua2nh&MlWt~G z+en1SrVOX1XH!`6SDUrq%I1ZP+4x3+%&_Y+VBw>!WS02Kud K`D$77u>S#3G + + + account.global.balance.tree + account.global.balance + + + + + + + + + + + account.global.balance.form + account.global.balance + +
+ + + + + + + +
+
+
+ + + + Account Global Balance + ir.actions.act_window + account.global.balance + tree,pivot,form + +

+ Create a new Account Global Balance +

+ Here, you can create and manage your Account Global Balances. +

+
+
+ + + +