Skip to content
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

Open
wants to merge 145 commits into
base: 17.0
Choose a base branch
from
Open

[MIG] [17.0] hotel #207

wants to merge 145 commits into from

Conversation

Rajan-SCS
Copy link

Migrated By RaishKhan Pathan

Atul Makwana(SerpentCS) and others added 30 commits April 23, 2024 11:39
mymage and others added 21 commits April 23, 2024 11:39
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/
)
return fields.Datetime.to_string(checkout_date)

name = fields.Char("Folio Number", readonly=True, index=True, default="New")

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,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
"name": "Hotel Management",
"version": "17.0.1.0.0",
"author": "Odoo Community Association (OCA), Serpent Consulting \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"author": "Odoo Community Association (OCA), Serpent Consulting \
"author": "Odoo Community Association (OCA),
Serpent Consulting Services Pvt. Ltd.,

"name": "Hotel Management",
"version": "17.0.1.0.0",
"author": "Odoo Community Association (OCA), Serpent Consulting \
Services Pvt. Ltd., OpenERP SA",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Services Pvt. Ltd., OpenERP SA",
OpenERP SA",

_inherit = "account.move"

@api.model
def create(self, vals):

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"

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"
     

@param vals: dictionary of fields value.
@return: new record set for hotel folio.
"""
if not "service_line_ids" and "folio_id" in vals:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if not "service_line_ids" and "folio_id" in vals:
if "service_line_ids" not in vals and "folio_id" in vals:

Copy link

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

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:

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

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)])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
room_obj = hotel_room_obj.search([("product_id", "=", rm.id)])
room_obj = hotel_room_obj.search([("product_id", "=", rm.id)], limit=1)

rooms = self.env["hotel.room"].search(
[("product_id", "=", line.order_line_id.product_id.id)]
)
folio_room_lines = self.env["folio.room.line"].search(

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

"""
for line in self:
if line.order_line_id:
rooms = self.env["hotel.room"].search(

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):

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"
     

@@ -69,7 +68,6 @@ def _get_checkout_date(self):
)
checkout_date = fields.Datetime(
"Check Out",
required=True,

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?

@@ -100,7 +100,7 @@
/>
<field
name="checkout_date"
readonly="state != 'draft'"
readonly="state != 'draft' or 1"

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.