Skip to Content
Odoo Menu
  • Log ind
  • Prøv gratis
  • Apps
    Økonomi
    • Bogføring
    • Fakturering
    • Udgifter
    • Regneark (BI)
    • Dokumenter
    • e-Signatur
    Salg
    • CRM
    • Salg
    • POS Butik
    • POS Restaurant
    • Abonnementer
    • Udlejning
    Hjemmeside
    • Hjemmesidebygger
    • e-Handel
    • Blog
    • Forum
    • LiveChat
    • e-Læring
    Forsyningskæde
    • Lagerbeholdning
    • Produktion
    • PLM
    • Indkøb
    • Vedligeholdelse
    • Kvalitet
    HR
    • Medarbejdere
    • Rekruttering
    • Fravær
    • Medarbejdersamtaler
    • Anbefalinger
    • Flåde
    Marketing
    • Markedsføring på sociale medier
    • E-mailmarketing
    • SMS-marketing
    • Arrangementer
    • Automatiseret marketing
    • Spørgeundersøgelser
    Tjenester
    • Projekt
    • Timesedler
    • Udkørende Service
    • Kundeservice
    • Planlægning
    • Aftaler
    Produktivitet
    • Dialog
    • Godkendelser
    • IoT
    • VoIP
    • Vidensdeling
    • WhatsApp
    Tredjepartsapps Odoo Studio Odoo Cloud-platform
  • Brancher
    Detailhandel
    • Boghandel
    • Tøjforretning
    • Møbelforretning
    • Dagligvarebutik
    • Byggemarked
    • Legetøjsforretning
    Mad og værtsskab
    • Bar og pub
    • Restaurant
    • Fastfood
    • Gæstehus
    • Drikkevareforhandler
    • Hotel
    Ejendom
    • Ejendomsmægler
    • Arkitektfirma
    • Byggeri
    • Ejendomsadministration
    • Havearbejde
    • Boligejerforening
    Rådgivning
    • Regnskabsfirma
    • Odoo-partner
    • Marketingbureau
    • Advokatfirma
    • Rekruttering
    • Audit & certificering
    Produktion
    • Tekstil
    • Metal
    • Møbler
    • Fødevareproduktion
    • Bryggeri
    • Firmagave
    Heldbred & Fitness
    • Sportsklub
    • Optiker
    • Fitnesscenter
    • Kosmetolog
    • Apotek
    • Frisør
    Håndværk
    • Handyman
    • IT-hardware og support
    • Solenergisystemer
    • Skomager
    • Rengøringsservicer
    • VVS- og ventilationsservice
    Andet
    • Nonprofitorganisation
    • Miljøagentur
    • Udlejning af billboards
    • Fotografi
    • Cykeludlejning
    • Softwareforhandler
    Gennemse alle brancher
  • Community
    Få mere at vide
    • Tutorials
    • Dokumentation
    • Certificeringer
    • Oplæring
    • Blog
    • Podcast
    Bliv klogere
    • Udannelselsesprogram
    • Scale Up!-virksomhedsspillet
    • Besøg Odoo
    Få softwaren
    • Download
    • Sammenlign versioner
    • Udgaver
    Samarbejde
    • Github
    • Forum
    • Arrangementer
    • Oversættelser
    • Bliv partner
    • Tjenester til partnere
    • Registrér dit regnskabsfirma
    Modtag tjenester
    • Find en partner
    • Find en bogholder
    • Kontakt en rådgiver
    • Implementeringstjenester
    • Kundereferencer
    • Support
    • Opgraderinger
    Github Youtube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Få en demo
  • Prissætning
  • Hjælp

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Bogføring
  • Lager
  • PoS
  • Projekt
  • MRP
All apps
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Hjælp

@api odoo11

Tilmeld

Få besked, når der er aktivitet på dette indlæg

Dette spørgsmål er blevet anmeldt
rentalrent@api.dependsOdoo11
5 Besvarelser
5444 Visninger
Avatar
Tiến Paul

hai,

Hello everyone, I'm newbie, I want to write @api so that when there are customers renting that room on the table room, the status fields will automatically turn into 'busy' and vice versa will return 'free'

class booking_room(models.Model):
_name = 'room'
_rec_name = 'name'

name = fields.Char(string="Mã phòng", required=True)
   status = fields.Selection([('1', 'Trống'), ('2', 'Bận')], string="Trạng thái", required=True)
kind = fields.Selection([('3', 'A'), ('4', 'B'), ('5', 'C'), ('6', 'Vip')], string="Loại phòng", required=True)
price = fields.Integer(string="Giá phòng", required=True)
description = fields.Text("Ghi chú")
-------------------------

class guest_room(models.Model):
_name = 'guest'

name = fields.Char(string="Họ tên", required=True)
cmnd = fields.Char(string="Số CMND", required=True)
sdt = fields.Char(string="SĐT", required=True)
time_in = fields.Datetime(string="Ngày đến")
time_out = fields.Datetime(string="Ngày trả")
servicesd = fields.Many2one('service', string="Dịch vụ sử dụng")
roomsd = fields.Many2one('room', string="Phòng mượn")

