Merge lp:~vauxoo/addons-vauxoo/addons-vauxoo-account_move_sum_all_credits_debits-dev-fernando2 into lp:addons-vauxoo

Proposed by Fernando Lopez
Status: Merged
Merged at revision: 488
Proposed branch: lp:~vauxoo/addons-vauxoo/addons-vauxoo-account_move_sum_all_credits_debits-dev-fernando2
Merge into: lp:addons-vauxoo
Diff against target: 175 lines (+152/-0)
4 files modified
account_move_sum_all_credits_debits/__init__.py (+26/-0)
account_move_sum_all_credits_debits/__openerp__.py (+45/-0)
account_move_sum_all_credits_debits/account.py (+56/-0)
account_move_sum_all_credits_debits/account_view.xml (+25/-0)
To merge this branch: bzr merge lp:~vauxoo/addons-vauxoo/addons-vauxoo-account_move_sum_all_credits_debits-dev-fernando2
Reviewer Review Type Date Requested Status
Fernando Lopez (community) Needs Resubmitting
Moisés López - http://www.vauxoo.com Needs Fixing
Review via email: mp+126733@code.launchpad.net

Description of the change

Se agregó el modulo que realiza en la vista form, en 2 campos, la suma de todos los credits y debits de la base de datos del modelo account move usando sql

To post a comment you must log in.
Revision history for this message
Moisés López - http://www.vauxoo.com (moylop260) wrote :

Fernando,
Haz la prueba de este function creando 3 registros de account.move con diferentes cantidades cada unom
Y veras que en los 3 te estará mostrando la misma cantidad.

Y en este caso, en la misma funcion puedes devolver el field_name para no tener que hacer casi la misma operacion, pero con diferentes campos 2 veces

review: Needs Fixing
471. By Fernando Lopez

[IMP]Made the changes so it shows the debit and credits of that record, not all account moves

472. By Fernando Lopez

[REM]Removed code lines for debugging

Revision history for this message
Fernando Lopez (kyon) wrote :

Se hizo el cambio de obtener la suma solo del registro actual, y no la suma de todos los registros de la base de datos. Se fusionó a una sola función en lugar de 2.

