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" 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">[('custom_binded','!=',1)]</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(osv.osv): _inherit = 'account.analytic.account' _columns = { 'custom_binded': fields.boolean('Binded'), } _default = { 'custom_binded': lambda *a: 0, } account_analytic_account() # create new class based on account analytic class class account_analytic_account_custom(osv.osv): _inherit = 'account.analytic.account' _table = 'account_analytic_account' _name = 'account.analytic.account_custom' account_analytic_account_custom() { "name" : "custom_analytic_account", "version" : "0.1", "depends" : ["base","account"], "author" : "zipgem", "description": """ custom analytic account """, 'init_xml': [], 'update_xml': ["custom_analytic_account.xml"], 'demo_xml': [], 'installable': True, 'active': False } 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
