Skip to Content
Menu
This question has been flagged
1698 Views

I want to get a room rate and the price of services used to make payment, then I must do so.
code:

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

name = fields.Char(string="Họ tên", required=True, size=50)
cmnd = fields.Integer(string="Số CMND", required=True, size=12)
sdt = fields.Integer(string="SĐT", required=True, size=10)
time_in = fields.Datetime(string="Ngày đến")
time_out = fields.Datetime(string="Ngày trả")
description = fields.Html("Ghi chú", size=1000)
# servicesd = fields.Many2one('service', string="Dịch vụ sử dụng")
servicesd_ids = fields.One2many('room.line', 'line', 'Dịch vụ')
roomsd = fields.Many2one('room', string="Phòng thuê")


class RoomLine(models.Model):
_name = 'room.line'

line = fields.Many2one('guest')
name = fields.Many2one('service', 'Dịch vụ')

and bills
class Bill(models.Model):
_name = 'bills'

kh_thue = fields.Many2one('guest', 'Khách hàng')
total = fields.Integer(compute="_get_total", string='Tổng')

@api.multi
@api.depends("kh_thue")
def _get_total(self):
if kh_thue != None:
total = kh_thue.roomsd.price + kh_thue.servicesd_ids.price_service
Avatar
Discard
Related Posts Replies Views Activity
0
Apr 19
2056
9
Mar 20
40585
2
Oct 18
2654
1
Oct 17
2869
2
Mar 15
5553