[IMP] account: General ledger & Account balance => if print from object should not have charts of account field

bzr revid: mra@mra-laptop-20100715053516-qgdjllsp9s717tkq
This commit is contained in:
Mustufa Rangwala 2010-07-15 11:05:16 +05:30
parent 540a1ab943
commit 869cde3704
2 changed files with 27 additions and 0 deletions

View File

@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from lxml import etree
from osv import osv, fields
from tools.translate import _
@ -36,6 +37,18 @@ class account_balance_report(osv.osv_memory):
'display_account': 'bal_all'
}
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
mod_obj = self.pool.get('ir.model.data')
res = super(account_balance_report, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=False)
if context.get('active_model', False) == 'account.account' and view_id:
doc = etree.XML(res['arch'])
nodes = doc.xpath("//field[@name='chart_account_id']")
for node in nodes:
node.set('readonly', '1')
node.set('help', 'If you print the report from Account list/form view it will not consider Charts of account')
res['arch'] = etree.tostring(doc)
return res
def _print_report(self, cr, uid, ids, data, query_line, context=None):
data['form'].update(self.read(cr, uid, ids, ['display_account'])[0])
data['form']['query_line'] = query_line

View File

@ -19,6 +19,8 @@
#
##############################################################################
from lxml import etree
from osv import fields, osv
from tools.translate import _
@ -41,6 +43,18 @@ class account_report_general_ledger(osv.osv_memory):
'sortby': 'sort_date',
}
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
mod_obj = self.pool.get('ir.model.data')
res = super(account_report_general_ledger, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=False)
if context.get('active_model', False) == 'account.account' and view_id:
doc = etree.XML(res['arch'])
nodes = doc.xpath("//field[@name='chart_account_id']")
for node in nodes:
node.set('readonly', '1')
node.set('help', 'If you print the report from Account list/form view it will not consider Charts of account')
res['arch'] = etree.tostring(doc)
return res
def _print_report(self, cr, uid, ids, data, query_line, context=None):
if context is None:
context = {}