Thanks

0
Avatar
Kassér
Nikhil Krishnan

Try to make question readable and explain details.

OdooBot
thank you for the help. changed a bit and it worked, but when "status" by default is "busy"

Vào Th 4, 26 thg 9, 2018 vào lúc 06:17 Juan Albarracin <aprados.juan@gmail.com> đã viết:

A new answer on @api odoo11 has been posted. Click here to access the post :

See post

--
Juan Albarracin

Sent by Odoo S.A. using Odoo.

OdooBot
thank you for the help. But it does not work for me

Vào Th 3, 25 thg 9, 2018 vào lúc 15:53 NIKHIL KRISHNAN <nikhilkrishnan0101@gmail.com> đã viết:

A new question @api odoo11 on Help has been posted. Click here to access the question :

See question


Sent by Odoo S.A. using Odoo.

Avatar
Nikhil Krishnan
Bedste svar

Hai vu van tien,

You can define a form view for the room table.

Then create a button for allocation and free the rooms.

XML

<button name="roomallocationandfree" string="Allocation/Free" type="object" class="btn-primary"/>

Python

@api.multi
def roomallocationandfree(self):
if self.status == 1:
self.status = 2
else:
self.status = 1

Regards,

Nikhilkrishnan

1
Avatar
Kassér
Avatar
Juan Albarracin
Bedste svar

Hello, I think you want the field to be computed on the fly, without having to assign the value with a button right?

You can make the status field a computed field and assign its value like in my code below.

Remember to import datetime at the top of your python file, and add the field to the views you prefer!

#import required library to get current datetime
from datetime import datetime as dt
class booking_room(models.Model):
_name = 'room'
name = fields.Char(string="Mã phòng", required=True)
   status = fields.Selection([('1', 'Trống'), ('2', 'Bận')], string="Trạng thái",
        required=True, compute="_get_status"
    )
kind = fields.Selection([('3', 'A'), ('4', 'B'), ('5', 'C'), ('6', 'Vip')],
        string="Loại phòng", required=True
    )
price = fields.Integer(string="Giá phòng", required=True)
description = fields.Text("Ghi chú")
@api.multi
def _get_status(self):
        # Get the current datetime in the format that time_in and time_out fields
        # are stored in the database
        now = dt.now().strftime('%Y-%m-%d %H:%M:%S')
        for room in self:
            # look for guests that have a room booked now, and whose room id is the current
            # the order is important because as the guest table grows,
            # the nº of rows that satisfy the conditions will be lower for the first one,
            # bigger for the second, and the biggest for the last one,
            # and the search will be faster this way.
            # guest_in_room will be True is len(search)>0, False otherwise.
            guest_in_room = len(self.env['guest'].search([
                ('time_out', '>', now),
                ('time_in', '<', now),
                ('roomsd', '=', room.id)
            ])) > 0
            # If guest_in_room is True, room's status is busy, free otherwise
            if guest_in_room:
                room.status = '2'
            else:
                room.status = '1'

 Regards,

Juan Albarracin

1
Avatar
Kassér
Avatar
DHA Medic
Bedste svar

You can use state:

Ex:

https://github.com/odoo/odoo/blob/11.0/addons/hr_holidays/models/hr_holidays.py#L159-L170

https://github.com/odoo/odoo/blob/11.0/addons/hr_holidays/views/hr_holidays_views.xml#L83-L89

1
Avatar
Kassér
Avatar
Tiến Paul
Forfatter Bedste svar
 thank you
Juan Albarracin
  has answered, but to me, it does not work. fields 'status' does not work, whether or not the "guest" reservation or not "status" returned is always "blank" and can not be tampered with or created.
0
Avatar
Kassér
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Tilmeld dig
Related Posts Besvarelser Visninger Aktivitet
Rental module for Odoo Community
rental rent
Avatar
0
apr. 19
15303
Displaying Prices (Website / Rental)
rental rent website
Avatar
Avatar
1
apr. 25
1920
Edit the rental app
rental rent source_code
Avatar
0
dec. 22
2960
Sale Rental v9c
rental rent Quantity on Hand
Avatar
0
sep. 17
3511
How to rent a fixed asset in odoo 16
rental rent fixedassets fixed_asset
Avatar
0
maj 23
3312
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Oversættelser
Tjenester
  • Odoo.sh-hosting
  • Support
  • Opgradere
  • Individuelt tilpasset udvikling
  • Uddannelse
  • Find en bogholder
  • Find en partner
  • Bliv partner
Om os
  • Vores virksomhed
  • Brandaktiver
  • Kontakt os
  • Stillinger
  • Arrangementer
  • Podcast
  • Blog
  • Kunder
  • Juridiske dokumenter • Privatlivspolitik
  • Sikkerhedspolitik
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo er en samling open source-forretningsapps, der dækker alle dine virksomhedsbehov – lige fra CRM, e-handel og bogføring til lagerstyring, POS, projektledelse og meget mere.

Det unikke ved Odoo er, at systemet både er brugervenligt og fuldt integreret.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now