Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Module Tree(multiple columns) help?

By
David
on 11/7/13, 3:03 PM 1,522 views

I'm beginning to play around more with OE and just trying to explore making a simple(so I would think) module, but I have seemed get stuck on displaying the grid(view field).

In the "Almost Complete" you can see in the grid I'm missing VALUE for the parametric

My other question, when I select "Component Type" could I get the grid(Parametrics) pre-populate with a set of Parametric Type's that are assigned to say Resistor in this example?

Almost Complete: (remove the {}) http://i{.}imgur{.}com{/}UxQCIfi.png

Here is my code:

tilparts.py:

# -*- coding: utf-8 -*-

from openerp.osv import fields, osv

class tilparts_componenttype(osv.osv): 
    _name = 'tilparts.componenttype'
    _rec_name='component_type'
    _columns = {
        'component_type': fields.char('Component Type',size=32),
    }
tilparts_componenttype() 

class tilparts_part(osv.osv):
    _name = 'tilparts.part'
    _rec_name='partno'
    _columns = {
        'partno': fields.char('Part Number',size=48),
        'componenttype_ids': fields.many2one('tilparts.componenttype','Component Type',select=True),
        'parameter_ids': fields.one2many('tilparts.parameter','parametrics_id',string='Parametrics',select=True),       
    }
tilparts_part()

class tilparts_parameter(osv.osv): 
    _name = 'tilparts.parameter'
    _rec_name='parametrics_id'
    _columns = {
        'parametrics_id': fields.many2one('tilparts.parametrics','Parametric Type', ondelete='cascade'),
        'value': fields.char('Value',size=16),
    }
tilparts_parameter() 

class tilparts_parametrics(osv.osv): 
    _name = 'tilparts.parametrics'
    _rec_name='parametric_type'
    _columns = {
        'parametric_type': fields.char('Parametric Type',size=16,required=False,ondelete='cascade'),
        'componenttype_ids': fields.many2one('tilparts.componenttype','Component Type',required=False,ondelete='cascade'),
    }
tilparts_parametrics()

tilparts_view.xml

<?xml version="1.0" ?>

<openerp>
        <data>

            <record model="ir.ui.view" id="part_form"> 
                <field name="name">part.form</field> 
                <field name="model">tilparts.part</field> 
                <field name="arch" type="xml">
                    <form string="Part"  version="7.0"> 
                        <sheet>
                            <group>
                                <group>
                                    <field name="partno"/> 
                                </group>
                                <group>
                                    <field name="componenttype_ids"/>               
                                </group>
                            </group>
                            <notebook  colspan="6">
                                <page string="Parametrics">
                                    <field name="parameter_ids"/> 
                                </page>
                            </notebook>
                        </sheet>
                    </form>
                </field>        
            </record>



            <record model="ir.ui.view" id="part_tree">
                <field name="name">part.tree</field>
                <field name="model">tilparts.part</field>
                <field name="type">tree</field> 
                <field name="arch" type="xml">
                    <tree string="Part" > 
                        <field name="partno"/>
                        <field name="componenttype_ids"/>               
                    </tree>
                </field>
            </record>

             <record model="ir.actions.act_window" id="action_part"> 
                <field name="name">Parts</field> 
                <field name="res_model">tilparts.part</field> 
                <field name="view_type">form</field> 
                <field name="view_mode">tree,form</field>
            </record>

            <menuitem id="tilparts" name="TIL Parts"/>
               <menuitem name="TiL Parts" id="section_main_menu_tilparts" parent="tilparts" />
                <menuitem name="Parts" id="choice_part" parent="section_main_menu_tilparts" action="action_part"/>

        </data>
</openerp>
0
David
On 11/8/13, 10:19 AM

Let me reword my question.

I would like to have a form in which I have 2 columns to fill in and as well a tree...

Object "tilparts_part" contains those 2 columns, partno and componenttype_ids(which points to tilparts_componenttype) for a dropdown list.

For the Tree I wanted to have it point to object: "tilparts_parameter". which would allow the user to enter as many "Add Items" in the tree type want.

My problem is that the form is built, and for the tree ONLY the field parametrics_id(which is a drop down list from tilparts_parametrics) is shown on the tree list. I would also like to include the field "value" from the "tilparts_parameter" Object as well... No matter what I have tried I haven't had any luck in displaying that field.

Can anyone provide feed back?

Thanks.

<record model="ir.ui.view" id="part_form"> 
<field name="name">part.form</field> 
<field name="model">tilparts.part</field> 
<field name="arch" type="xml">
    <form string="Part"  version="7.0"> 
        <sheet>
            <group>
                <group>
                    <field name="partno"/> 
                </group>
                <group>
                    <field name="componenttype_ids"/>               
                </group>
            </group>
            <notebook  colspan="6">
                <page string="Parametrics">
                    <field name="parameter_ids"/> 
                </page>
            </notebook>
        </sheet>
    </form>
</field>

</record>

class tilparts_part(osv.osv):
_name = 'tilparts.part'
_rec_name='partno'
_columns = {
    'partno': fields.char('Part Number',size=48),
    'componenttype_ids': fields.many2one('tilparts.componenttype','Component Type',select=True),
    'Calibration_child_row_id': fields.many2one('tilparts.part','tilparts.part'),
    'parameter_ids': fields.one2many('tilparts.parameter','parametrics_id',string='Parametrics'),       
}
tilparts_part()

class tilparts_parameter(osv.osv): 
    _name = 'tilparts.parameter'
    _columns = {
        'parametrics_id': fields.many2one('tilparts.parametrics','Parametric Type', ondelete='cascade'),
        'value': fields.char('Value',size=16),
    }
tilparts_parameter()

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 11/7/13, 3:03 PM
Seen: 1522 times
Last updated: 6/11/16, 12:27 PM