-
-
Notifications
You must be signed in to change notification settings - Fork 253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MIG] [17.0] hotel #207
base: 17.0
Are you sure you want to change the base?
[MIG] [17.0] hotel #207
Changes from 1 commit
4699570
179ddd6
da5a593
924aebd
f0beb6a
f4462ab
fa892f1
5da0d1f
55bc685
56aac23
0a7ff20
373922c
6aef83f
6820729
0e45958
3bdca1b
c70b383
3606a4a
5eb74d2
8244744
bd35472
494ff79
877c5d2
026ec69
9ee3e46
3e7bbd1
d7aea65
254481c
0d3d83f
752050b
b3340ab
24b2f29
cfc5d7d
e8abcee
4401091
5c7bddf
23915d8
fb07c78
6dc7e97
2f78f01
164146b
24438c0
c52bb03
846567c
261f085
39207ab
b8db1ba
692db2a
4581149
8e426a4
85cc134
b3b0d3d
7d7597e
9d032ea
7c364b0
0985a05
cd1f0fc
542fdc0
09a9be5
e852a75
f2d3e7a
c458040
d5de5ea
12fa3f8
cd1193e
e6e68c4
02d1acf
ec09671
e80ab8e
1d01ae2
09abc1e
275ea78
9b1163b
ef6dc7c
9e2d3a4
224abb8
3ac8360
e44e6ce
5dc6edc
3e0ab84
7530e1f
56cd5ac
7bb6274
ba238a9
1abccd4
49ce808
1409b5c
6c9d4ff
813f13c
688b6e2
0aa4be0
f6fad13
69a10db
b83ce2d
a60279b
0bfd5cb
76f787f
996459f
c37ae37
2db8534
64a4d28
f12d2cc
b96c2cb
629e48b
2f7aac8
2093bf8
f527595
b238587
56b755e
9590f56
9cb6f03
370b079
16066f6
e86d464
2d3b892
944f16d
353962b
8f84bd4
3195172
4c8f5e9
dd84425
ad247d9
6b35844
b68ec8c
5e7d434
57e862b
2d7bed7
cd1b3fb
a520967
9da4728
3afd083
a8f35c5
8045135
b0f3a84
6220591
e29c872
6a1598d
c02ed49
bb00d05
01bd487
2f4b970
abed0a6
9f7223f
4dee427
236a3b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,14 +27,13 @@ class HotelFolio(models.Model): | |
_description = "hotel folio" | ||
_rec_name = "order_id" | ||
|
||
def name_get(self): | ||
def _compute_display_name(self): | ||
res = [] | ||
fname = "" | ||
for rec in self: | ||
if rec.order_id: | ||
fname = str(rec.name) | ||
rec.display_name = ( str(rec.order_id.name)) | ||
res.append((rec.id, fname)) | ||
return res | ||
|
||
@api.model | ||
def name_search(self, name="", args=None, operator="ilike", limit=100): | ||
|
@@ -58,7 +57,7 @@ def _get_checkout_date(self): | |
) | ||
return fields.Datetime.to_string(checkout_date) | ||
|
||
name = fields.Char("Folio Number", readonly=True, index=True, default="New") | ||
name = fields.Char("Folio Number", index=True, default="New") | ||
order_id = fields.Many2one( | ||
"sale.order", "Order", delegate=True, required=True, ondelete="cascade" | ||
) | ||
|
@@ -69,7 +68,6 @@ def _get_checkout_date(self): | |
) | ||
checkout_date = fields.Datetime( | ||
"Check Out", | ||
required=True, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why removed the required=True? |
||
readonly=True, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
default=_get_checkout_date, | ||
) | ||
|
@@ -140,18 +138,16 @@ def _update_folio_line(self, folio_id): | |
folio_room_line_obj = self.env["folio.room.line"] | ||
hotel_room_obj = self.env["hotel.room"] | ||
for rec in folio_id: | ||
for room_rec in rec.room_line_ids: | ||
room = hotel_room_obj.search( | ||
[("product_id", "=", room_rec.product_id.id)] | ||
) | ||
room.write({"isroom": False}) | ||
vals = { | ||
"room_id": room.id, | ||
"check_in": rec.checkin_date, | ||
"check_out": rec.checkout_date, | ||
"folio_id": rec.id, | ||
} | ||
folio_room_line_obj.create(vals) | ||
product_ids = rec.room_line_ids.mapped("product_id").ids | ||
rooms = hotel_room_obj.search([("product_id", "in", product_ids)]) | ||
rooms.write({"isroom": False}) | ||
vals = { | ||
"room_id": rooms.id, | ||
"check_in": rec.checkin_date, | ||
"check_out": rec.checkout_date, | ||
"folio_id": rec.id, | ||
} | ||
folio_room_line_obj.create(vals) | ||
|
||
@api.model | ||
def create(self, vals): | ||
|
@@ -161,7 +157,7 @@ def create(self, vals): | |
@param vals: dictionary of fields value. | ||
@return: new record set for hotel folio. | ||
""" | ||
if not "service_line_ids" and "folio_id" in vals: | ||
if "service_line_ids" not in vals and "folio_id" in vals: | ||
tmp_room_lines = vals.get("room_line_ids", []) | ||
vals["order_policy"] = vals.get("hotel_policy", "manual") | ||
vals.update({"room_line_ids": []}) | ||
|
@@ -175,7 +171,7 @@ def create(self, vals): | |
vals = {} | ||
vals["name"] = self.env["ir.sequence"].next_by_code("hotel.folio") | ||
vals["duration"] = vals.get("duration", 0.0) or vals.get("duration", 0.0) | ||
folio_id = super().create(vals) | ||
folio_id = super(HotelFolio, self).create(vals) | ||
self._update_folio_line(folio_id) | ||
return folio_id | ||
|
||
|
@@ -198,8 +194,8 @@ def write(self, vals): | |
new_rooms = set(room_lst).difference(set(rooms_list)) | ||
if len(list(new_rooms)) != 0: | ||
room_list = product_obj.browse(list(new_rooms)) | ||
for rm in room_list: | ||
room_obj = hotel_room_obj.search([("product_id", "=", rm.id)]) | ||
for room in room_list: | ||
room_obj = hotel_room_obj.search([("product_id", "=", room.id)],limit=1) | ||
room_obj.write({"isroom": False}) | ||
vals = { | ||
"room_id": room_obj.id, | ||
|
@@ -223,7 +219,7 @@ def write(self, vals): | |
[("folio_id", "=", rec.id)] | ||
) | ||
folio_romline_rec.write(room_vals) | ||
return super().write(vals) | ||
return super(HotelFolio, self).write(vals) | ||
|
||
@api.onchange("partner_id") | ||
def _onchange_partner_id(self): | ||
|
@@ -347,6 +343,8 @@ def unlink(self): | |
@param self: The object pointer | ||
@return: True/False. | ||
""" | ||
hotel_room_obj = self.env["hotel.room"] | ||
hotel_room_line_obj = self.env["folio.room.line"] | ||
for line in self: | ||
if line.order_line_id: | ||
rooms = self.env["hotel.room"].search( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. define all object at starting of the method |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,7 +61,7 @@ | |
<sheet> | ||
<label for="name" string="Folio Number" /> | ||
<h1> | ||
<field name="name" colspan="4" /> | ||
<field name="name" colspan="4" readonly="1" /> | ||
</h1> | ||
<group colspan="4" col="4"> | ||
<field name="date_order" readonly="1" /> | ||
|
@@ -100,7 +100,7 @@ | |
/> | ||
<field | ||
name="checkout_date" | ||
readonly="state != 'draft'" | ||
readonly="state != 'draft' or 1" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you sure its working? |
||
/> | ||
<field name="duration" readonly="1" /> | ||
<field name="duration_dummy" invisible="1" /> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add Docstring
"Override the create method to link the account move with a hotel folio"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have added comment instead of docstring:
Docstring is the method description defined inside the method between triple quote in case of multiline