Pular para o conteúdo
Odoo Menu
  • Entrar
  • Experimente grátis
  • Aplicativos
    Finanças
    • Financeiro
    • Faturamento
    • Despesas
    • Planilhas (BI)
    • Documentos
    • Assinar Documentos
    Vendas
    • CRM
    • Vendas
    • PDV Loja
    • PDV Restaurantes
    • Assinaturas
    • Locação
    Websites
    • Criador de Sites
    • e-Commerce
    • Blog
    • Fórum
    • Chat ao Vivo
    • e-Learning
    Cadeia de mantimentos
    • Inventário
    • Fabricação
    • PLM - Ciclo de Vida do Produto
    • Compras
    • Manutenção
    • Qualidade
    Recursos Humanos
    • Funcionários
    • Recrutamento
    • Folgas
    • Avaliações
    • Indicações
    • Frota
    Marketing
    • Redes Sociais
    • Marketing por E-mail
    • Marketing por SMS
    • Eventos
    • Automação de Marketing
    • Pesquisas
    Serviços
    • Projeto
    • Planilhas de Horas
    • Serviço de Campo
    • Central de Ajuda
    • Planejamento
    • Compromissos
    Produtividade
    • Mensagens
    • Aprovações
    • Internet das Coisas
    • VoIP
    • Conhecimento
    • WhatsApp
    Aplicativos de terceiros Odoo Studio Plataforma Odoo Cloud
  • Setores
    Varejo
    • Loja de livros
    • Loja de roupas
    • Loja de móveis
    • Mercearia
    • Loja de ferramentas
    • Loja de brinquedos
    Comida e hospitalidade
    • Bar e Pub
    • Restaurante
    • Fast Food
    • Hospedagem
    • Distribuidor de bebidas
    • Hotel
    Imóveis
    • Imobiliária
    • Escritório de arquitetura
    • Construção
    • Administração de propriedades
    • Jardinagem
    • Associação de proprietários de imóveis
    Consultoria
    • Escritório de Contabilidade
    • Parceiro Odoo
    • Agência de marketing
    • Escritório de advocacia
    • Aquisição de talentos
    • Auditoria e Certificação
    Fabricação
    • Têxtil
    • Metal
    • Móveis
    • Alimentação
    • Cervejaria
    • Presentes corporativos
    Saúde e Boa forma
    • Clube esportivo
    • Loja de óculos
    • Academia
    • Profissionais de bem-estar
    • Farmácia
    • Salão de cabeleireiro
    Comércio
    • Handyman
    • Hardware e Suporte de TI
    • Sistemas de energia solar
    • Sapataria
    • Serviços de limpeza
    • Serviços de climatização
    Outros
    • Organização sem fins lucrativos
    • Agência Ambiental
    • Aluguel de outdoors
    • Fotografia
    • Aluguel de bicicletas
    • Revendedor de software
    Navegar por todos os setores
  • Comunidade
    Aprenda
    • Tutoriais
    • Documentação
    • Certificações
    • Treinamento
    • Blog
    • Podcast
    Empodere a Educação
    • Programa de educação
    • Scale Up! Jogo de Negócios
    • Visite a Odoo
    Obtenha o Software
    • Baixar
    • Comparar edições
    • Releases
    Colaborar
    • Github
    • Fórum
    • Eventos
    • Traduções
    • Torne-se um parceiro
    • Serviços para parceiros
    • Cadastre seu escritório contábil
    Obtenha os serviços
    • Encontre um parceiro
    • Encontre um Contador
    • Conheça um consultor
    • Serviços de Implementação
    • Referências de Clientes
    • Suporte
    • Upgrades
    Github YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Faça uma demonstração
  • Preços
  • Ajuda

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

  • CRM
  • e-Commerce
  • Financeiro
  • Inventário
  • PoS
  • Projeto
  • MRP
All apps
É necessário estar registrado para interagir com a comunidade.
Todas as publicações Pessoas Emblemas
Marcadores (Ver tudo)
odoo accounting v14 pos v15
Sobre este fórum
É necessário estar registrado para interagir com a comunidade.
Todas as publicações Pessoas Emblemas
Marcadores (Ver tudo)
odoo accounting v14 pos v15
Sobre este fórum
Ajuda

@api odoo11

Inscrever

Seja notificado quando houver atividade nesta publicação

Esta pergunta foi sinalizada
rentalrent@api.dependsOdoo11
5 Respostas
5450 Visualizações
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
Cancelar
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
Melhor resposta

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
Cancelar
Avatar
Juan Albarracin
Melhor resposta

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
Cancelar
Avatar
DHA Medic
Melhor resposta

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
Cancelar
Avatar
Tiến Paul
Autor Melhor resposta
 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
Cancelar
Está gostando da discussão? Não fique apenas lendo, participe!

Crie uma conta hoje mesmo para aproveitar os recursos exclusivos e interagir com nossa incrível comunidade!

Inscreva-se
Publicações relacionadas Respostas Visualizações Atividade
Rental module for Odoo Community
rental rent
Avatar
0
abr. 19
15314
Displaying Prices (Website / Rental)
rental rent website
Avatar
Avatar
1
abr. 25
1921
Edit the rental app
rental rent source_code
Avatar
0
dez. 22
2960
Sale Rental v9c
rental rent Quantity on Hand
Avatar
0
set. 17
3511
How to rent a fixed asset in odoo 16
rental rent fixedassets fixed_asset
Avatar
0
mai. 23
3314
Comunidade
  • Tutoriais
  • Documentação
  • Fórum
Open Source
  • Baixar
  • Github
  • Runbot
  • Traduções
Serviços
  • Odoo.sh Hosting
  • Suporte
  • Upgrade
  • Desenvolvimentos personalizados
  • Educação
  • Encontre um Contador
  • Encontre um parceiro
  • Torne-se um parceiro
Sobre nós
  • Nossa empresa
  • Ativos da marca
  • Contato
  • Empregos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidade
  • Segurança
الْعَرَبيّة 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 é um conjunto de aplicativos de negócios em código aberto que cobre todas as necessidades de sua empresa: CRM, comércio eletrônico, contabilidade, estoque, ponto de venda, gerenciamento de projetos, etc.

A proposta de valor exclusiva Odoo é ser, ao mesmo tempo, muito fácil de usar e totalmente integrado.

Site feito com

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