Merge lp:~vauxoo/addons-vauxoo/7.0-aging_due_imp_format_by_document_report_dev_jorge into lp:addons-vauxoo/7.0

Status: Merged
Merged at revision: 891
Proposed branch: lp:~vauxoo/addons-vauxoo/7.0-aging_due_imp_format_by_document_report_dev_jorge
Merge into: lp:addons-vauxoo/7.0
Diff against target: 1453 lines (+1126/-168)
12 files modified
account_aged_partner_balance_vw/__init__.py (+1/-1)
account_aged_partner_balance_vw/__openerp__.py (+13/-7)
account_aged_partner_balance_vw/balance.py (+0/-17)
account_aged_partner_balance_vw/data/data.xml (+168/-0)
account_aged_partner_balance_vw/model/__init__.py (+27/-0)
account_aged_partner_balance_vw/model/account_aged_partner_balance_vw.py (+533/-106)
account_aged_partner_balance_vw/report/account_aged_partner_balance.mako (+244/-0)
account_aged_partner_balance_vw/report/report.xml (+23/-0)
account_aged_partner_balance_vw/view/action_menues.xml (+22/-14)
account_aged_partner_balance_vw/view/view.xml (+93/-21)
account_aged_partner_balance_vw/wizard/__init__.py (+1/-1)
account_aged_partner_balance_vw/wizard/wizard_open_move_line.py (+1/-1)
To merge this branch: bzr merge lp:~vauxoo/addons-vauxoo/7.0-aging_due_imp_format_by_document_report_dev_jorge
Reviewer Review Type Date Requested Status
hbto [Vauxoo] http://www.vauxoo.com Pending
Jorge Angel Naranjo Rogel - http://www.vauxoo.com Pending
Review via email: mp+189129@code.launchpad.net

Description of the change

