-
-
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
Conversation
…ol on list of modules.
…TODO: rewrite everything
Currently translated at 100.0% (520 of 520 strings) Translation: vertical-hotel-15.0/vertical-hotel-15.0-hotel Translate-URL: https://translation.odoo-community.org/projects/vertical-hotel-15-0/vertical-hotel-15-0-hotel/it/
Currently translated at 100.0% (520 of 520 strings) Translation: vertical-hotel-15.0/vertical-hotel-15.0-hotel Translate-URL: https://translation.odoo-community.org/projects/vertical-hotel-15-0/vertical-hotel-15-0-hotel/it/
Currently translated at 100.0% (520 of 520 strings) Translation: vertical-hotel-15.0/vertical-hotel-15.0-hotel Translate-URL: https://translation.odoo-community.org/projects/vertical-hotel-15-0/vertical-hotel-15-0-hotel/it/
Currently translated at 100.0% (520 of 520 strings) Translation: vertical-hotel-15.0/vertical-hotel-15.0-hotel Translate-URL: https://translation.odoo-community.org/projects/vertical-hotel-15-0/vertical-hotel-15-0-hotel/it/
Currently translated at 100.0% (520 of 520 strings) Translation: vertical-hotel-15.0/vertical-hotel-15.0-hotel Translate-URL: https://translation.odoo-community.org/projects/vertical-hotel-15-0/vertical-hotel-15-0-hotel/it/
Currently translated at 100.0% (520 of 520 strings) Translation: vertical-hotel-15.0/vertical-hotel-15.0-hotel Translate-URL: https://translation.odoo-community.org/projects/vertical-hotel-15-0/vertical-hotel-15-0-hotel/it/
Currently translated at 100.0% (520 of 520 strings) Translation: vertical-hotel-15.0/vertical-hotel-15.0-hotel Translate-URL: https://translation.odoo-community.org/projects/vertical-hotel-15-0/vertical-hotel-15-0-hotel/it/
Currently translated at 100.0% (520 of 520 strings) Translation: vertical-hotel-15.0/vertical-hotel-15.0-hotel Translate-URL: https://translation.odoo-community.org/projects/vertical-hotel-15-0/vertical-hotel-15-0-hotel/it/
Currently translated at 100.0% (520 of 520 strings) Translation: vertical-hotel-15.0/vertical-hotel-15.0-hotel Translate-URL: https://translation.odoo-community.org/projects/vertical-hotel-15-0/vertical-hotel-15-0-hotel/it/
Currently translated at 100.0% (520 of 520 strings) Translation: vertical-hotel-15.0/vertical-hotel-15.0-hotel Translate-URL: https://translation.odoo-community.org/projects/vertical-hotel-15-0/vertical-hotel-15-0-hotel/it/
Currently translated at 100.0% (520 of 520 strings) Translation: vertical-hotel-15.0/vertical-hotel-15.0-hotel Translate-URL: https://translation.odoo-community.org/projects/vertical-hotel-15-0/vertical-hotel-15-0-hotel/it/
Currently translated at 100.0% (520 of 520 strings) Translation: vertical-hotel-15.0/vertical-hotel-15.0-hotel Translate-URL: https://translation.odoo-community.org/projects/vertical-hotel-15-0/vertical-hotel-15-0-hotel/it/
Currently translated at 100.0% (520 of 520 strings) Translation: vertical-hotel-15.0/vertical-hotel-15.0-hotel Translate-URL: https://translation.odoo-community.org/projects/vertical-hotel-15-0/vertical-hotel-15-0-hotel/it/
Currently translated at 100.0% (520 of 520 strings) Translation: vertical-hotel-15.0/vertical-hotel-15.0-hotel Translate-URL: https://translation.odoo-community.org/projects/vertical-hotel-15-0/vertical-hotel-15-0-hotel/it/
Currently translated at 100.0% (520 of 520 strings) Translation: vertical-hotel-15.0/vertical-hotel-15.0-hotel Translate-URL: https://translation.odoo-community.org/projects/vertical-hotel-15-0/vertical-hotel-15-0-hotel/it/
Currently translated at 100.0% (520 of 520 strings) Translation: vertical-hotel-15.0/vertical-hotel-15.0-hotel Translate-URL: https://translation.odoo-community.org/projects/vertical-hotel-15-0/vertical-hotel-15-0-hotel/it/
Currently translated at 100.0% (520 of 520 strings) Translation: vertical-hotel-15.0/vertical-hotel-15.0-hotel Translate-URL: https://translation.odoo-community.org/projects/vertical-hotel-15-0/vertical-hotel-15-0-hotel/it/
hotel/models/hotel_folio.py
Outdated
) | ||
return fields.Datetime.to_string(checkout_date) | ||
|
||
name = fields.Char("Folio Number", readonly=True, index=True, default="New") |
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.
checkout_date = fields.Datetime( | ||
"Check Out", | ||
required=True, | ||
readonly=True, |
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.
hotel/__manifest__.py
Outdated
{ | ||
"name": "Hotel Management", | ||
"version": "17.0.1.0.0", | ||
"author": "Odoo Community Association (OCA), Serpent Consulting \ |
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.
"author": "Odoo Community Association (OCA), Serpent Consulting \ | |
"author": "Odoo Community Association (OCA), | |
Serpent Consulting Services Pvt. Ltd., |
hotel/__manifest__.py
Outdated
"name": "Hotel Management", | ||
"version": "17.0.1.0.0", | ||
"author": "Odoo Community Association (OCA), Serpent Consulting \ | ||
Services Pvt. Ltd., OpenERP SA", |
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.
Services Pvt. Ltd., OpenERP SA", | |
OpenERP SA", |
_inherit = "account.move" | ||
|
||
@api.model | ||
def create(self, vals): |
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
@api.model
def create(self, vals):
"Override the create method to link the account move with a hotel folio"
hotel/models/hotel_folio.py
Outdated
@param vals: dictionary of fields value. | ||
@return: new record set for hotel folio. | ||
""" | ||
if not "service_line_ids" and "folio_id" in vals: |
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.
if not "service_line_ids" and "folio_id" in vals: | |
if "service_line_ids" not in vals and "folio_id" in vals: |
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.
This change completely alters the behavior. The original precedence would be like this:
(not "service_line_ids") and ("folio_id" in vals)
which would always evaluate to False (because of not "service_line_ids"
)
If this fixes incorrect behavior shouldn't that rather be a PR with fixing that in an existing branch that would be propagated to other branches and possibly cherry-picked in this PR?
However the code does not make much sense. This is inside create method of hotel.folio model and there is no such attribute as folio_id in that model. So what is actually the intention of that code? Was it to check presence of folio_id in service_line_ids ? But then see remarks regarding create method signature.
Also the code after the else
is pretty funny. It only handles the situation when vals
is empty. If it would not be it will end up with nasty exception of using folio_id
before initialization.
Also the whole method signature:
@api.model
def create(self, vals):
"""
Overrides orm create method.
@param self: The object pointer
@param vals: dictionary of fields value.
@return: new record set for hotel folio.
"""
Where is this coming from? The create method had @api.model in 11.0 Since 12.0 it is something like:
@api.model_create_multi
def create(self, vals_list):
When @api.model or @api.model_create_multi is used, the parameter self has no meaning at all. Certainly not a pointer to object. The @api.model on create method will end up being @api.model_create_single which in turn will result in logger warning of not overriding the create method in batch - see https://github.com/odoo/odoo/blob/f01b55636fecf2193ea4bd7551b5daef5bfbb12a/odoo/api.py#L369-L379 and https://github.com/odoo/odoo/blob/f01b55636fecf2193ea4bd7551b5daef5bfbb12a/odoo/api.py#L397-L404
hotel/models/hotel_folio.py
Outdated
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: |
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.
use variable name "room" instead of "rm" for better readability
hotel/models/hotel_folio.py
Outdated
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)]) |
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.
room_obj = hotel_room_obj.search([("product_id", "=", rm.id)]) | |
room_obj = hotel_room_obj.search([("product_id", "=", rm.id)], limit=1) |
hotel/models/hotel_folio.py
Outdated
rooms = self.env["hotel.room"].search( | ||
[("product_id", "=", line.order_line_id.product_id.id)] | ||
) | ||
folio_room_lines = self.env["folio.room.line"].search( |
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.
define self.env at first line on method outside for loop
hotel/models/hotel_folio.py
Outdated
""" | ||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
define all object at starting of the method
_inherit = "account.move" | ||
|
||
@api.model | ||
def create(self, vals): |
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
@api.model
def create(self, vals):
"Override the create method to link the account move with a hotel folio"
hotel/models/hotel_folio.py
Outdated
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Why removed the required=True?
hotel/views/hotel_folio.xml
Outdated
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure its working?
Migrated By RaishKhan Pathan