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 fields, osv
35
class account_move_line(osv.osv):
36
_name = 'account.move.line'
37
_inherit = 'account.move.line'
39
def _invoice(self, cr, uid, ids, name, arg, context=None) :
40
return super(account_move_line, self)._invoice(cr, uid, ids, name, arg, context)
42
def _invoice_search(self, cr, uid, obj, name, args, context={}) :
43
"""Redefinition for searching account move lines without any invoice related ('invoice.id','=',False)"""
44
sql = """SELECT l.id FROM account_move_line l
45
LEFT JOIN account_invoice i ON l.move_id = i.move_id
48
if (x[2] is False) and (x[1] == '=') and (x[0] == 'invoice') :
52
return [('id', '=', '0')]
53
return [('id', 'in', [x[0] for x in res])]
54
return super(account_move_line, self)._invoice_search(cr, uid, obj, name, args, context=context)
57
{ 'invoice': fields.function
62
, relation='account.invoice'
63
, fnct_search=_invoice_search