[MERGE] Account: Balance sheet report visible reserve and surplus field
bzr revid: mra@mra-laptop-20101227105043-5j8k7qxx8g0ktn01
This commit is contained in:
@@ -32,36 +32,45 @@ class account_bs_report(osv.osv_memory):
|
||||
_inherit = "account.common.account.report"
|
||||
_description = 'Account Balance Sheet Report'
|
||||
|
||||
def _get_def_reserve_account(self, cr, uid, context=None):
|
||||
chart_id = self._get_account(cr, uid, context=context)
|
||||
res = self.onchange_chart_id(cr, uid, [], chart_id, context=context)
|
||||
if not res:
|
||||
return False
|
||||
return res['value']['reserve_account_id']
|
||||
|
||||
_columns = {
|
||||
'display_type': fields.boolean("Landscape Mode"),
|
||||
'reserve_account_id': fields.many2one('account.account', 'Reserve & Profit/Loss Account',required = True,
|
||||
help='This Account is used for transferring Profit/Loss(If It is Profit: Amount will be added, Loss : Amount will be duducted.), Which is calculated from Profilt & Loss Report', domain = [('type','=','payable')]),
|
||||
'reserve_account_id': fields.many2one('account.account', 'Reserve & Profit/Loss Account',
|
||||
required=True,
|
||||
help='This Account is used for transfering Profit/Loss ' \
|
||||
'(Profit: Amount will be added, Loss: Amount will be duducted), ' \
|
||||
'which is calculated from Profilt & Loss Report',
|
||||
domain = [('type','=','payable')]),
|
||||
}
|
||||
|
||||
_defaults={
|
||||
'display_type': True,
|
||||
'journal_ids': [],
|
||||
'reserve_account_id': _get_def_reserve_account,
|
||||
}
|
||||
|
||||
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
|
||||
res = super(account_bs_report, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=False)
|
||||
doc = etree.XML(res['arch'])
|
||||
nodes = doc.xpath("//field[@name='journal_ids']")
|
||||
for node in nodes:
|
||||
node.set('readonly', '1')
|
||||
node.set('required', '0')
|
||||
res['arch'] = etree.tostring(doc)
|
||||
return res
|
||||
def onchange_chart_id(self, cr, uid, ids, chart_id, context=None):
|
||||
if not chart_id:
|
||||
return {}
|
||||
account = self.pool.get('account.account').browse(cr, uid, chart_id , context=context)
|
||||
if not account.company_id.property_reserve_and_surplus_account:
|
||||
return {'value': {'reserve_account_id': False}}
|
||||
return {'value': {'reserve_account_id': account.company_id.property_reserve_and_surplus_account.id}}
|
||||
|
||||
|
||||
def _print_report(self, cr, uid, ids, data, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
data = self.pre_print_report(cr, uid, ids, data, context=context)
|
||||
account = self.pool.get('account.account').browse(cr, uid, data['form']['chart_account_id'], context=context)
|
||||
if not account.company_id.property_reserve_and_surplus_account:
|
||||
data['form'].update(self.read(cr, uid, ids, ['display_type','reserve_account_id'])[0])
|
||||
if not data['form']['reserve_account_id']:
|
||||
raise osv.except_osv(_('Warning'),_('Please define the Reserve and Profit/Loss account for current user company !'))
|
||||
data['form']['reserve_account_id'] = account.company_id.property_reserve_and_surplus_account.id
|
||||
data['form'].update(self.read(cr, uid, ids, ['display_type'])[0])
|
||||
data = self.pre_print_report(cr, uid, ids, data, context=context)
|
||||
if data['form']['display_type']:
|
||||
return {
|
||||
'type': 'ir.actions.report.xml',
|
||||
@@ -77,4 +86,4 @@ class account_bs_report(osv.osv_memory):
|
||||
|
||||
account_bs_report()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
@@ -9,14 +9,20 @@
|
||||
<field name="inherit_id" ref="account.account_common_report_view" />
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="//field[@name='chart_account_id']" position="replace">
|
||||
<field name="chart_account_id" widget="selection" on_change="onchange_chart_id(chart_account_id)"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='journal_ids']" position="replace">
|
||||
<field name="journal_ids" colspan="4" nolabel="1" required="0" readonly="1"/>
|
||||
</xpath>
|
||||
<xpath expr="/form/label[@string='']" position="replace">
|
||||
<separator string="Balance Sheet" colspan="4"/>
|
||||
<label nolabel="1" colspan="4" string="This report allows you to print or generate a pdf of your trial balance allowing you to quickly check the balance of each of your accounts in a single report"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='target_move']" position="after">
|
||||
<field name="display_account"/>
|
||||
<field name="reserve_account_id" required="1"/>
|
||||
<field name="display_type"/>
|
||||
<field name="reserve_account_id" required="0" invisible="1"/>
|
||||
<newline/>
|
||||
</xpath>
|
||||
</data>
|
||||
|
||||
Reference in New Issue
Block a user