review: Needs Resubmitting

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'account_move_sum_all_credits_debits'
2=== added file 'account_move_sum_all_credits_debits/__init__.py'
3--- account_move_sum_all_credits_debits/__init__.py 1970-01-01 00:00:00 +0000
4+++ account_move_sum_all_credits_debits/__init__.py 2012-09-28 19:45:26 +0000
5@@ -0,0 +1,26 @@
6+# -*- encoding: utf-8 -*-
7+###########################################################################
8+# Module Writen to OpenERP, Open Source Management Solution
9+#
10+# Copyright (c) 2012 Vauxoo - http://www.vauxoo.com
11+# All Rights Reserved.
12+# info@vauxoo.com
13+############################################################################
14+# Coded by: fernandoL (fernando_ld@vauxoo.com)
15+############################################################################
16+#
17+# This program is free software: you can redistribute it and/or modify
18+# it under the terms of the GNU Affero General Public License as
19+# published by the Free Software Foundation, either version 3 of the
20+# License, or (at your option) any later version.
21+#
22+# This program is distributed in the hope that it will be useful,
23+# but WITHOUT ANY WARRANTY; without even the implied warranty of
24+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25+# GNU Affero General Public License for more details.
26+#
27+# You should have received a copy of the GNU Affero General Public License
28+# along with this program. If not, see <http://www.gnu.org/licenses/>.
29+#
30+##############################################################################
31+import account
32\ No newline at end of file
33
34=== added file 'account_move_sum_all_credits_debits/__openerp__.py'
35--- account_move_sum_all_credits_debits/__openerp__.py 1970-01-01 00:00:00 +0000
36+++ account_move_sum_all_credits_debits/__openerp__.py 2012-09-28 19:45:26 +0000
37@@ -0,0 +1,45 @@
38+# -*- encoding: utf-8 -*-
39+###########################################################################
40+# Module Writen to OpenERP, Open Source Management Solution
41+#
42+# Copyright (c) 2012 Vauxoo - http://www.vauxoo.com
43+# All Rights Reserved.
44+# info@vauxoo.com
45+############################################################################
46+# Coded by: fernandoL (fernando_ld@vauxoo.com)
47+############################################################################
48+#
49+# This program is free software: you can redistribute it and/or modify
50+# it under the terms of the GNU Affero General Public License as
51+# published by the Free Software Foundation, either version 3 of the
52+# License, or (at your option) any later version.
53+#
54+# This program is distributed in the hope that it will be useful,
55+# but WITHOUT ANY WARRANTY; without even the implied warranty of
56+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57+# GNU Affero General Public License for more details.
58+#
59+# You should have received a copy of the GNU Affero General Public License
60+# along with this program. If not, see <http://www.gnu.org/licenses/>.
61+#
62+##############################################################################
63+
64+{
65+ "name": "Account move sum all credits debits",
66+ "version": "1.0",
67+ "author" : "Vauxoo",
68+ "category": "Generic Modules/Production",
69+ "website" : "http://www.vauxoo.com/",
70+ "description": """ Add two function fields to sum all of the credits and
71+ debits of the account move lines
72+ """,
73+ 'depends': ['account'],
74+ 'init_xml': [],
75+ 'update_xml': [
76+ 'account_view.xml',
77+ ],
78+ 'demo_xml': [],
79+ 'test': [],
80+ 'installable': True,
81+ 'active': False,
82+}
83\ No newline at end of file
84
85=== added file 'account_move_sum_all_credits_debits/account.py'
86--- account_move_sum_all_credits_debits/account.py 1970-01-01 00:00:00 +0000
87+++ account_move_sum_all_credits_debits/account.py 2012-09-28 19:45:26 +0000
88@@ -0,0 +1,56 @@
89+# -*- encoding: utf-8 -*-
90+###########################################################################
91+# Module Writen to OpenERP, Open Source Management Solution
92+#
93+# Copyright (c) 2012 Vauxoo - http://www.vauxoo.com
94+# All Rights Reserved.
95+# info@vauxoo.com
96+############################################################################
97+# Coded by: fernandoL (fernando_ld@vauxoo.com)
98+############################################################################
99+#
100+# This program is free software: you can redistribute it and/or modify
101+# it under the terms of the GNU Affero General Public License as
102+# published by the Free Software Foundation, either version 3 of the
103+# License, or (at your option) any later version.
104+#
105+# This program is distributed in the hope that it will be useful,
106+# but WITHOUT ANY WARRANTY; without even the implied warranty of
107+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
108+# GNU Affero General Public License for more details.
109+#
110+# You should have received a copy of the GNU Affero General Public License
111+# along with this program. If not, see <http://www.gnu.org/licenses/>.
112+#
113+##############################################################################
114+
115+from tools.translate import _
116+from osv import osv, fields
117+import decimal_precision as dp
118+
119+class account_move(osv.osv):
120+ _inherit = "account.move"
121+
122+ """example of query that get these fields ---
123+ select sum(credit), sum(debit)
124+ from account_move_line
125+ where move_id=27
126+ """
127+
128+ def _sum_credit_debit(self, cr, uid, ids, field, arg, context=None):
129+ suma = []
130+ dict = {}
131+ for id in ids:
132+ cr.execute("""select sum(credit), sum(debit)
133+ from account_move_line
134+ where move_id=%s""",(id,))
135+ suma = cr.fetchone()
136+ dict[id] = {field[0]:suma[0],field[1]:suma[1]}
137+ return dict#{25:{total_debit:1200},{total_credit:1200}}
138+
139+ _columns = {
140+ 'total_debit': fields.function(_sum_credit_debit, string='Total debit', method=True, digits_compute=dp.get_precision('Account'), type='float', multi="total_credit_debit"),
141+ 'total_credit': fields.function(_sum_credit_debit, string='Total credit', method=True, digits_compute=dp.get_precision('Account'), type='float', multi="total_credit_debit"),
142+ }
143+
144+account_move()
145\ No newline at end of file
146
147=== added file 'account_move_sum_all_credits_debits/account_view.xml'
148--- account_move_sum_all_credits_debits/account_view.xml 1970-01-01 00:00:00 +0000
149+++ account_move_sum_all_credits_debits/account_view.xml 2012-09-28 19:45:26 +0000
150@@ -0,0 +1,25 @@
151+<?xml version="1.0" encoding="utf-8"?>
152+<openerp>
153+ <data>
154+<!--
155+ Adding the fields to the parent account move view
156+-->
157+ <record id="account_move_sum_all_credits_debits_form" model="ir.ui.view">
158+ <field name="name">account.move.sum.all.credits.debits.form</field>
159+ <field name="model">account.move</field>
160+ <field name="inherit_id" ref="account.view_move_form" />
161+ <field name="type">form</field>
162+ <field name="arch" type="xml">
163+ <xpath expr="/form/group/field[@name='date']" position="after">
164+ <field name="total_debit"/>
165+ <field name="total_credit"/>
166+ </xpath>
167+ </field>
168+ </record>
169+
170+<!--
171+ View of wizard on stock.picking
172+-->
173+
174+ </data>
175+</openerp>