1
# -*- encoding: utf-8 -*-
2
###########################################################################
3
# Module Writen to OpenERP, Open Source Management Solution
5
# Copyright (c) 2010 Vauxoo - http://www.vauxoo.com/
7
# info Vauxoo (info@vauxoo.com)
8
############################################################################
9
# Coded by: Luis Torres (luis_t@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
##############################################################################
26
from openerp.osv import fields, osv
27
from lxml import etree
28
from openerp import SUPERUSER_ID
30
class account_voucher(osv.Model):
31
_inherit = 'account.voucher'
33
def fields_view_get_address(self, cr, uid, arch, context={}):
34
user_obj = self.pool.get('res.users')
35
fmt = user_obj.browse(cr, SUPERUSER_ID, uid, context).\
37
fmt = fmt and fmt.address_format
40
<div class="oe_subtotal_footer_separator">
41
<field name="conciled" modifiers="{"invisible":\
44
<button type="object" icon="terp-stock_format-scientific" \
45
name="compute_tax" class="oe_link oe_edit_only" \
46
string="(Update)" attrs="{'invisible': \
47
[('state','!=','draft')]}"/>
51
for k,v in layouts.items():
52
if fmt and (k in fmt):
53
doc = etree.fromstring(arch)
54
for node in doc.xpath(
55
"//div[@class='oe_subtotal_footer_separator']"):
56
tree = etree.fromstring(v)
57
node.getparent().replace(node, tree)
58
arch = etree.tostring(doc)
62
def fields_view_get(self, cr, uid, view_id=None, view_type=False,
63
context=None, toolbar=False, submenu=False):
64
res = super(account_voucher, self).fields_view_get(cr, uid,
65
view_id=view_id, view_type=view_type, context=context,
66
toolbar=toolbar, submenu=submenu)
67
if view_type == 'form':
68
res['arch'] = self.fields_view_get_address(cr, uid, res['arch'],
72
def _check_conciled(self, cr, uid, ids, name, arg, context=None):
74
for voucher in self.browse(cr, uid, ids, context=context):
76
for line in voucher.move_ids:
77
if line.reconcile_id or line.reconcile_partial_id:
79
if reconcile == False:
80
res[voucher.id] = False
82
res[voucher.id] = True
85
def _voucher_search(self, cr, uid, obj, name, args, context=None):
88
company_user = self.pool.get('res.users').browse(cr, uid, uid,
89
context=context).company_id.id
90
company_id = self.pool.get('res.company').browse(cr, uid, company_user,
93
for voucher in self.search(cr, uid, [('state','=','posted'), (
94
'company_id', '=', company_id)]):
96
for line in self.browse(cr, uid, voucher, context=context).move_ids:
97
if line.reconcile_id.id or line.reconcile_partial_id.id:
102
if reconcile == False:
103
list_voucher.append(voucher)
104
return [('id', 'in', [x for x in list_voucher])]
107
'conciled' : fields.function(_check_conciled, type='boolean',
108
string='References', method=True, fnct_search=_voucher_search)