1
# -*- encoding: utf-8 -*-
2
###########################################################################
3
# Module Writen to OpenERP, Open Source Management Solution
5
# Copyright (c) 2011 Vauxoo - http://www.vauxoo.com/
7
# info Vauxoo (info@vauxoo.com)
8
############################################################################
9
# Coded by: moylop260 (moylop260@vauxoo.com)
10
############################################################################
12
# This program is free software: you can redistribute it and/or modify
13
# it under the terms of the GNU Affero General Public License as
14
# published by the Free Software Foundation, either version 3 of the
15
# License, or (at your option) any later version.
17
# This program is distributed in the hope that it will be useful,
18
# but WITHOUT ANY WARRANTY; without even the implied warranty of
19
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
# GNU Affero General Public License for more details.
22
# You should have received a copy of the GNU Affero General Public License
23
# along with this program. If not, see <http://www.gnu.org/licenses/>.
25
##############################################################################
30
class wizard_open_move_line(wizard.interface):
31
def _open_window(self, cr, uid, data, context={}):
34
mod_obj = pooler.get_pool(cr.dbname).get('ir.model.data')
35
act_obj = pooler.get_pool(cr.dbname).get('ir.actions.act_window')
36
aged_partner_balance_vw_obj = pooler.get_pool(cr.dbname).get('account.aged.partner.balance.vw')
37
partner_ids = [aged_partner_balance_vw.partner_id and aged_partner_balance_vw.partner_id.id or False for aged_partner_balance_vw in aged_partner_balance_vw_obj.browse(cr, uid, data['ids'], context=context)]
38
#result = mod_obj._get_id(cr, uid, 'account', 'action_account_moves_all_a')
39
result = mod_obj._get_id(cr, uid, 'account', 'action_move_line_select')
40
id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
41
result = act_obj.read(cr, uid, [id])[0]
42
#result['context'] = {'partner_id': partner_ids}
43
#result['domain'] = [('partner_id','in',partner_ids), ('account_id.type','=','receivable')]
45
days_due_start = context.get('days_due_start', False)
46
if not days_due_start is False:
47
where_query.append( 'days_due >= %d'%( days_due_start ) )
49
days_due_end = context.get('days_due_end', False)
50
if not days_due_end is False:
51
where_query.append( 'days_due <= %d'%( days_due_end ) )
52
#where_query_str = (where_query and ' WHERE ' or '') + ' AND '.join( where_query )
53
where_query_str = (where_query and ' AND ' or '') + ' AND '.join( where_query )
54
query = """SELECT l.id as id--, l.partner_id, l.company_id
55
FROM account_move_line l
58
SELECT id, EXTRACT(DAY FROM (now() - COALESCE(lt.date_maturity,lt.date))) AS days_due
59
FROM account_move_line lt
62
INNER JOIN account_account
63
ON account_account.id = l.account_id
64
INNER JOIN res_company
65
ON account_account.company_id = res_company.id
66
INNER JOIN account_move
67
ON account_move.id = l.move_id
68
WHERE account_account.active
69
AND (account_account.type IN ('receivable'))
70
AND (l.reconcile_id IS NULL)
71
AND account_move.state = 'posted'
72
AND l.reconcile_id is null --and l.currency_id is null
76
move_ids = [r[0] for r in res]
77
result['domain'] = [('partner_id','in',partner_ids), ('id','in',move_ids)]
83
'result': {'type': 'action', 'action': _open_window, 'state': 'end'}
86
wizard_open_move_line('wizard.open.move.line')
87
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: