Buongiorno a tutti,
sto provando a personalizzare le view del conto analitico (account_analytic_account). In particolare sto provando a crearmi una nuova tree customizzata, che si basa su oggetto che estende account_analytic_account. Ma non c'è verso di far visualizzare il campo "balance" (che è un campo funzione): mi da errore SQL.
Vi posto il codice così magari vi è un po più chiaro cosa faccio:
<?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
Ovviamente bisogna eventualmente cambiare i nomi dei file.
Qualcuno riesce a darmi un aiuto? Se toglo il commento ai campi nella tree si vede subito l'errore su openerp quando tenti di aprire la tree.
Ringrazio in anticipo chiunque mi riesca a dare una mano.
Grazie
Zipgem