Se agrega formato a reporte by_document.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_aged_partner_balance_vw/__init__.py'
2--- account_aged_partner_balance_vw/__init__.py 2012-07-28 05:09:49 +0000
3+++ account_aged_partner_balance_vw/__init__.py 2013-10-03 16:40:09 +0000
4@@ -24,5 +24,5 @@
5 #
6 ##############################################################################
7
8-import account_aged_partner_balance_vw
9+import model
10 import wizard
11
12=== modified file 'account_aged_partner_balance_vw/__openerp__.py'
13--- account_aged_partner_balance_vw/__openerp__.py 2013-04-19 21:04:05 +0000
14+++ account_aged_partner_balance_vw/__openerp__.py 2013-10-03 16:40:09 +0000
15@@ -26,20 +26,26 @@
16
17 {
18 "name" : "Report Account Aged Partner Balance view",
19- "version" : "1.0",
20+ "version" : "2.0",
21 "author" : "Vauxoo",
22 "category" : "Localization/Mexico",
23 "description" : """This module creates a sql view for Account Aged Partner Balance today.""",
24 "website" : "http://www.vauxoo.com/",
25 "license" : "AGPL-3",
26- "depends" : ["account",'board'],
27+ "depends" : [
28+ "account",
29+ 'board',
30+ 'report_webkit',
31+ ],
32 "init_xml" : [],
33 "demo_xml" : [],
34 "update_xml" : [
35- "account_aged_partner_balance_vw_wizard.xml",
36- "account_aged_partner_balance_vw_view.xml",
37- 'board_account_view.xml',
38+ "view/wizard.xml",
39+ "view/view.xml",
40+ 'view/action_menues.xml',
41+ "data/data.xml",
42+ 'report/report.xml',
43 ],
44- "installable" : False,
45- "active" : False,
46+ "installable" : True,
47+ "active" : True,
48 }
49
50=== removed file 'account_aged_partner_balance_vw/balance.py'
51--- account_aged_partner_balance_vw/balance.py 2013-04-18 00:38:02 +0000
52+++ account_aged_partner_balance_vw/balance.py 1970-01-01 00:00:00 +0000
53@@ -1,17 +0,0 @@
54-query_template = "SELECT %s FROM account_account"
55-columns = range(1, 5)
56-for i in columns:
57- # sum_colums = '0 AS col%s'%(columns)
58- # print map(lambda x: x, columns)
59- cols_query = ', '.join(map(lambda x: i == x and 'SUM(debit+credit) AS col%s' % (
60- x,) or '0 AS col%s' % (x,), columns))
61- dates_query = ' '
62- dates_query += ' BETWEEN %s AND %s)'
63- # query_full = query_template%(sum_colums)
64-# print query_full
65-
66-# cfd_data_invoices_str = '\n'.join( map(lambda x: '|'.join(x) + '|',
67-# cfd_data_invoices) )
68-
69-for i in range(5)[::-1]:
70- print i
71
72=== added directory 'account_aged_partner_balance_vw/data'
73=== added file 'account_aged_partner_balance_vw/data/data.xml'
74--- account_aged_partner_balance_vw/data/data.xml 1970-01-01 00:00:00 +0000
75+++ account_aged_partner_balance_vw/data/data.xml 2013-10-03 16:40:09 +0000
76@@ -0,0 +1,168 @@
77+<?xml version="1.0" ?>
78+<openerp>
79+ <data noupdate="0">
80+ <record id="ir_header_webkit_account_aged_partner_balance_report" model="ir.header_webkit">
81+ <field name="footer_html"><![CDATA[<html>
82+ <head>
83+ <meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
84+ <script>
85+ function subst() {
86+ var vars={};
87+ var x=document.location.search.substring(1).split('&');
88+ for(var i in x) {var z=x[i].split('=',2);vars[z[0]] = unescape(z[1]);}
89+ var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];
90+ for(var i in x) {
91+ var y = document.getElementsByClassName(x[i]);
92+ for(var j=0; j<y.length; ++j) y[j].textContent = vars[x[i]];
93+ }
94+ }
95+ </script>
96+ </head>
97+ <body style="border:0; margin: 0;" onload="subst()">
98+ <table style="border-top: 1px solid black; width: 100%">
99+ <tr >
100+ <td style="float:right;text-align:left;font-size:12;" width="30%">
101+ <script type="text/javascript">
102+ var date = new Date();
103+ var d = date.getDate();
104+ var day = (d < 10) ? '0' + d : d;
105+ var m = date.getMonth() + 1;
106+ var month = (m < 10) ? '0' + m : m;
107+ var yy = date.getYear();
108+ var year = (yy < 1000) ? yy + 1900 : yy;
109+ var h = date.getHours();
110+ var hours = (h < 10) ? '0' + h : h;
111+ var mm = date.getMinutes();
112+ var minutes = (mm < 10) ? '0' + mm : mm;
113+ document.write(day + "/" + month + "/" + year +
114+ "\t\t" + hours+":" + minutes );
115+ </script>
116+ </td>
117+ <td style="text-align:right;font-size:12;" width="65%">Page <span class="page"/></td><td style="text-align:left;font-size:12;"> of <span class="topage"/></td>
118+ </tr>
119+ </table>
120+ </body>
121+</html>]]></field>
122+ <field name="orientation">Landscape</field>
123+ <field name="format">Letter</field>
124+ <field name="html">
125+ <![CDATA[<html>
126+ <head>
127+ <meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
128+ <script>
129+ function subst() {
130+ var vars={};
131+ var x=document.location.search.substring(1).split('&');
132+ for(var i in x) {var z=x[i].split('=',2);vars[z[0]] = unescape(z[1]);}
133+ var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];
134+ for(var i in x) {
135+ var y = document.getElementsByClassName(x[i]);
136+ for(var j=0; j<y.length; ++j) y[j].textContent = vars[x[i]];
137+ }
138+ }
139+ </script>
140+ <style type="text/css">
141+ ${css}
142+ </style>
143+ </head>
144+ <body style="border:0; margin: 0;" onload="subst()">
145+ ${_debug or ''|n} </body>
146+ </html>]]>
147+ </field>
148+ <field name="css">
149+<![CDATA[
150+table.basic_table{
151+text-align:left;
152+border:1px solid lightGrey;
153+border-collapse: collapse;
154+}
155+
156+.dest_address { font-size:12pt;
157+margin-left:0;
158+text-align:left; l
159+ine-height:80%;
160+padding-top:0px
161+}
162+
163+.prueba{
164+color:black;
165+background-color:#dcdcdc;
166+}
167+
168+.celdaTotalTitulo{
169+font-size:11pt;
170+text-align:left;
171+font-weight:bold;
172+font-family:Arial,Helvetica,sans-serif;
173+background-color:#dcdcdc;
174+}
175+
176+.celdaBoxUp{
177+font-size:9pt;
178+font-family:Arial,Helvetica,sans-serif;
179+text-align:right;
180+background-color:#F5F5F5;
181+}
182+
183+.celdaTotal{
184+font-size:7pt;
185+font-family: monospace;
186+text-align:right;
187+font-weight:bold;
188+background-color:#EAEAEA;
189+}
190+
191+.celdaTotalTotales{
192+font-size:7pt;
193+font-family: monospace;
194+text-align:right;
195+font-weight:bold;
196+background-color:#EAEAEA;
197+}
198+
199+.celdaLineDataTitulo{
200+font-style:italic;
201+font-size:7pt;
202+text-align:left;
203+font-family:Arial,Helvetica,sans-serif;
204+background-color:#F5F5F5;
205+}
206+
207+.celdaLineData{
208+font-size:7pt;
209+font-family: monospace;
210+text-align:right;
211+background-color:#F5F5F5;
212+}
213+
214+.celdaTituloTabla{
215+font-size:8pt;
216+text-align:left;
217+font-family:Arial,Helvetica,sans-serif;
218+background-color:#620400;
219+font-weight:bold;
220+color:#FFFFFF;
221+}
222+
223+.celdaTituloPartner{
224+font-size:8pt;
225+text-align:left;
226+font-family:Arial,Helvetica,sans-serif;
227+background-color:#CDCDCD;
228+font-weight:bold;
229+}
230+
231+.celdaTituloTablaCompany{
232+font-size:11pt;
233+text-align:left;
234+font-family:Arial,Helvetica,sans-serif;
235+background-color:#620400;
236+color:#FFFFFF;
237+}
238+]]>
239+</field>
240+ <field name="name">Report Account Aged Partner Balance VW</field>
241+ </record>
242+
243+ </data>
244+</openerp>
245
246=== added directory 'account_aged_partner_balance_vw/model'
247=== added file 'account_aged_partner_balance_vw/model/__init__.py'
248--- account_aged_partner_balance_vw/model/__init__.py 1970-01-01 00:00:00 +0000
249+++ account_aged_partner_balance_vw/model/__init__.py 2013-10-03 16:40:09 +0000
250@@ -0,0 +1,27 @@
251+# -*- encoding: utf-8 -*-
252+###########################################################################
253+# Module Writen to OpenERP, Open Source Management Solution
254+#
255+# Copyright (c) 2011 Vauxoo - http://www.vauxoo.com/
256+# All Rights Reserved.
257+# info Vauxoo (info@vauxoo.com)
258+############################################################################
259+# Coded by: moylop260 (moylop260@vauxoo.com)
260+############################################################################
261+#
262+# This program is free software: you can redistribute it and/or modify
263+# it under the terms of the GNU Affero General Public License as
264+# published by the Free Software Foundation, either version 3 of the
265+# License, or (at your option) any later version.
266+#
267+# This program is distributed in the hope that it will be useful,
268+# but WITHOUT ANY WARRANTY; without even the implied warranty of
269+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
270+# GNU Affero General Public License for more details.
271+#
272+# You should have received a copy of the GNU Affero General Public License
273+# along with this program. If not, see <http://www.gnu.org/licenses/>.
274+#
275+##############################################################################
276+
277+import account_aged_partner_balance_vw
278
279=== renamed file 'account_aged_partner_balance_vw/account_aged_partner_balance_vw.py' => 'account_aged_partner_balance_vw/model/account_aged_partner_balance_vw.py'
280--- account_aged_partner_balance_vw/account_aged_partner_balance_vw.py 2013-04-18 00:38:02 +0000
281+++ account_aged_partner_balance_vw/model/account_aged_partner_balance_vw.py 2013-10-03 16:40:09 +0000
282@@ -1,13 +1,13 @@
283 # -*- encoding: utf-8 -*-
284-###########################################################################
285+#
286 # Module Writen to OpenERP, Open Source Management Solution
287 #
288 # Copyright (c) 2011 Vauxoo - http://www.vauxoo.com/
289 # All Rights Reserved.
290 # info Vauxoo (info@vauxoo.com)
291-############################################################################
292+#
293 # Coded by: moylop260 (moylop260@vauxoo.com)
294-############################################################################
295+#
296 #
297 # This program is free software: you can redistribute it and/or modify
298 # it under the terms of the GNU Affero General Public License as
299@@ -22,7 +22,7 @@
300 # You should have received a copy of the GNU Affero General Public License
301 # along with this program. If not, see <http://www.gnu.org/licenses/>.
302 #
303-##############################################################################
304+#
305
306 from openerp.osv import fields, osv
307 import openerp.tools as tools
308@@ -31,12 +31,12 @@
309 import openerp.netsvc as netsvc
310 import time
311 import os
312-
313-
314-class account_aged_partner_balance_vw(osv.Model):
315+import mx.DateTime
316+
317+
318+class account_aged_partner_balance_vw(osv.TransientModel):
319 _name = 'account.aged.partner.balance.vw'
320 _rec_name = 'partner_id'
321- _auto = False
322 _order = 'partner_id'
323
324 _columns = {
325@@ -48,102 +48,529 @@
326 'days_due_61to90': fields.float(u'61/90'),
327 'days_due_91to120': fields.float(u'91/120'),
328 'days_due_121togr': fields.float(u'+121'),
329- #'pending': fields.float(u'Pending'),
330 'company_id': fields.many2one('res.company', u'Company'),
331- 'currency_company_id': fields.many2one('res.currency', u'Company Currency'),
332- #'currency_src_id': fields.many2one('res.currency', u'Source Currency'),
333- }
334-
335- def init(self, cr):
336- # FALTA AGREGAR INNER JOIN CON COMPANY, PARA CASAR LA MONEDA POR
337- # DEFAULT Y TRANSFORMAR TODO A LA MONEDA DE LA COMPANY.
338- move_obj = self.pool.get('account.move.line')
339- ctx = {}
340- # ACCOUNT_TYPE = ['receivable']#customer
341- # ACCOUNT_TYPE = ['payable']#supplier
342- # ACCOUNT_TYPE = ['payable','receivable']#supplier & customer
343- # MOVE_STATE = ['posted']#, 'draft']
344- move_query = move_obj._query_get(cr, 1, obj='l', context=ctx)
345- # print 'en aged partner balance nueva modificacion---------------------------------------'
346- # query en version 97 con errores
347- #~ full_query ='''SELECT *
348- #~ FROM (
349- #~ SELECT MIN(l.id) as id, l.partner_id,
350- #~ SUM(l.debit-l.credit) AS "total",
351- #~ SUM(CASE WHEN days_due <= 00 THEN l.debit-l.credit ELSE 0 END ) AS "not_due",
352- #~ SUM(CASE WHEN days_due BETWEEN 01 AND 30 THEN l.debit-l.credit ELSE 0 END ) AS "days_due_01to30",
353- #~ SUM(CASE WHEN days_due BETWEEN 31 AND 60 THEN l.debit-l.credit ELSE 0 END ) AS "days_due_31to60",
354- #~ SUM(CASE WHEN days_due BETWEEN 61 AND 90 THEN l.debit-l.credit ELSE 0 END ) AS "days_due_61to90",
355- #~ SUM(CASE WHEN days_due BETWEEN 91 AND 120 THEN l.debit-l.credit ELSE 0 END ) AS "days_due_91to120",
356- #~ SUM(CASE WHEN days_due >=121 THEN l.debit-l.credit ELSE 0 END ) AS "days_due_121togr",
357- #~ COALESCE( l.currency_id, res_company.currency_id) AS "currency_src_id",
358- #~ res_company.currency_id AS "currency_company_id",
359- #~ l.company_id,l.currency_id as lcurrency
360- #~ FROM account_move_line l
361- #~ INNER JOIN
362- #~ (
363- #~ SELECT id, EXTRACT(DAY FROM (now() - COALESCE(lt.date_maturity,lt.date))) AS days_due
364- #~ FROM account_move_line lt
365- #~ --WHERE --lt.state, si ya finalizo no tiene fecha de vencimiento
366- #~ ) l2
367- #~ ON l2.id = l.id
368- #~ INNER JOIN account_account
369- #~ ON account_account.id = l.account_id
370- #~ INNER JOIN res_company
371- #~ ON account_account.company_id = res_company.id
372- #~ INNER JOIN account_move
373- #~ ON account_move.id = l.move_id
374- #~ WHERE account_account.active
375- #~ AND (account_account.type IN ('receivable'))
376- #~ --AND (l.reconcile_id IS NULL)
377- #~ AND account_move.state = 'posted'
378- #~ --AND %s
379- #~ --GROUP BY l.partner_id, l.currency_id, l.company_id, res_company.currency_id,l.currency_id --original
380- #~ GROUP BY l.partner_id, COALESCE(l.currency_id, res_company.currency_id), l.company_id, res_company.currency_id
381- #~ ) vw
382- #~ WHERE total <> 0
383- #~ and lcurrency is null '''%(move_query)
384-
385- # modificado el 07/07/2011 Isaac
386-
387- full_query = '''select * from (
388- SELECT MIN(l.id) as id, l.partner_id,
389- SUM(l.debit-l.credit) AS "total",
390- SUM(CASE WHEN days_due <= 00 THEN l.debit-l.credit ELSE 0 END ) AS "not_due",
391- SUM(CASE WHEN days_due BETWEEN 01 AND 30 THEN l.debit-l.credit ELSE 0 END ) AS "days_due_01to30",
392- SUM(CASE WHEN days_due BETWEEN 31 AND 60 THEN l.debit-l.credit ELSE 0 END ) AS "days_due_31to60",
393- SUM(CASE WHEN days_due BETWEEN 61 AND 90 THEN l.debit-l.credit ELSE 0 END ) AS "days_due_61to90",
394- SUM(CASE WHEN days_due BETWEEN 91 AND 120 THEN l.debit-l.credit ELSE 0 END ) AS "days_due_91to120",
395- SUM(CASE WHEN days_due >=121 THEN l.debit-l.credit ELSE 0 END ) AS "days_due_121togr",
396- --COALESCE( l.currency_id, res_company.currency_id) AS "currency_src_id",
397- --res_company.currency_id AS "currency_src_id",
398- res_company.currency_id AS "currency_company_id",
399- l.company_id
400- FROM account_move_line l
401- INNER JOIN
402- (--Subquery add days_due to account_move_line
403- SELECT id, EXTRACT(DAY FROM (now() - COALESCE(lt.date_maturity,lt.date))) AS days_due
404- FROM account_move_line lt
405- --WHERE --lt.state, si ya finalizo no tiene fecha de vencimiento
406- ) l2
407- ON l2.id = l.id
408-
409- INNER JOIN account_account
410- ON account_account.id = l.account_id
411- INNER JOIN res_company
412- ON account_account.company_id = res_company.id
413- INNER JOIN account_move
414- ON account_move.id = l.move_id
415- WHERE account_account.active
416- AND (account_account.type IN ('receivable'))
417- AND (l.reconcile_id IS NULL)
418- AND account_move.state = 'posted'
419- GROUP BY l.partner_id, l.company_id, res_company.currency_id--, l.currency_id
420- ) vw
421- WHERE total <> 0'''
422-
423- tools.drop_view_if_exists(cr, '%s' % (self._name.replace('.', '_')))
424- cr.execute("""CREATE OR REPLACE VIEW %s AS (
425- %s
426- )""" % ( self._name.replace('.', '_'), full_query ) )
427-account_aged_partner_balance_vw()
428+ 'currency_company_id':
429+ fields.many2one('res.currency', u'Company Currency'),
430+ 'aatb_id': fields.many2one('account.aged.trial.balance', ('Aged Trial '
431+ 'Balance'), help='Aged Trail Balance Document'),
432+ }
433+
434+
435+class account_aged_partner_document(osv.TransientModel):
436+ _name = 'account.aged.partner.document'
437+ _inherit = 'account.aged.partner.balance.vw'
438+ _rec_name = 'partner_id'
439+ _order = 'partner_id, due_days'
440+
441+ _columns = {
442+ 'user_id':
443+ fields.many2one('res.users', 'User', help="User's Document"),
444+ 'date_due': fields.date('Due Date', help='Due Date'),
445+ 'due_days': fields.integer(u'Due Days'),
446+ 'residual': fields.float(u'Residual'),
447+ 'aatb_id': fields.many2one('account.aged.trial.balance', ('Aged Trial '
448+ 'Balance'), help='Aged Trail Balance Document'),
449+ 'document_id': fields.reference('Document',
450+ [('account.invoice', 'Invoice'),
451+ ('account.voucher', 'Voucher'),
452+ ('account.move.line', 'Journal Entry Line')],
453+ size=128,
454+ required=False),
455+ }
456+
457+
458+class account_aged_trial_balance(osv.TransientModel):
459+ _inherit = 'account.aged.trial.balance'
460+
461+ _columns = {
462+ 'partner_doc_ids': fields.one2many('account.aged.partner.document',
463+ 'aatb_id', 'Partner Aged Trail Balance',
464+ help='Partner Aged Trail Balance'),
465+ 'partner_line_ids': fields.one2many('account.aged.partner.balance.vw',
466+ 'aatb_id', 'Partner Aged Trail Balance',
467+ help='Partner Aged Trail Balance'),
468+ 'type': fields.selection([('variation', 'Balance Variation in Periods'),
469+ ('distributed', 'Distributed Payments over Debts'),
470+ ('by_document', 'Documents spread in Periods'),
471+ ], 'Type of Report', help='Reporte Type'),
472+ 'state': fields.selection([('draft', 'New'), ('open', 'Open'), ('done', 'Done'),
473+ ], 'Status', help='Document State'),
474+ }
475+
476+ _defaults = {
477+ 'state': 'draft',
478+ 'type': 'variation',
479+ }
480+
481+ def to_start(self, cr, uid, ids, context=None):
482+ context = context or {}
483+ ids = isinstance(ids, (int, long)) and [ids] or ids
484+ wzd_brw = self.browse(cr, uid, ids[0], context=context)
485+ wzd_brw.write({'state': 'draft', 'partner_line_ids': [(6, 0, [])]})
486+ return {}
487+
488+ def aged_report(self, cr, uid, ids, context=None):
489+ context = context or {}
490+ ids = isinstance(ids, (int, long)) and [ids] or ids
491+ datas = {'ids': ids}
492+ wzd_brw = self.browse(cr, uid, ids[0], context=context)
493+ res = self.check_report(cr, uid, ids, context=context)
494+ data = res['datas']
495+ datas['form'] = data['form']
496+ return {
497+ 'type': 'ir.actions.report.xml',
498+ 'report_name': 'account_aged_partner_balance_report',
499+ 'datas': datas,
500+ }
501+
502+ def compute_lines(self, cr, uid, ids, context=None):
503+ context = context or {}
504+ ids = isinstance(ids, (int, long)) and [ids] or ids
505+ wzd_brw = self.browse(cr, uid, ids[0], context=context)
506+ wzd_brw.write({'state': 'open', 'partner_line_ids': [(6, 0, [])],
507+ 'partner_doc_ids': [(6, 0, [])]})
508+ res = self.check_report(cr, uid, ids, context=context)
509+
510+ data = res['datas']
511+ form = data['form']
512+ self.set_context(cr, uid, ids, data, context=context)
513+ if wzd_brw.type in ('variation', 'distributed'):
514+ res = self._get_lines(cr, uid, ids, form, context=context)
515+ res = map(lambda x: (0, 0, x), res)
516+ wzd_brw.write({'partner_line_ids': res})
517+ elif wzd_brw.type == 'by_document':
518+ res = self._get_doc_lines(cr, uid, ids, form, context=context)
519+ res = map(lambda x: (0, 0, x), res)
520+ wzd_brw.write({'partner_doc_ids': res})
521+ return {}
522+
523+ def set_context(self, cr, uid, ids, data, context=None):
524+ context = context or {}
525+ self.total_account = []
526+ obj_move = self.pool.get('account.move.line')
527+ context = data['form'].get('used_context', {})
528+ context.update({'fiscalyear': False, 'all_fiscalyear': True})
529+ self.query = obj_move._query_get(cr, uid, obj='l', context=context)
530+ self.direction_selection = data[
531+ 'form'].get('direction_selection', 'past')
532+ self.target_move = data['form'].get('target_move', 'all')
533+ self.date_from = data['form'].get(
534+ 'date_from',
535+ time.strftime('%Y-%m-%d'))
536+ if (data['form']['result_selection'] == 'customer'):
537+ self.ACCOUNT_TYPE = ['receivable']
538+ elif (data['form']['result_selection'] == 'supplier'):
539+ self.ACCOUNT_TYPE = ['payable']
540+ else:
541+ self.ACCOUNT_TYPE = ['payable', 'receivable']
542+
543+ def _get_partners(self, cr, uid, ids, form, context=None):
544+ context = context or {}
545+ res = []
546+ wzd_brw = self.browse(cr, uid, ids[0], context=context)
547+ move_state = ['draft', 'posted']
548+ if self.target_move == 'posted':
549+ move_state = ['posted']
550+ cr.execute('SELECT DISTINCT res_partner.id AS id,\
551+ res_partner.name AS name \
552+ FROM res_partner,account_move_line AS l, account_account, account_move am\
553+ WHERE (l.account_id=account_account.id) \
554+ AND (l.move_id=am.id) \
555+ AND (am.state IN %s)\
556+ AND (account_account.type IN %s)\
557+ AND account_account.active\
558+ AND ((reconcile_id IS NULL)\
559+ OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))\
560+ AND (l.partner_id=res_partner.id)\
561+ AND (l.date <= %s)\
562+ AND ' + self.query + ' \
563+ ORDER BY res_partner.name', (tuple(move_state), tuple(self.ACCOUNT_TYPE), self.date_from, self.date_from,))
564+ return cr.dictfetchall()
565+
566+ def _get_lines(self, cr, uid, ids, form, context=None):
567+ context = context or {}
568+ res = []
569+ wzd_brw = self.browse(cr, uid, ids[0], context=context)
570+ move_state = ['draft', 'posted']
571+ if self.target_move == 'posted':
572+ move_state = ['posted']
573+ partners = self._get_partners(cr, uid, ids, form, context=context)
574+ # mise a 0 du total
575+ for i in range(7):
576+ self.total_account.append(0)
577+ #
578+ # Build a string like (1,2,3) for easy use in SQL query
579+ partner_ids = [x['id'] for x in partners]
580+ if not partner_ids:
581+ return []
582+ # This dictionary will store the debit-credit for all partners, using
583+ # partner_id as key.
584+
585+ type_query = ''
586+ type_query_r = ''
587+ if wzd_brw.type == 'distributed':
588+ if wzd_brw.result_selection == 'customer':
589+ type_query = ', SUM(l.credit)'
590+ type_query_r = ', SUM(l.debit)'
591+ elif wzd_brw.result_selection == 'supplier':
592+ type_query = ', SUM(l.debit)'
593+ type_query_r = ', SUM(l.credit)'
594+
595+ advances = {}
596+
597+ totals = {}
598+ cr.execute('SELECT l.partner_id, SUM(l.debit-l.credit) \
599+ ' + type_query + '\
600+ FROM account_move_line AS l, account_account, account_move am \
601+ WHERE (l.account_id = account_account.id) AND (l.move_id=am.id) \
602+ AND (am.state IN %s)\
603+ AND (account_account.type IN %s)\
604+ AND (l.partner_id IN %s)\
605+ AND ((l.reconcile_id IS NULL)\
606+ OR (l.reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))\
607+ AND ' + self.query + '\
608+ AND account_account.active\
609+ AND (l.date <= %s)\
610+ GROUP BY l.partner_id ', (tuple(move_state), tuple(self.ACCOUNT_TYPE), tuple(partner_ids), self.date_from, self.date_from,))
611+ t = cr.fetchall()
612+ for i in t:
613+ totals[i[0]] = i[1]
614+ if wzd_brw.type == 'distributed':
615+ if wzd_brw.result_selection in ('customer', 'supplier'):
616+ advances[i[0]] = i[2]
617+
618+ # This dictionary will store the future or past of all partners
619+ future_past = {}
620+ if self.direction_selection == 'future':
621+ cr.execute('SELECT l.partner_id, SUM(l.debit-l.credit) \
622+ FROM account_move_line AS l, account_account, account_move am \
623+ WHERE (l.account_id=account_account.id) AND (l.move_id=am.id) \
624+ AND (am.state IN %s)\
625+ AND (account_account.type IN %s)\
626+ AND (COALESCE(l.date_maturity, l.date) < %s)\
627+ AND (l.partner_id IN %s)\
628+ AND ((l.reconcile_id IS NULL)\
629+ OR (l.reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))\
630+ AND ' + self.query + '\
631+ AND account_account.active\
632+ AND (l.date <= %s)\
633+ GROUP BY l.partner_id', (tuple(move_state), tuple(self.ACCOUNT_TYPE), self.date_from, tuple(partner_ids), self.date_from, self.date_from,))
634+ t = cr.fetchall()
635+ for i in t:
636+ future_past[i[0]] = i[1]
637+ # Using elif so people could extend without this breaking
638+ elif self.direction_selection == 'past':
639+ cr.execute('SELECT l.partner_id, SUM(l.debit-l.credit) \
640+ ' + type_query_r + '\
641+ FROM account_move_line AS l, account_account, account_move am \
642+ WHERE (l.account_id=account_account.id) AND (l.move_id=am.id)\
643+ AND (am.state IN %s)\
644+ AND (account_account.type IN %s)\
645+ AND (COALESCE(l.date_maturity,l.date) > %s)\
646+ AND (l.partner_id IN %s)\
647+ AND ((l.reconcile_id IS NULL)\
648+ OR (l.reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))\
649+ AND ' + self.query + '\
650+ AND account_account.active\
651+ AND (l.date <= %s)\
652+ GROUP BY l.partner_id', (tuple(move_state), tuple(self.ACCOUNT_TYPE), self.date_from, tuple(partner_ids), self.date_from, self.date_from,))
653+ t = cr.fetchall()
654+ if wzd_brw.type == 'distributed':
655+ if wzd_brw.result_selection in ('customer', 'supplier'):
656+ for i in t:
657+ future_past[i[0]] = wzd_brw.result_selection == 'customer' \
658+ and i[2] or -(i[2])
659+ else:
660+ for i in t:
661+ future_past[i[0]] = i[1]
662+ else:
663+ for i in t:
664+ future_past[i[0]] = i[1]
665+
666+ # Use one query per period and store results in history (a list variable)
667+ # Each history will contain: history[1] = {'<partner_id>':
668+ # <partner_debit-credit>}
669+ history = []
670+ for i in range(5):
671+ args_list = (
672+ tuple(move_state),
673+ tuple(self.ACCOUNT_TYPE),
674+ tuple(partner_ids),
675+ self.date_from,
676+ )
677+ dates_query = '(COALESCE(l.date_maturity,l.date)'
678+ if form[str(i)]['start'] and form[str(i)]['stop']:
679+ dates_query += ' BETWEEN %s AND %s)'
680+ args_list += (form[str(i)]['start'], form[str(i)]['stop'])
681+ elif form[str(i)]['start']:
682+ dates_query += ' > %s)'
683+ args_list += (form[str(i)]['start'],)
684+ else:
685+ dates_query += ' < %s)'
686+ args_list += (form[str(i)]['stop'],)
687+ args_list += (self.date_from,)
688+ cr.execute('''SELECT l.partner_id, SUM(l.debit-l.credit)
689+ ''' + type_query_r + '''
690+ FROM account_move_line AS l, account_account, account_move am
691+ WHERE (l.account_id = account_account.id) AND (l.move_id=am.id)
692+ AND (am.state IN %s)
693+ AND (account_account.type IN %s)
694+ AND (l.partner_id IN %s)
695+ AND ((l.reconcile_id IS NULL)
696+ OR (l.reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))
697+ AND ''' + self.query + '''
698+ AND account_account.active
699+ AND ''' + dates_query + '''
700+ AND (l.date <= %s)
701+ GROUP BY l.partner_id''', args_list)
702+ t = cr.fetchall()
703+ d = {}
704+ if wzd_brw.type == 'distributed':
705+ if wzd_brw.result_selection in ('customer', 'supplier'):
706+ for i in t:
707+ if advances[i[0]] >= i[2]:
708+ d[i[0]] = 0.0
709+ advances[i[0]] -= i[2]
710+ elif advances[i[0]] < i[2] and advances[i[0]]:
711+ d[i[0]] = wzd_brw.result_selection == 'customer' \
712+ and i[2] - advances[i[0]] or \
713+ -(i[2] - advances[i[0]])
714+ advances[i[0]] = 0.0
715+ else:
716+ d[i[0]] = wzd_brw.result_selection == 'customer' \
717+ and i[2] or -(i[2])
718+ else:
719+ for i in t:
720+ d[i[0]] = i[1]
721+ else:
722+ for i in t:
723+ d[i[0]] = i[1]
724+ history.append(d)
725+
726+ for partner in partners:
727+ values = {}
728+ # If choise selection is in the future
729+ if self.direction_selection == 'future':
730+ # Query here is replaced by one query which gets the all the
731+ # partners their 'before' value
732+ before = False
733+ if partner['id'] in future_past:
734+ before = [future_past[partner['id']]]
735+ self.total_account[6] = self.total_account[
736+ 6] + (before and before[0] or 0.0)
737+ values['direction'] = before and before[0] or 0.0
738+ # Changed this so people could in the future create new
739+ # direction_selections
740+ elif self.direction_selection == 'past':
741+ # Query here is replaced by one query which gets the all the
742+ # partners their 'after' value
743+ after = False
744+ # Making sure this partner actually was found by the query
745+ if partner['id'] in future_past:
746+ after = [future_past[partner['id']]]
747+
748+ self.total_account[6] = self.total_account[
749+ 6] + (after and after[0] or 0.0)
750+ if wzd_brw.type == 'distributed':
751+ if wzd_brw.result_selection in ('customer', 'supplier') and advances.get(partner['id'], 0.0):
752+ if advances.get(partner['id'], 0.0) >= (after and after[0] or 0.0):
753+ values['direction'] = 0.0
754+ advances[partner['id']] -= after and after[
755+ 0] or 0.0
756+ elif advances.get(partner['id'], 0.0) < (after and after[0] or 0.0) and advances.get(partner['id'], 0.0):
757+ values['direction'] = wzd_brw.result_selection == 'customer' \
758+ and after and after[0] - advances[partner['id']] or \
759+ - \
760+ (after and after[
761+ 0] - advances[partner['id']])
762+ advances[partner['id']] = 0.0
763+ else:
764+ values['direction'] = wzd_brw.result_selection == 'customer' \
765+ and after and after[0] or 0.0 or -(after and after[0] or 0.0)
766+ else:
767+ values['direction'] = after and after[0] or 0.0
768+ else:
769+ values['direction'] = after and after[0] or 0.0
770+
771+ for i in range(5):
772+ during = False
773+ if partner['id'] in history[i]:
774+ during = [history[i][partner['id']]]
775+ # Ajout du compteur
776+ self.total_account[(i)] = self.total_account[
777+ (i)] + (during and during[0] or 0)
778+ values[str(i)] = during and during[0] or 0.0
779+ total = False
780+ if partner['id'] in totals:
781+ total = [totals[partner['id']]]
782+ values['total'] = total and total[0] or 0.0
783+ # Add for total
784+ self.total_account[(i + 1)] = self.total_account[
785+ (i + 1)] + (total and total[0] or 0.0)
786+ values['name'] = partner['name']
787+ values['partner_id'] = partner['id']
788+
789+ res.append(values)
790+
791+ total = 0.0
792+ totals = {}
793+ for r in res:
794+ total += float(r['total'] or 0.0)
795+ for i in range(5) + ['direction']:
796+ totals.setdefault(str(i), 0.0)
797+ totals[str(i)] += float(r[str(i)] or 0.0)
798+ mapping = {
799+ 'direction': 'not_due',
800+ '4': 'days_due_01to30',
801+ '3': 'days_due_31to60',
802+ '2': 'days_due_61to90',
803+ '1': 'days_due_91to120',
804+ '0': 'days_due_121togr',
805+ }
806+ res2 = []
807+ for r in res:
808+ for j, k in mapping.iteritems():
809+ r[k] = r.pop(j)
810+ r.pop('name')
811+ res2.append(r)
812+ return res2
813+
814+ def _get_doc_lines(self, cr, uid, ids, form, context=None):
815+ context = context or {}
816+ res = []
817+ wzd_brw = self.browse(cr, uid, ids[0], context=context)
818+ partners = self._get_partners(cr, uid, ids, form, context=context)
819+ partner_ids = [x['id'] for x in partners]
820+ if not partner_ids:
821+ return []
822+ res = self._get_invoice_by_partner(cr, uid, ids, partner_ids)
823+ res2 = self._get_lines_by_partner_without_invoice(
824+ cr, uid, ids, partner_ids)
825+ res += res2
826+ res = self._screening_invoices(cr, uid, ids, form, res)
827+ return res
828+
829+ def _screening_invoices(self, cr, uid, ids, form, res, context=None):
830+ context = context or {}
831+ res2 = []
832+ if not res:
833+ return []
834+ for r in res:
835+ if form['0']['stop'] >= r['date_due']:
836+ r['days_due_121togr'] = r['residual']
837+ elif form['1']['start'] <= r['date_due'] and form['1']['stop'] >= r['date_due']:
838+ r['days_due_91to120'] = r['residual']
839+ elif form['2']['start'] <= r['date_due'] and form['2']['stop'] >= r['date_due']:
840+ r['days_due_61to90'] = r['residual']
841+ elif form['3']['start'] <= r['date_due'] and form['3']['stop'] >= r['date_due']:
842+ r['days_due_31to60'] = r['residual']
843+ elif form['4']['start'] <= r['date_due'] and form['4']['stop'] >= r['date_due']:
844+ r['days_due_01to30'] = r['residual']
845+ else:
846+ r['not_due'] = r['residual']
847+ res2.append(r)
848+ return res2
849+
850+ def _get_invoice_by_partner(self, cr, uid, ids, rp_ids, context=None):
851+ res = []
852+ context = context or {}
853+ wzd_brw = self.browse(cr, uid, ids[0], context=context)
854+ rp_obj = self.pool.get('res.partner')
855+ inv_obj = self.pool.get('account.invoice')
856+ args = [
857+ ('residual', '!=', 0),
858+ ('state', 'not in', ('cancel', 'draft'))]
859+
860+ if wzd_brw.result_selection == 'customer':
861+ args += [('type', '=', 'out_invoice')]
862+ elif wzd_brw.result_selection == 'supplier':
863+ args += [('type', '=', 'in_invoice')]
864+ else:
865+ return []
866+
867+ rp_brws = rp_obj.browse(cr, uid, rp_ids, context=context)
868+
869+ for rp_brw in rp_brws:
870+ inv_ids = inv_obj.search(
871+ cr, uid, [('partner_id', '=', rp_brw.id)] + args)
872+ if not inv_ids:
873+ continue
874+ for inv_brw in inv_obj.browse(cr, uid, inv_ids):
875+ residual = inv_brw.residual
876+ date_due = mx.DateTime.strptime(
877+ inv_brw.date_due or inv_brw.date_invoice, '%Y-%m-%d')
878+ today = mx.DateTime.strptime(wzd_brw.date_from, '%Y-%m-%d')
879+ due_days = (today - date_due).day
880+
881+ if not residual:
882+ continue
883+
884+ res.append({
885+ 'partner_id': rp_brw.id,
886+ 'user_id': inv_brw.user_id and inv_brw.user_id.id or False,
887+ 'document_id': '%s,%s' % (inv_brw._name, inv_brw.id),
888+ 'residual': residual,
889+ 'due_days': due_days,
890+ 'date_due': inv_brw.date_due or inv_brw.date_invoice,
891+ })
892+ return res
893+
894+ def _get_lines_by_partner_without_invoice(
895+ self, cr, uid, ids, rp_ids, context=None):
896+ res = []
897+ context = context or {}
898+ wzd_brw = self.browse(cr, uid, ids[0], context=context)
899+ acc_move_line = self.pool.get('account.move.line')
900+ inv_obj = self.pool.get('account.invoice')
901+ acc_journal_obj = self.pool.get('account.journal')
902+ company_id = self.pool.get('res.company')._company_default_get(cr, uid,
903+ 'account.diot.report', context=context)
904+ moves_invoice_ids = []
905+ inv_company = inv_obj.search(
906+ cr, uid, [('company_id', '=', company_id)], context=context)
907+ for invoice in inv_obj.browse(cr, uid, inv_company, context=context):
908+ if invoice.move_id:
909+ moves_invoice_ids.append(invoice.move_id.id)
910+ journal_comp = acc_journal_obj.search(
911+ cr, uid, [('company_id', '=', company_id),
912+ ('type', 'in', ['bank', 'cash'])], context=context)
913+ accounts_journal = []
914+ for journal in acc_journal_obj.browse(cr, uid, journal_comp, context=context):
915+ if journal.default_debit_account_id:
916+ accounts_journal.append(journal.default_debit_account_id.id)
917+ if journal.default_credit_account_id:
918+ accounts_journal.append(journal.default_credit_account_id.id)
919+ accounts_journal = list(set(accounts_journal))
920+ args = [
921+ ('reconcile_partial_id', '=', False),
922+ ('reconcile_id', '=', False),
923+ ('move_id', 'not in', moves_invoice_ids),
924+ ('company_id', '=', company_id),
925+ ('account_id', 'in', accounts_journal),
926+ ('partner_id', '!=', False)
927+ ]
928+ if wzd_brw.direction_selection == 'past':
929+ args += [('date', '<=', wzd_brw.date_from)]
930+ elif wzd_brw.direction_selection == 'future':
931+ args += [('date', '>=', wzd_brw.date_from)]
932+ if wzd_brw.result_selection == 'customer':
933+ args += [('credit', '!=', 0)]
934+ elif wzd_brw.result_selection == 'supplier':
935+ args += [('debit', '!=', 0)]
936+ else:
937+ return []
938+ move_lines_ret = acc_move_line.search(cr, uid, args, context=context)
939+ today = mx.DateTime.strptime(wzd_brw.date_from, '%Y-%m-%d')
940+ for line in acc_move_line.browse(cr, uid, move_lines_ret, context=context):
941+ date_due = mx.DateTime.strptime(line.date, '%Y-%m-%d')
942+ due_days = (today - date_due).day
943+ residual = line.credit or line.debit or False
944+ res.append({
945+ 'partner_id': line.partner_id and line.partner_id.id or False,
946+ 'user_id': False,
947+ 'document_id': '%s,%s' % (line._name, line.id),
948+ 'residual': residual * -1,
949+ 'due_days': due_days,
950+ 'date_due': line.date,
951+ })
952+ return res
953
954=== added directory 'account_aged_partner_balance_vw/report'
955=== added file 'account_aged_partner_balance_vw/report/account_aged_partner_balance.mako'
956--- account_aged_partner_balance_vw/report/account_aged_partner_balance.mako 1970-01-01 00:00:00 +0000
957+++ account_aged_partner_balance_vw/report/account_aged_partner_balance.mako 2013-10-03 16:40:09 +0000
958@@ -0,0 +1,244 @@
959+<html>
960+ <head>
961+ <style type="text/css">
962+ ${css}
963+ </style>
964+ </head>
965+ <body style="border:0; margin: 0;" onload="subst()" >
966+ %for obj in objects :
967+ <table>
968+ <tr>
969+ <td width="10%">
970+ <div>${helper.embed_image('jpeg',str(obj.company_id.logo),220, 100)}</div>
971+ </td>
972+ <td>
973+ <table style="width: 100%; text-align:center;">
974+ <tr>
975+ <th class="celdaTituloTabla" style="text-align:center;" width="10%">${_('Chart of Accounts')}</th>
976+ <th class="celdaTituloTabla" style="text-align:center;" width="10%">${_('Fiscal Year')}</th>
977+ <th class="celdaTituloTabla" style="text-align:center;" width="10%">${_('Start Date')}</th>
978+ <th class="celdaTituloTabla" style="text-align:center;" width="10%">${_('Period Length(days)')}</th>
979+ <th class="celdaTituloTabla" style="text-align:center;" width="10%">${_('Partners ')}</th>
980+ <th class="celdaTituloTabla" style="text-align:center;" width="10%">${_('Analysis Direction')}</th>
981+ <th class="celdaTituloTabla" style="text-align:center;" width="10%">${_('Target Moves')}</th>
982+ </tr>
983+ <tr>
984+ <th class="celdaBoxUp" style="text-align:center;" width="10%">${obj.chart_account_id.name or ''|entity}</th>
985+ <th class="celdaBoxUp" style="text-align:center;" width="10%">${obj.fiscalyear_id.name or ''|entity}</th>
986+ <th class="celdaBoxUp" style="text-align:center;" width="10%">${obj.date_from or ''|entity}</th>
987+ <th class="celdaBoxUp" style="text-align:center;" width="10%">${obj.period_length or ''|entity}</th>
988+
989+ %if obj.result_selection == 'customer':
990+ <th class="celdaBoxUp" style="text-align:center;" width="10%">${_('Receivable Accounts')}</th>
991+ %elif obj.result_selection == 'supplier':
992+ <th class="celdaBoxUp" style="text-align:center;" width="10%">${_('Payable Accounts')}</th>
993+ %elif obj.result_selection == 'customer_suppiler':
994+ <th class="celdaBoxUp" style="text-align:center;" width="10%">${_('Receivable and Payable Accounts')}</th>
995+ %endif
996+ %if obj.direction_selection == 'past':
997+ <th class="celdaBoxUp" style="text-align:center;" width="10%">${_('Past')}</th>
998+ %elif obj.direction_selection == 'future':
999+ <th class="celdaBoxUp" style="text-align:center;" width="10%">${_('Future')}</th>
1000+ %endif
1001+ %if obj.target_move == 'posted':
1002+ <th class="celdaBoxUp" style="text-align:center;" width="10%">${_('All Posted Entries')}</th>
1003+ %elif obj.target_move == 'all':
1004+ <th class="celdaBoxUp" style="text-align:center;" width="10%">${_('All Entries')}</th>
1005+ %endif
1006+ </tr>
1007+ </table>
1008+ </td>
1009+ </tr>
1010+ </table>
1011+ <br clear="all"/>
1012+
1013+ <table class="list_table" width="100%" border="0">
1014+ <thead>
1015+ <tr>
1016+ <th class="celdaTituloTablaCompany" width="100%">${obj.company_id.name or ''|entity} (Expressed in ${obj.company_id.currency_id.name |entity} )</th>
1017+ </tr>
1018+ </thead>
1019+ </table>
1020+ %if obj.type != "by_document":
1021+ <table class="list_table" width="100%" border="0">
1022+ <thead>
1023+ <tr>
1024+ <th class="celdaTituloTabla" style="text-align:center;" width="30%">${_('Partners')}</th>
1025+ <th class="celdaTituloTabla" style="text-align:center;" width="10%">${_('Not due')}</th>
1026+ <% form = data['form']%>
1027+ %for i in range (4,-1,-1):
1028+ <th class="celdaTituloTabla" style="text-align:center;">${form.get('%i'%i).get('name')}</th>
1029+ %endfor
1030+ <th class="celdaTituloTabla" style="text-align:center;">${_('Total')}</th>
1031+ </tr>
1032+ </thead>
1033+
1034+ <tbody>
1035+ %for line in obj.partner_line_ids:
1036+ <tr class="prueba" >
1037+ <td class="celdaLineDataTitulo" width="30%">
1038+ ${line.partner_id.name.upper()}
1039+ </td>
1040+ <td class="celdaLineData" width="10%">
1041+ ${line.not_due}
1042+ </td>
1043+ <td class="celdaLineData" width="10%">
1044+ ${line.days_due_01to30}
1045+ </td>
1046+ <td class="celdaLineData" width="10%">
1047+ ${line.days_due_31to60}
1048+ </td>
1049+ <td class="celdaLineData" width="10%">
1050+ ${line.days_due_61to90}
1051+ </td>
1052+ <td class="celdaLineData" width="10%">
1053+ ${line.days_due_91to120}
1054+ </td>
1055+ <td class="celdaLineData" width="10%">
1056+ ${line.days_due_121togr}
1057+ </td>
1058+ <td class="celdaTotal" width="10%">
1059+ ${line.total}
1060+ </td>
1061+ </tr>
1062+ %endfor
1063+
1064+ <!--
1065+ Aquí va la celda de los totales la vemos si la ponemos con un ciclo por lo pronto te dejo
1066+ El esqueleto de esos campos
1067+ -->
1068+ <tr>
1069+ %for i in range(1,9):
1070+ <td class="celdaTotalTotales" >${_('$')}
1071+ </td>
1072+ %endfor
1073+ </tr>
1074+ </tbody>
1075+ </table>
1076+ %endif
1077+ <%
1078+ def get_dict_lines_by_partner(lines):
1079+ dic_partner_lines = {}
1080+ for line in lines:
1081+ if line.partner_id.id:
1082+ if line.partner_id.name in dic_partner_lines:
1083+ dic_partner_lines.get(line.partner_id.name).append(line)
1084+ else:
1085+ dic_partner_lines.update({line.partner_id.vat_split and line.partner_id.vat_split + ' - ' + line.partner_id.name or line.partner_id.name : [line]})
1086+ return dic_partner_lines
1087+ %>
1088+ %if obj.type == "by_document":
1089+ %for partner in get_dict_lines_by_partner(obj.partner_doc_ids):
1090+ <table class="list_table" width="100%" border="0">
1091+ <thead>
1092+ <tr>
1093+ <th class="celdaTituloPartner" style="text-align:left;" width="10%">${partner}</th>
1094+ </tr>
1095+ </thead>
1096+ </table>
1097+ <table class="list_table" width="100%" border="0">
1098+ <thead>
1099+ <tr>
1100+ <th class="celdaTituloTabla" style="text-align:left;" width="20%">${_('Document')}</th>
1101+ <th class="celdaTituloTabla" style="text-align:left;" width="10%">${_('Type')}</th>
1102+ <th class="celdaTituloTabla" style="text-align:left;" width="10%">${_('Due Days')}</th>
1103+ <th class="celdaTituloTabla" style="text-align:left;" width="10%">${_('Residual')}</th>
1104+ <% form = data['form']%>
1105+ %for i in range (4,-1,-1):
1106+ <th class="celdaTituloTabla" style="text-align:center;">${form.get('%i'%i).get('name')}</th>
1107+ %endfor
1108+ </tr>
1109+ </thead>
1110+
1111+ <tbody>
1112+ <%lines_partner = get_dict_lines_by_partner(obj.partner_doc_ids).get(partner, False)%>
1113+ <%
1114+ to0130 = 0
1115+ to3160 = 0
1116+ to6190 = 0
1117+ to91120 = 0
1118+ to121 = 0
1119+ residual = 0%>
1120+ %for line in lines_partner:
1121+ <%
1122+ type = ''
1123+ document = ''
1124+ if line.document_id._name == 'account.invoice':
1125+ document = line.document_id.number
1126+ type = 'Invoice'
1127+ elif line.document_id._name == 'account.voucher':
1128+ type = 'Voucher'
1129+ document = line.document_id.number
1130+ elif line.document_id._name == 'account.move.line':
1131+ type = 'Journal Entry Line'
1132+ document = line.document_id.name
1133+ to0130 += line.days_due_01to30
1134+ to3160 += line.days_due_31to60
1135+ to6190 += line.days_due_61to90
1136+ to91120 += line.days_due_91to120
1137+ to121 += line.days_due_121togr
1138+ residual += line.residual
1139+ %>
1140+ <tr class="prueba" >
1141+ <td class="celdaLineDataTitulo" width="20%">
1142+ ${document}
1143+ </td>
1144+ <td class="celdaLineData" width="10%">
1145+ ${type}
1146+ </td>
1147+ <td class="celdaLineData" style="text-align:center;" width="10%">
1148+ ${line.due_days}
1149+ </td>
1150+ <td class="celdaLineData" width="10%">
1151+ ${line.residual}
1152+ </td>
1153+ <td class="celdaLineData" width="10%">
1154+ ${line.days_due_01to30}
1155+ </td>
1156+ <td class="celdaLineData" width="10%">
1157+ ${line.days_due_31to60}
1158+ </td>
1159+ <td class="celdaLineData" width="10%">
1160+ ${line.days_due_61to90}
1161+ </td>
1162+ <td class="celdaLineData" width="10%">
1163+ ${line.days_due_91to120}
1164+ </td>
1165+ <td class="celdaLineData" width="10%">
1166+ ${line.days_due_121togr}
1167+ </td>
1168+ </tr>
1169+ %endfor
1170+ <tr>
1171+ <td class="celdaTotalTotales" width="20%">
1172+ ${_('Total')}
1173+ </td>
1174+ <td class="celdaTotalTotales" width="10%">
1175+ </td>
1176+ <td class="celdaTotalTotales" width="10%"></td>
1177+ <td class="celdaTotalTotales" width="10%">
1178+ ${formatLang(residual, digits=2, grouping=True)}
1179+ </td>
1180+ <td class="celdaTotalTotales" width="10%">
1181+ ${formatLang(to0130, digits=2, grouping=True)}
1182+ </td>
1183+ <td class="celdaTotalTotales" width="10%">
1184+ ${formatLang(to3160, digits=2, grouping=True)}
1185+ </td>
1186+ <td class="celdaTotalTotales" width="10%">
1187+ ${formatLang(to6190, digits=2, grouping=True)}
1188+ </td>
1189+ <td class="celdaTotalTotales" width="10%">
1190+ ${formatLang(to91120, digits=2, grouping=True)}
1191+ </td>
1192+ <td class="celdaTotalTotales" width="10%">
1193+ ${formatLang(to121, digits=2, grouping=True)}
1194+ </td>
1195+ </tr>
1196+ </tbody>
1197+ </table>
1198+ %endfor
1199+ %endif
1200+ %endfor
1201+ </body>
1202+</html>
1203
1204=== added file 'account_aged_partner_balance_vw/report/report.xml'
1205--- account_aged_partner_balance_vw/report/report.xml 1970-01-01 00:00:00 +0000
1206+++ account_aged_partner_balance_vw/report/report.xml 2013-10-03 16:40:09 +0000
1207@@ -0,0 +1,23 @@
1208+<?xml version="1.0"?>
1209+<openerp>
1210+ <data>
1211+ <report
1212+ auto = "True"
1213+ id="account_aged_partner_balance_report"
1214+ model="account.aged.trial.balance"
1215+ name="account_aged_partner_balance_report"
1216+ file="account_aged_partner_balance_vw/report/account_aged_partner_balance.mako"
1217+ string="Aged Partner Balance"
1218+ report_type="webkit"
1219+ multi="True"
1220+ />
1221+
1222+ <record id="property_aged_partner_report_webkit" model="ir.property">
1223+ <field name="name">webkit_header</field>
1224+ <field name="fields_id" ref="report_webkit.field_ir_act_report_xml_webkit_header"/>
1225+ <field eval="'ir.header_webkit,'+str(ref('account_aged_partner_balance_vw.ir_header_webkit_account_aged_partner_balance_report'))" model="ir.header_webkit" name="value"/>
1226+ <field eval="'ir.actions.report.xml,'+str(ref('account_aged_partner_balance_vw.account_aged_partner_balance_report'))" model="ir.actions.report.xml" name="res_id"/>
1227+ </record>
1228+
1229+ </data>
1230+</openerp>
1231
1232=== added directory 'account_aged_partner_balance_vw/view'
1233=== renamed file 'account_aged_partner_balance_vw/board_account_view.xml' => 'account_aged_partner_balance_vw/view/action_menues.xml'
1234--- account_aged_partner_balance_vw/board_account_view.xml 2013-04-19 21:05:23 +0000
1235+++ account_aged_partner_balance_vw/view/action_menues.xml 2013-10-03 16:40:09 +0000
1236@@ -1,7 +1,6 @@
1237 <?xml version='1.0' encoding='utf-8'?>
1238 <openerp>
1239 <data>
1240-
1241 <record id="action_expense_report_tree" model="ir.actions.act_window">
1242 <field name="name">Expense Company</field>
1243 <field name="res_model">account.aged.partner.balance.vw</field>
1244@@ -10,17 +9,26 @@
1245 <field name="view_id" ref="account_aged_partner_balance_vw.view_account_aged_partner_balance_vw_tree"/>
1246 </record>
1247
1248-
1249- <record id="board_account_form_inherit" model="ir.ui.view">
1250- <field name="name">board.account.form</field>
1251- <field name="model">board.board</field>
1252- <field name="inherit_id" ref="account.board_account_form"/>
1253- <field name="arch" type="xml">
1254- <xpath expr="/form/board/column/action[@string='Draft Customer Invoices']" position="before">
1255- <action name="%(action_expense_report_tree)d" string="Purchase Order Waiting Approval"/>
1256- </xpath>
1257-
1258- </field>
1259- </record>
1260+ <record id="action_account_aged_partner_balance_vw" model="ir.actions.act_window">
1261+ <field name="name">Aged Partner Balance View</field>
1262+ <field name="res_model">account.aged.partner.balance.vw</field>
1263+ <field name="view_type">form</field>
1264+ <field name="view_id" ref="view_account_aged_partner_balance_vw_tree"/>
1265+ <field name="view_mode">tree</field>
1266+ <!--<field name="context">{'search_default_posted': 0}</field>-->
1267+ <!--<field name="search_view_id" ref="account.view_account_move_line_filter"/>-->
1268+ <field name="help"/>
1269+ </record>
1270+
1271+ <record id="account.action_account_aged_balance_view" model="ir.actions.act_window">
1272+ <field name="target">inline</field>
1273+ </record>
1274+
1275+ <menuitem
1276+ action="action_account_aged_partner_balance_vw"
1277+ id="menu_action_account_aged_partner_balance_vw"
1278+ parent="account.menu_finance_legal_statement"
1279+ sequence="100"
1280+ />
1281 </data>
1282-</openerp>
1283\ No newline at end of file
1284+</openerp>
1285
1286=== renamed file 'account_aged_partner_balance_vw/account_aged_partner_balance_vw_view.xml' => 'account_aged_partner_balance_vw/view/view.xml'
1287--- account_aged_partner_balance_vw/account_aged_partner_balance_vw_view.xml 2013-04-19 21:05:23 +0000
1288+++ account_aged_partner_balance_vw/view/view.xml 2013-10-03 16:40:09 +0000
1289@@ -1,6 +1,71 @@
1290 <?xml version='1.0' encoding='utf-8'?>
1291 <openerp>
1292 <data>
1293+ <!-- <record id="board_account_form_inherit" model="ir.ui.view">
1294+ <field name="name">board.account.form</field>
1295+ <field name="model">board.board</field>
1296+ <field name="inherit_id" ref="account.board_account_form"/>
1297+ <field name="arch" type="xml">
1298+ <xpath expr="/form/board/column/action[@string='Draft Customer Invoices']" position="before">
1299+ <action name="%(action_expense_report_tree)d" string="Purchase Order Waiting Approval"/>
1300+ </xpath>
1301+
1302+ </field>
1303+ </record>-->
1304+
1305+ <record id="account_aged_balance_view" model="ir.ui.view">
1306+ <field name="name">Aged Partner Balance</field>
1307+ <field name="model">account.aged.trial.balance</field>
1308+ <field name="inherit_id" ref="account.account_aged_balance_view" />
1309+ <field name="arch" type="xml">
1310+ <xpath expr='//footer' position='replace'>
1311+ </xpath>
1312+ <xpath expr='//separator[@string="Aged Partner Balance"]' position='before'>
1313+ <header>
1314+ <button name="check_report" string="Print" type="object" default_focus="1" class="oe_highlight"/>
1315+ <button
1316+ name="compute_lines"
1317+ string="Compute"
1318+ type="object"
1319+ default_focus="0"
1320+ states="draft,open"
1321+ class="oe_highlight"/>
1322+ <button
1323+ name="aged_report"
1324+ string="Aged Report"
1325+ type="object"
1326+ default_focus="0"
1327+ states="draft,open"
1328+ class="oe_highlight"/>
1329+ <button
1330+ name="to_start"
1331+ string="Back to Start"
1332+ type="object"
1333+ default_focus="0"
1334+ states="open"
1335+ class="oe_highlight"/>
1336+ <field name="state"
1337+ widget="statusbar"
1338+ statusbar_visible="draft,open,done"
1339+ />
1340+ </header>
1341+ </xpath>
1342+ <xpath expr='//field[@name="direction_selection"]' position='after'>
1343+ <field name='type' required='1'/>
1344+ <field name='target_move' required='1'/>
1345+ </xpath>
1346+ <xpath expr='//field[@name="journal_ids"]' position='after'>
1347+ <field
1348+ name='partner_line_ids'
1349+ nolabel='1'
1350+ attrs="{'invisible':[('type','=','by_document')]}"/>
1351+ <field
1352+ name='partner_doc_ids'
1353+ nolabel='1'
1354+ attrs="{'invisible':[('type','!=','by_document')]}"/>
1355+ </xpath>
1356+ </field>
1357+ </record>
1358
1359 <record model="ir.ui.view" id="view_account_aged_partner_balance_vw_tree">
1360 <field name="name">view.account.aged.partner.balance.vw.tree</field>
1361@@ -8,39 +73,46 @@
1362 <field name="arch" type="xml">
1363 <tree string="Aged Partner Balance View">
1364 <field name="partner_id"/>
1365- <field name="total" sum="Total"/>
1366- <button name="%(wizard_open_move_line)d" string="Total Open Moves" type="action" icon="gtk-go-forward" context="{'days_due_start':False,'days_due_end': False}"/>
1367 <field name="not_due" sum="Not due"/>
1368- <button name="%(wizard_open_move_line)d" string="Not Due Open Moves" type="action" icon="gtk-go-forward" context="{'days_due_start':False,'days_due_end': 0}"/>
1369 <field name="days_due_01to30" sum="01/30"/>
1370- <button name="%(wizard_open_move_line)d" string="01/30 Open Moves" type="action" icon="gtk-go-forward" context="{'days_due_start':01,'days_due_end': 30}"/>
1371 <field name="days_due_31to60" sum="31/60"/>
1372- <button name="%(wizard_open_move_line)d" string="31/60 Open Moves" type="action" icon="gtk-go-forward" context="{'days_due_start':31,'days_due_end': 60}"/>
1373 <field name="days_due_61to90" sum="61/90"/>
1374- <button name="%(wizard_open_move_line)d" string="61/90 Open Moves" type="action" icon="gtk-go-forward" context="{'days_due_start':61,'days_due_end': 90}"/>
1375 <field name="days_due_91to120" sum="91/120"/>
1376- <button name="%(wizard_open_move_line)d" string="91/120 Open Moves" type="action" icon="gtk-go-forward" context="{'days_due_start':91,'days_due_end': 120}"/>
1377 <field name="days_due_121togr" sum="+121"/>
1378- <button name="%(wizard_open_move_line)d" string="+121 Open Moves" type="action" icon="gtk-go-forward" context="{'days_due_start':121,'days_due_end': False}"/>
1379+ <field name="total" sum="Total"/>
1380+<!--
1381 <field name="company_id"/>
1382 <field name="currency_company_id"/>
1383-<!--
1384 <field name="currency_src_id"/>
1385 -->
1386 </tree>
1387 </field>
1388 </record>
1389- <record id="action_account_aged_partner_balance_vw" model="ir.actions.act_window">
1390- <field name="name">Aged Partner Balance View</field>
1391- <field name="res_model">account.aged.partner.balance.vw</field>
1392- <field name="view_type">form</field>
1393- <field name="view_id" ref="view_account_aged_partner_balance_vw_tree"/>
1394- <field name="view_mode">tree</field>
1395- <!--<field name="context">{'search_default_posted': 0}</field>-->
1396- <!--<field name="search_view_id" ref="account.view_account_move_line_filter"/>-->
1397- <field name="help"/>
1398- </record>
1399- <menuitem action="action_account_aged_partner_balance_vw" id="menu_action_account_aged_partner_balance_vw" parent="account.menu_finance_legal_statement" sequence="100"/>
1400
1401+ <record model="ir.ui.view" id="view_account_aged_partner_document">
1402+ <field name="name">view.account.aged.partner.document.tree</field>
1403+ <field name="model">account.aged.partner.document</field>
1404+ <field name="arch" type="xml">
1405+ <tree string="Aged Partner Document">
1406+ <field name="partner_id"/>
1407+ <field name="document_id"/>
1408+ <field name="date_due"/>
1409+ <field name="due_days"/>
1410+ <field name="residual" sum='Residual'/>
1411+ <field name="not_due" sum="Not due"/>
1412+ <field name="days_due_01to30" sum="01/30"/>
1413+ <field name="days_due_31to60" sum="31/60"/>
1414+ <field name="days_due_61to90" sum="61/90"/>
1415+ <field name="days_due_91to120" sum="91/120"/>
1416+ <field name="days_due_121togr" sum="+121"/>
1417+ <field name="total" sum="Total"/>
1418+<!--
1419+ <field name="company_id"/>
1420+ <field name="currency_company_id"/>
1421+ <field name="currency_src_id"/>
1422+-->
1423+ </tree>
1424+ </field>
1425+ </record>
1426 </data>
1427-</openerp>
1428\ No newline at end of file
1429+</openerp>
1430
1431=== renamed file 'account_aged_partner_balance_vw/account_aged_partner_balance_vw_wizard.xml' => 'account_aged_partner_balance_vw/view/wizard.xml'
1432=== modified file 'account_aged_partner_balance_vw/wizard/__init__.py'
1433--- account_aged_partner_balance_vw/wizard/__init__.py 2012-07-28 05:09:49 +0000
1434+++ account_aged_partner_balance_vw/wizard/__init__.py 2013-10-03 16:40:09 +0000
1435@@ -24,4 +24,4 @@
1436 #
1437 ##############################################################################
1438
1439-import wizard_open_move_line
1440+#import wizard_open_move_line
1441
1442=== modified file 'account_aged_partner_balance_vw/wizard/wizard_open_move_line.py'
1443--- account_aged_partner_balance_vw/wizard/wizard_open_move_line.py 2013-04-18 03:13:19 +0000
1444+++ account_aged_partner_balance_vw/wizard/wizard_open_move_line.py 2013-10-03 16:40:09 +0000
1445@@ -25,7 +25,7 @@
1446 ##############################################################################
1447
1448 import pooler
1449-
1450+import wizard
1451
1452 class wizard_open_move_line(wizard.interface):
1453 def _open_window(self, cr, uid, data, context={}):