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

Many2one fields are not showing

By
youta
on 1/13/16, 7:27 AM 317 views

Hello,

I'm trying to create a module to add extra fields to hr.holidays.

I've created a new menuitem called Travel Request to inherit hr.holidays and apply extra modification.

Here's my code:

class travel_request(models.Model):

_inherit = 'hr.holidays',

_name = 'travel.request'

flight_class = fields.Selection([('business_c','Business class'),('economy_c','Economy class')], 'Flight Class', required=True, readonly=True, states={'draft':[('readonly',False)], 'confirm':[('readonly',False)]}, help="Please choose your flight class", select=True)

trip_type = fields.Selection([('business_t','Business'),('personal_t','personal'),('sales_t', 'Sales')], 'Trip Type', required=True, readonly=True, states={'draft':[('readonly',False)], 'confirm':[('readonly',False)]}, help="Please choose your desired trip type", select=True)

city_from = fields.Char('From', readonly=True, states={'draft':[('readonly',False)], 'confirm':[('readonly',False)]})

city_to = fields.Char('To', readonly=True, states={'draft':[('readonly',False)], 'confirm':[('readonly',False)]})

trip_details_ids = fields.One2many('trip.details','travel_req_id', string="Trip Details")

class trip_details(models.Model):

_name = 'trip.details'

from_city = fields.Char('From')

to_city = fields.Char('To')

travel_req_id = fields.Many2one('travel.request', 'Travel Request')

and in my view.xml:

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

<field name="name">Travel Request</field>

<field name="model">travel.request</field>

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

<form string="Travel Request">

 

<sheet>

                     .

                     .

                     .

<notebook colspan="4">

<page string="Trip Details">

<field name="trip_details_ids" />

</page>

<page string="Reason">

<field name="notes" nolabel="1" placeholder="Add a reason..." />

</page>

</notebook>

</sheet>

</form>

</field>

</record>

and here's my output view:

https://drive.google.com/open?id=0B8l_J46zjX-1VXZBRXBWY2c2YTQ

My problem is why the two char fields from_city & to_city are not showing as columns instead of the "Created by" row inside trip details?

1

Pawan

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


Pawan
On 1/14/16, 12:58 AM

Youla,

inspite of

<field name="trip_details_ids" />

try giving :

<field name="trip_details_ids">
     <tree>
         <field name="from_city"/>
         <field name="to_city"/>
         <field name="travel_req_id"/>
     </tree>
</field>


Hope it helps    

Thank you Pawan, it worked.. Looks like the way I used to create modules in openerp 7 isn't working anymore .. And I need to learn the new api

youta
on 1/14/16, 2:23 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: 1/13/16, 7:27 AM
Seen: 317 times
Last updated: 1/14/16, 2:21 AM