コンテンツへスキップ
Odoo メニュー
  • サインイン
  • 無料で15日試す
  • アプリ
    財務
    • 会計
    • 請求
    • 経費
    • スプレッドシート(BI)
    • ドキュメント管理
    • 署名
    販売
    • CRM
    • 販売
    • POS店舗
    • POSレストラン
    • サブスクリプション
    • レンタル
    ウェブサイト
    • ウェブサイトビルダー
    • eコマース
    • ブログ
    • フォーラム
    • ライブチャット
    • eラーニング
    サプライチェーン
    • 在庫
    • 製造
    • 製品ライフサイクル管理 (PLM)
    • 購買
    • 整備
    • 品質
    人事業務
    • 従業員管理
    • 採用
    • 休暇管理
    • 人事評価
    • リファラル
    • フリート
    マーケティング
    • ソーシャルマーケティング
    • メールマーケティング
    • SMSマーケティング
    • イベント
    • マーケティングオートメーション
    • アンケート調査
    サービス
    • プロジェクト管理
    • タイムシート
    • フィールドサービス
    • ヘルプデスク
    • 計画
    • アポイントメント
    生産性向上ツール
    • ディスカッション
    • 承認
    • IoT
    • VoIP
    • ナレッジ
    • WhatsApp
    サードパーティアプリ Odooスタジオ Odooクラウドプラットホーム
  • インダストリー(業種別ソリューション)
    小売
    • 書店
    • アパレルショップ
    • 家具専門店
    • 食料品店
    • 金物店
    • 玩具店
    飲食・ホスピタリティ業界
    • バー・パブ
    • レストラン
    • ファストフード
    • ゲストハウス
    • 飲料販売代理店
    • ホテル
    不動産
    • 不動産会社
    • 建築事務所
    • 建設
    • 不動産管理
    • 造園
    • 住宅所有者組合
    コンサルティング
    • 会計事務所
    • Odooパートナー
    • マーケティングエージェンシー
    • 法律事務所
    • 人材派遣
    • 監査・認証
    製造
    • テキスタイル
    • 金属
    • 家具
    • 飲食
    • 醸造所
    • コーポレートギフト
    ヘルス & フィットネス
    • スポーツクラブ
    • 眼鏡店
    • フィットネスセンター
    • ウェルネス専門家
    • 薬局
    • ヘアサロン
    業種
    • 便利屋
    • IT ハードウェア・サポート
    • 太陽エネルギーシステム
    • 靴メーカー
    • クリーニングサービス
    • 空調設備サービス
    その他
    • 非営利団体
    • 環境機関
    • ビルボードレンタル
    • 写真
    • 自転車リース
    • ソフトウェアリセラー
    すべての業種を見る
  • コミュニティ
    学ぶ
    • チュートリアル
    • ドキュメンテーション
    • 認定
    • トレーニング
    • ブログ
    • ポッドキャスト
    教育サポート
    • 教育プログラム
    • Scale Up! ビジネスゲーム
    • Odooオフィス訪問
    ソフトを入手
    • ダウンロード
    • エディションを比較
    • リリース
    コラボレーション
    • Github
    • フォーラム
    • イベント
    • 翻訳
    • パートナーになる
    • パートナー様向けサービス
    • 会計事務所を登録
    サービス利用
    • パートナー一覧
    • 会計事務所一覧
    • 今すぐ相談する
    • 導入支援サービス
    • お客様一覧
    • サポート
    • アップグレード
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    製品デモを利用する
  • 料金
  • ヘルプ

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

  • CRM
  • e-Commerce
  • 会計
  • 在庫
  • PoS
  • プロジェクト
  • MRP
All apps
コミュニティで交流するには登録する必要があります。
全てのポスト 人々 バッジ
タグ (全て表示)
odoo accounting v14 pos v15
このフォーラムについて
コミュニティで交流するには登録する必要があります。
全てのポスト 人々 バッジ
タグ (全て表示)
odoo accounting v14 pos v15
このフォーラムについて
ヘルプ

@api odoo11

購読

この投稿に活動があった際に通知を受け取ります

この質問にフラグが付けられました
rentalrent@api.dependsOdoo11
5 返信
5445 ビュー
アバター
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
アバター
破棄
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.

アバター
Nikhil Krishnan
最善の回答

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
アバター
破棄
アバター
Juan Albarracin
最善の回答

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
アバター
破棄
アバター
DHA Medic
最善の回答

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
アバター
破棄
アバター
Tiến Paul
著作者 最善の回答
 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
アバター
破棄
ディスカッションを楽しんでいますか?読むだけでなく、参加しましょう!

今すぐアカウントを作成して、限定機能を利用したり、素晴らしいコミュニティと交流しましょう!

登録
関連投稿 返信 ビュー 活動
Rental module for Odoo Community
rental rent
アバター
0
4月 19
15309
Displaying Prices (Website / Rental)
rental rent website
アバター
アバター
1
4月 25
1920
Edit the rental app
rental rent source_code
アバター
0
12月 22
2960
Sale Rental v9c
rental rent Quantity on Hand
アバター
0
9月 17
3511
How to rent a fixed asset in odoo 16
rental rent fixedassets fixed_asset
アバター
0
5月 23
3313
コミュニティ
  • チュートリアル
  • ドキュメンテーション
  • フォーラム
オープンソース
  • ダウンロード
  • Github
  • Runbot
  • 翻訳
サービス
  • Odoo.shホスティング
  • サポート
  • アップグレード
  • カスタム開発
  • 教育プログラム
  • 会計事務所一覧
  • パートナー一覧
  • パートナーになる
企業情報
  • 会社概要
  • ブランドアセット
  • お問い合わせ
  • 採用情報
  • イベント
  • ポッドキャスト
  • ブログ
  • お客様一覧
  • リーガル情報 • プライバシーポリシー
  • セキュリティ
الْعَرَبيّة 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(オドゥー)は、CRM、eコマース、会計、在庫管理、POS、プロジェクト管理など、企業のさまざまな業務を一つのシステムで管理できる、ベルギー発のオープンソースのERPソフトウェアです。

高機能で使いやすく、完全に統合されたERPとして、ユニークな価値を提供しています。

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