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

One2many field on a form view

By
Roberto Barreiro
on 7/6/16, 7:12 AM 396 views

Hello to all, I have the following problem showing a one2many field on a form view at odoo8. I want to show the fields "days", "morning" and "afternoon" at the form, but only the field "created by" it's shown.  What I'm doing wrong? Thanks in advice.

The code of my model:

from openerp.osv import fields, osv

class res_partner_schedule(osv.osv):

_name = "res.partner.schedule"

_columns = {

'company_id': fields.many2one('res.company', 'Company',

ondelete='cascade'),

'days': fields.char('Days'),

'morning': fields.char('Mornings'),

'afternoon': fields.char('Afternoon'),

}

class res_company(osv.osv):

_inherit = "res.company"

_columns = {

'schedule': fields.one2many('res.partner.schedule', 'company_id', 'Business Hours', help='Schedule of this company'),

}


The code of my view:

<openerp>

<data>

<record id="res_company_schedule_form" model="ir.ui.view">

<field name="name">res.company.schedule.form</field>

<field name="model">res.company</field>

<field name="type">form</field>

<field name="inherit_id" ref="base.view_company_form"/>

<field name="arch" type="xml">

<group string="Bank Accounts" position="before">

<group string="Schedule">

<field name="schedule"/>

</group>

</group>

</field>

</record>

</data>

</openerp>

1

Pawan

--Pawan--
1267
| 4 3 5
Hyderabad, India
--Pawan--


Pawan
On 7/6/16, 7:37 AM

Roberto,

The reason why you are getting only created_by is, you don't have any tree view defined for your object res.partner.schedule so odoo is showing only created_by field as default tree view,

if you wan to show other fields too, you can do it there only, by defining  an inline tree view....as:

<group string="Bank Accounts" position="before">

<group string="Schedule">

<field name="schedule">

                                     <tree>    

                                            <field name="days"/>

                                            <field name="morning"/>

                                          <field name="afternoon"/>

                                     </tree>

                                </field>

</group>

</group>

Thank you so much for your answer. I was divin on the odoo code, but I never thought tree view had relation with form view.

Roberto Barreiro
on 7/6/16, 7:41 AM
1
kirubanidhi
On 7/6/16, 8:39 AM


Hi,Are you specified tree tag after declare "schedule" field in your view file

<openerp>

<data>

<record id="res_company_schedule_form" model="ir.ui.view">

<field name="name">res.company.schedule.form</field>

<field name="model">res.company</field>

<field name="type">form</field>

<field name="inherit_id" ref="base.view_company_form"/>

<field name="arch" type="xml">

<group string="Bank Accounts" position="before">

<group string="Schedule">

<field name="schedule"/>

                                    <tree>

                                        <field name="days"/>

                                        <field name="morning"/>

                                        <field name="afternoon"/>

                                    </tree>

</group>

</group>

</field>

</record>

</data>

</openerp>





Hmmm. This doesn't work. The view refers to res.company model. Days, morning and afternoon fields belongs to res.partner.schedule, so using this code results on fields not found error.

Roberto Barreiro
on 7/6/16, 9:44 AM

It works with the tree tag and it's content inside field "schedule" as Pawan answered.

Roberto Barreiro
on 7/6/16, 12:40 PM

I send code your mail check it now

kirubanidhi
on 7/7/16, 2:14 AM

Thanks for your code and your time. I have given you +1, but I selected pawan's answer as right because he was the first on post, and his answer solved my problem.

Roberto Barreiro
on 7/8/16, 11:39 AM

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

1 follower(s)

Stats

Asked: 7/6/16, 7:12 AM
Seen: 396 times
Last updated: 7/6/16, 9:39 AM