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.

1

how to customize one2many field [Closed]

By
Susi
on 12/30/14, 7:53 AM 1,987 views

The Question has been closed

by
Susi
on 01/21/2016 23:15:11

i made new object called 'wtc.city' it has one2many fields called 'city_line'. it contain 3 fields (code, name and state_id) . i want to insert that line to 'res.country.state' just for code and name not contain state_id . but i always get 3 fields. My code shown below :

.py

class wtc_country_state (osv.osv):
    _inherit = 'res.country.state'

   _columns = {

 'city_line': fields.one2many('wtc.city', 'state_id', string='City', readonly=True)

}

.xml

         <record model="ir.ui.view" id="country_state_form_view">
            <field name="name">wtc.country.state.form</field>
            <field name="model">res.country.state</field>
            <field name="inherit_id" ref="base.view_country_state_form"/>
            <field name="arch" type="xml">   
                <xpath expr="//form[@string='State']" position="inside">
                    <separator string="City" />
                    <field name="city_line" nolabel="1" colspan="2"/>
                </xpath>
            </field>
            </record>

anyone can help me?

2

Anil R. Kesariya

--Anil R. Kesariya--
4321
| 6 5 8
Gandhinagar, India
--Anil R. Kesariya--
ERP Consultant

Key Skill
-
Technical & Functional Expert
Anil R. Kesariya
On 12/30/14, 8:46 AM

@Susi,

you need to define internal tree,form for your one2many field otherwise it will display all the fields defined in that model.

if you are not defining internal tree,form view than create seprate xml reocrd for form and tree view of your one2many field  model.

Hope this will helps you.

Anil.

 

 

 

1
sameer alhwety
On 12/30/14, 9:43 AM

try this :

                               <field name="city_line" nolabel="1" colspan="4">
                                    <tree string="City" editable="bottom">
                                        <field name="name"/>  
                                        <field name="code"/>
                                    </tree>
                                </field>

1
Susi
On 12/30/14, 10:51 PM

dear all i have use tree but its not work

         <record model="ir.ui.view" id="country_state_form_view">
            <field name="name">wtc.country.state.form</field>
            <field name="model">res.country.state</field>
            <field name="inherit_id" ref="base.view_country_state_form"/>
            <field name="arch" type="xml">   
                <xpath expr="//form[@string='State']" position="inside">
                    <separator string="City" />
                    <field name="city_line" nolabel="1" colspan="2"/>
                      <tree string="City" editable="bottom">
                                <field name="name"/>  
                                 <field name="code"/>
                      </tree>
                </xpath>
            </field>
            </record>

 

 

you need remove last "/" on line and add after

Alan Luo
on 4/14/16, 2:29 AM
0
Pouya Maleki
On 5/30/15, 3:50 AM

add mode to fild definition like this:

<field name="city_line" nolabel="1" colspan="2" mode="tree">

     <tree>

        <field name="code"/>

        <field name="name"/>

    </tree>

</field>

0
odookillsme
On 12/30/14, 8:09 AM

your tree implementation wrong
                    <field name="city_line" nolabel="1" colspan="2"/>
                      <tree string="City" editable="bottom">
                                <field name="name"/>  
                                 <field name="code"/>
                      </tree>

you have to put the tree inside the <field> tag you shouldn't self close it please look below again

 

try this instead of "<field name="city_line" nolabel="1" colspan="2"/>"

<field name="city_line" nolabel="1" colspan="2">
     <tree>
         <field name="code"/>
         <field name="name"/>
     </tree>
</field>

 

i have try your code but its doesnt work...thanks before

Susi
on 12/30/14, 8:13 AM

hmm, try with tree tags instead of form

odookillsme
on 12/30/14, 8:17 AM
0

zbik

--zbik--
5941
| 6 4 7
Lodz, Poland
--zbik--


zbik
On 12/30/14, 8:19 AM

If I understand you well, use:

<field name="city_line" widget="many2many" nolabel="1" colspan="2"/>

its doesnt work

Susi
on 12/30/14, 8:29 AM

You have defined forms and tree views for wtc.city?

zbik
on 12/30/14, 8:39 AM

About This Community

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

Question tools

1 follower(s)

Stats

Asked: 12/30/14, 7:53 AM
Seen: 1987 times
Last updated: 1/21/16, 11:15 PM