openerp - Best way to show fields not in the model in a One2many widget ODOO -


i want show column on form field want access not store in model. i've following models:

class class1(models.model):     _name = 'module.class1'      field1 = fields.integer(string='field1')     field2 = fields.integer(string='field2')   class class2(models.model):     _name = 'module.class1'      field1 = fields.integer(string='field1')     field2 = fields.integer(string='field2')     class3_ids = fields.one2many('module.class3', 'class2_id', string="class2")  class class3(models.model):     _name='module.class3'      class2_id = fields.many2one('module.class2')     class1_id = fields.many2one('module.class1')     field1 = fields.float(string='field1') 

i'm form want display in class1 form class2 records show class1 fields somethin this:

<record id="module_class1_form" model="ir.ui.view">     <field name="name">module_class1: form</field>     <field name="model">module.class1</field>     <field name="arch" type="xml">         <form>             <sheet>                 <group>                     <field name="number"/>                     <field name="class3_ids" nolabel="1">                         <tree string="class3" editable="bottom" nolabel="1">                           <field name="field1"/>                           <field name="class1_id"/>                           <field name="class1_id.somefield"/>                         </tree>                     </field>                 </group>             </sheet>         </form>     </field> </record> 

the code work fine, except part of want access , show data class1 thinking use computed fields more pythonic way?

thanks

use related field. in model:

class class3(models.model):     _name='module.class3'      class2_id = fields.many2one('module.class2')     class1_id = fields.many2one('module.class1')     field1 = fields.float(string='field1')     class1field1 = fields.integer(related='class1_id.field1') 

and in view:

<field name="class1field1"/> 

Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -