1
# -*- coding: utf-8 -*-
2
##############################################
4
# Swing Entwicklung betrieblicher Informationssysteme GmbH
5
# (<http://www.swing-system.com>)
6
# Copyright (C) ChriCar Beteiligungs- und Beratungs- GmbH
8
# 08-JUN-2012 (GK) created
10
# WARNING: This program as such is intended to be used by professional
11
# programmers who take the whole responsibility of assessing all potential
12
# consequences resulting from its eventual inadequacies and bugs.
13
# End users who are looking for a ready-to-use solution with commercial
14
# guarantees and support are strongly advised to contract a Free Software
17
# This program is Free Software; you can redistribute it and/or
18
# modify it under the terms of the GNU General Public License
19
# as published by the Free Software Foundation; either version 3
20
# of the License, or (at your option) any later version.
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 General Public License for more details.
27
# You should have received a copy of the GNU General Public License
28
# along with this program; if not, see <http://www.gnu.org/licenses/> or
29
# write to the Free Software Foundation, Inc.,
30
# 59 Temple Place - Suite 330, Boston, MA 02111-1.17, USA.
32
###############################################
33
from osv import osv, fields
35
class payment_order_create(osv.osv_memory):
36
_name = 'payment.order.create.c2c'
37
_inherit = 'payment.order.create'
38
_description = 'payment.order.create'
40
{ 'balance_filter' : fields.boolean
41
( 'Only partners with total liability'
42
, help='Will select only partners with a debit-credit < 0 regardless of due date.'
44
, 'min_balance' : fields.float
45
( 'Minimum Total Amount Due'
46
, help="Will select only partners with total payment balance greater than this amount."
50
{ 'balance_filter' : lambda *a: True
51
, 'min_balance' : lambda *a: 100.0
54
def search_entries(self, cr, uid, ids, context=None):
55
if context is None : context = {}
56
order_obj = self.pool.get('payment.order')
57
line_obj = self.pool.get('account.move.line')
58
mod_obj = self.pool.get('ir.model.data')
59
obj = self.browse(cr, uid, ids, context=context)[0]
60
payment = order_obj.browse(cr, uid, context['active_id'], context=context)
62
[ ('reconcile_id', '=', False)
63
, ('account_id.type', '=', 'payable')
64
, ('amount_to_pay', '>', 0)
68
, ('date_maturity', '<=', obj.duedate)
69
, ('date_maturity', '=', False)
71
ids = line_obj.search(cr, uid, domain, context=context)
73
for line in line_obj.browse(cr, uid, ids) :
74
if line.invoice.payment_block : continue
75
if line.move_id.state == "draft" : continue
76
if not line.partner_bank_id and payment.mode.require_bank_account : continue
77
if line.partner_id.payment_block : continue
78
if (line.partner_id.payment_obey_balance
79
and obj.balance_filter
80
and not ((line.partner_id.debit - line.partner_id.credit) >= obj.min_balance)) : continue
81
line_ids.append(line.id)
82
context.update({'line_ids': line_ids})
83
model_data_ids = mod_obj.search \
85
, [('model', '=', 'ir.ui.view'), ('name', '=', 'view_create_payment_order_lines')]
88
resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
90
{ 'name' : ('Entry Lines')
92
, 'view_type' : 'form'
93
, 'view_mode' : 'form'
94
, 'res_model' : 'payment.order.create'
95
, 'views' : [(resource_id,'form')]
96
, 'type' : 'ir.actions.act_window'
99
payment_order_create()