Hello,
I'm trying to customize the analytic account views (account_analytic_account). 
In particular I'm trying to create a new custom tree, based on an object that 
extend account_analytic_account object. But there is no way to display 
"balance" field (that is a function field): when I try to view tree in OpenERP, 
it gives me a SQL error.
I post you my code so you can understand more:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="custom_form_analyticaccountcustom_bind" model="ir.ui.view">
<field name="name">custom.analyticaccountcustom_bind.form</field>
<field name="model">account.analytic.account_custom</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Analytic bind">
<field name="name" select="1" readonly="1"/>
<field name="code" select="1" readonly="1"/>
<newline/>
<field name="custom_binded"/>
</form>
</field>
</record>
<record id="custom_tree_analyticaccountcustom_bind" model="ir.ui.view">
<field name="name">custom.analyticaccountcustom_bind.tree</field>
<field name="model">account.analytic.account_custom</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Analytic bind">
<field name="name"/>
<field name="code"/>
<field name="partner_id"/>
<field name="custom_binded"/>
<field name="company_currency_id"/>
<field name="debit"/>
<field name="credit"/>

<!--<field name="balance"/>
<field name="quantity"/>-->

<field name="quantity_max"/>
</tree>
</field>
</record>
<menuitem name="custom management"&nbsp; 
id="custom_menu_analyticaccount_management" icon="STOCK_DND_MULTIPLE"/>
<record model="ir.actions.act_window" 
id="custom_action_analyticaccount_bind_tree">
<field name="name">custom analytic bind tree</field>
<field name="res_model">account.analytic.account_custom</field>
<field name="view_id" ref="custom_tree_analyticaccountcustom_bind"/>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">&#91;&#40;'custom_binded','!=',1&#41;&#93;</field>
</record>
<menuitem name="custom analytic bind tree" 
id="custom_menu_analyticaccount_bind_tree" 
parent="custom_menu_analyticaccount_management" 
action="custom_action_analyticaccount_bind_tree"/>
</data>
</openerp>

from osv import fields, osv

# extend account analytic class

class account_analytic_account&#40;osv.osv&#41;&#58;
_inherit = 'account.analytic.account'
_columns = &#123;
'custom_binded'&#58; fields.boolean&#40;'Binded'&#41;,
&#125;
_default = &#123;
'custom_binded'&#58; lambda *a&#58; 0,
&#125;

account_analytic_account&#40;&#41;

# create new class based on account analytic class

class account_analytic_account_custom&#40;osv.osv&#41;&#58;
_inherit = 'account.analytic.account'
_table = 'account_analytic_account'
_name = 'account.analytic.account_custom'

account_analytic_account_custom&#40;&#41;

&#123;
"name" &#58; "custom_analytic_account",
"version" &#58; "0.1",
"depends" &#58; &#91;"base","account"&#93;,
"author" &#58; "zipgem",
"description"&#58; """
custom analytic account
""",
'init_xml'&#58; &#91;&#93;,
'update_xml'&#58; &#91;"custom_analytic_account.xml"&#93;,
'demo_xml'&#58; &#91;&#93;,
'installable'&#58; True,
'active'&#58; False
&#125;

import custom_analytic_account


Obviously it is possibly to change the name of the file.
Can someone help me? If I uncommnet field balance in tree XML, OpenERP give me 
the error when I try to open the tree.

Thank in advance anyone able to help me.

tnk

Zipgem




-------------------- m2f --------------------

--
http://www.openobject.com/forum/viewtopic.php?p=52542#52542

-------------------- m2f --------------------


_______________________________________________
Tinyerp-users mailing list
http://tiny.be/mailman2/listinfo/tinyerp-users

Reply via email to