Skip to Content
Menu
This question has been flagged
2 Replies
6241 Views

I have three model as follows:

room (model.model):

_name=hotel.room

name = fields.Integer(string = 'Room Number')
room_type = fields.Many2one('hotell.roomtype', string='Room Type')

roomtype(model.model):

_name = 'hotell.roomtype'
   
    name = fields.Selection([('Standard', 'Standard'), ('Deluxe', 'Deluxe')], string = 'Room Type')
    room_ppn = fields.Integer(string = 'Price per Night')

reservation(model.model):

_name = 'hotell.reservation'

room_id = fields.Many2one('hotell.room', string='Room Number')

ppn = fields.Integer(string="Price per Night")


How can I get the price per night from model roomtype via model room?

(P.S there's no relation allowed between model reservation and roomtype

Avatar
Discard
Best Answer

use related : https://www.odoo.com/documentation/11.0/reference/orm.html

Avatar
Discard
Best Answer

Hi,

You can use a related field concept here:

class HotelRoom(models.Model):
_name = 'hotel.room'

name = fields.Integer(string='Room Number')
room_type = fields.Many2one('hotell.roomtype', string='Room Type')
price = fields.Integer(string='Price per Night', related='room_type.room_ppn')

Thanks

Avatar
Discard
Related Posts Replies Views Activity
0
Sep 23
496
0
Sep 23
450
2
Feb 23
9250
6
Oct 23
19259
3
Mar 24
7682