1
# -*- encoding: utf-8 -*-
2
###########################################################################
3
# Module Writen to OpenERP, Open Source Management Solution
4
# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
6
###############Credits######################################################
7
# Coded by: nhomar@openerp.com.ve,
8
# Planified by: Nhomar Hernandez
9
# Finance by: Helados Gilda, C.A. http://heladosgilda.com.ve
10
# Audited by: Humberto Arocha humberto@openerp.com.ve
11
#############################################################################
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 published by
14
# the Free Software Foundation, either version 3 of the License, or
15
# (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/>.
24
##############################################################################
26
from osv import fields
27
from tools.translate import _
30
class account_invoice(osv.osv):
31
_inherit = 'account.invoice'
33
def search_asociated_invoice(self, cr, uid, ids, context=None):
36
data_pool = self.pool.get('ir.model.data')
37
inv_type = self.read(cr, uid, ids[0], ['type', 'name'])
38
name = inv_type['name']
39
inv_type = inv_type['type']
40
invoice_ids = self.search(cr, uid, [('name', '=', name)])
41
# inv_type = context.get('inv_type', False)
45
raise osv.except_osv(_('Error'), _('No Invoices were created'))
46
if inv_type == "out_invoice":
47
action_model,action_id = data_pool.get_object_reference(cr, uid, 'account', "action_invoice_tree1")
48
elif inv_type == "in_invoice":
49
action_model,action_id = data_pool.get_object_reference(cr, uid, 'account', "action_invoice_tree2")
50
elif inv_type == "out_refund":
51
action_model,action_id = data_pool.get_object_reference(cr, uid, 'account', "action_invoice_tree3")
52
elif inv_type == "in_refund":
53
action_model,action_id = data_pool.get_object_reference(cr, uid, 'account', "action_invoice_tree4")
55
action_pool = self.pool.get(action_model)
56
action = action_pool.read(cr, uid, action_id, context=context)
57
action['domain'] = "[('id','in', ["+','.join(map(str,invoice_ids))+"])]"
58
action.update({'nodestroy': True})