diff --git a/.copier-answers.yml b/.copier-answers.yml index 7671798888..2cd562b036 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,8 +1,9 @@ # Do NOT update manually; changes here will be overwritten by Copier -_commit: v1.21.1 +_commit: v1.29 _src_path: gh:oca/oca-addons-repo-template ci: GitHub convert_readme_fragments_to_markdown: false +enable_checklog_odoo: false generate_requirements_txt: true github_check_license: true github_ci_extra_env: {} diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 6578458712..afd7524ef0 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -13,8 +13,8 @@ jobs: pre-commit: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: "3.11" - name: Get python version diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3bf18e843c..5d0f95283c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest name: Detect unreleased dependencies steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: | for reqfile in requirements.txt test-requirements.txt ; do if [ -f ${reqfile} ] ; then @@ -50,7 +50,7 @@ jobs: ports: - 5432:5432 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: persist-credentials: false - name: Install addons and dependencies diff --git a/.gitignore b/.gitignore index 0090721f5d..6ec07a054b 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,19 @@ var/ *.egg *.eggs +# Windows installers +*.msi + +# Debian packages +*.deb + +# Redhat packages +*.rpm + +# MacOS packages +*.dmg +*.pkg + # Installer logs pip-log.txt pip-delete-this-directory.txt diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d3eef51355..d9739fad44 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ exclude: | # Files and folders generated by bots, to avoid loops ^setup/|/static/description/index\.html$| # We don't want to mess with tool-generated files - .svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/| + .svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/|^eslint.config.cjs|^prettier.config.cjs| # Maybe reactivate this when all README files include prettier ignore tags? ^README\.md$| # Library files can have extraneous formatting (even minimized) @@ -39,7 +39,7 @@ repos: language: fail files: '[a-zA-Z0-9_]*/i18n/en\.po$' - repo: https://github.com/oca/maintainer-tools - rev: 9a170331575a265c092ee6b24b845ec508e8ef75 + rev: d5fab7ee87fceee858a3d01048c78a548974d935 hooks: # update the NOT INSTALLABLE ADDONS section above - id: oca-update-pre-commit-excluded-addons @@ -58,6 +58,8 @@ repos: hooks: - id: oca-checks-odoo-module - id: oca-checks-po + args: + - --disable=po-pretty-format - repo: https://github.com/myint/autoflake rev: v1.6.1 hooks: @@ -73,25 +75,35 @@ repos: rev: 22.8.0 hooks: - id: black - - repo: https://github.com/pre-commit/mirrors-prettier - rev: v2.7.1 + - repo: local hooks: - id: prettier name: prettier (with plugin-xml) + entry: prettier + args: + - --write + - --list-different + - --ignore-unknown + types: [text] + files: \.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|xml|yaml|yml)$ + language: node additional_dependencies: - "prettier@2.7.1" - "@prettier/plugin-xml@2.2.0" - args: - - --plugin=@prettier/plugin-xml - files: \.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|xml|yaml|yml)$ - - repo: https://github.com/pre-commit/mirrors-eslint - rev: v8.24.0 + - repo: local hooks: - id: eslint - verbose: true + name: eslint + entry: eslint args: - --color - --fix + verbose: true + types: [javascript] + language: node + additional_dependencies: + - "eslint@8.24.0" + - "eslint-plugin-jsdoc@" - repo: https://github.com/pre-commit/pre-commit-hooks rev: v5.0.0 hooks: diff --git a/multi_pms_properties/models.py b/multi_pms_properties/models.py index 25a475e43d..2409834244 100644 --- a/multi_pms_properties/models.py +++ b/multi_pms_properties/models.py @@ -21,13 +21,13 @@ def _valid_field_parameter(self, field, name): @api.model_create_multi def create(self, vals_list): - records = super(BaseModel, self).create(vals_list) + records = super().create(vals_list) if self._check_pms_properties_auto: records._check_pms_properties() return records def write(self, vals): - res = super(BaseModel, self).write(vals) + res = super().write(vals) check_pms_properties = False for fname in vals: field = self._fields.get(fname) diff --git a/multi_pms_properties/tests/test_multi_pms_properties.py b/multi_pms_properties/tests/test_multi_pms_properties.py index 10f81e0226..f19a3488ab 100644 --- a/multi_pms_properties/tests/test_multi_pms_properties.py +++ b/multi_pms_properties/tests/test_multi_pms_properties.py @@ -12,10 +12,10 @@ @common.tagged("-at_install", "post_install") -class TestMultiPMSProperties(common.SavepointCase): +class TestMultiPMSProperties(common.TransactionCase): @classmethod def setUpClass(cls): - super(TestMultiPMSProperties, cls).setUpClass() + super().setUpClass() model_classes = [ParentTester, ChildTester] setup_test_model(cls.env, model_classes) for mdl_cls in model_classes: diff --git a/pms/__manifest__.py b/pms/__manifest__.py index 58fcb9f632..8fdf66d512 100644 --- a/pms/__manifest__.py +++ b/pms/__manifest__.py @@ -92,7 +92,6 @@ "views/res_company_views.xml", "views/traveller_report_template.xml", "wizards/wizard_split_join_swap_reservation.xml", - "views/precheckin_portal_templates.xml", "wizards/wizard_massive_changes.xml", "wizards/wizard_advanced_filters.xml", "wizards/folio_payment_link_views.xml", diff --git a/pms/init_hook.py b/pms/init_hook.py index 5592fe58f7..ab344e799c 100644 --- a/pms/init_hook.py +++ b/pms/init_hook.py @@ -3,14 +3,13 @@ def pre_init_hook(cr): - with Environment.manage(): - env = Environment(cr, SUPERUSER_ID, {}) - ResConfig = env["res.config.settings"] - default_values = ResConfig.default_get(list(ResConfig.fields_get())) - default_values.update( - {"group_product_pricelist": True, "group_sale_pricelist": True} - ) - ResConfig.sudo().create(default_values).execute() - env["ir.config_parameter"].sudo().set_param( - "product.product_pricelist_setting", "advanced" - ) + env = Environment(cr, SUPERUSER_ID, {}) + ResConfig = env["res.config.settings"] + default_values = ResConfig.default_get(list(ResConfig.fields_get())) + default_values.update( + {"group_product_pricelist": True, "group_sale_pricelist": True} + ) + ResConfig.sudo().create(default_values).execute() + env["ir.config_parameter"].sudo().set_param( + "product.product_pricelist_setting", "advanced" + ) diff --git a/pms/models/account_analytic_line.py b/pms/models/account_analytic_line.py index cdaa2ad88f..6a18ca011d 100644 --- a/pms/models/account_analytic_line.py +++ b/pms/models/account_analytic_line.py @@ -1,4 +1,4 @@ -from odoo import fields, models, api +from odoo import api, fields, models class AccountAnalyticDistribution(models.Model): @@ -14,15 +14,23 @@ class AccountAnalyticDistribution(models.Model): @api.model def default_get(self, fields): res = super().default_get(fields) - if "pms_property_id" in fields and self.env.context.get("default_analytic_distribution"): + if "pms_property_id" in fields and self.env.context.get( + "default_analytic_distribution" + ): distribution = self.env.context["default_analytic_distribution"] if distribution.keys(): property_ids = self.env["pms.property"].search( - [("analytic_account_id", "in", [int(x) for x in distribution.keys()])] + [ + ( + "analytic_account_id", + "in", + [int(x) for x in distribution.keys()], + ) + ] ) if property_ids: res["pms_property_id"] = property_ids[0].id - res['company_id'] = property_ids[0].company_id.id + res["company_id"] = property_ids[0].company_id.id return res def _get_distribution(self, vals): diff --git a/pms/models/account_bank_statement.py b/pms/models/account_bank_statement.py index 2c2eecd5fd..c50f812e71 100644 --- a/pms/models/account_bank_statement.py +++ b/pms/models/account_bank_statement.py @@ -21,7 +21,6 @@ class AccountBankStatement(models.Model): check_pms_properties=True, ) - # pylint: disable=W8110 @api.depends("journal_id") def _compute_pms_property_id(self): for record in self: @@ -29,22 +28,3 @@ def _compute_pms_property_id(self): record.pms_property_id = record.journal_id.pms_property_ids[0] elif not record.pms_property_id: record.pms_property_id = False - - def button_post(self): - """ - Override the default method to add autoreconcile payments and statement lines - """ - lines_of_moves_to_post = self.line_ids.filtered( - lambda line: line.move_id.state != "posted" - ) - super(AccountBankStatement, self).button_post() - for line in lines_of_moves_to_post: - payment_move_line = line._get_payment_move_lines_to_reconcile() - statement_move_line = line.move_id.line_ids.filtered( - lambda line: line.account_id.reconcile - or line.account_id == line.journal_id.suspense_account_id - ) - if payment_move_line and statement_move_line: - statement_move_line.account_id = payment_move_line.account_id - lines_to_reconcile = payment_move_line + statement_move_line - lines_to_reconcile.reconcile() diff --git a/pms/models/account_bank_statement_line.py b/pms/models/account_bank_statement_line.py index 576fe52d54..d44db048c0 100644 --- a/pms/models/account_bank_statement_line.py +++ b/pms/models/account_bank_statement_line.py @@ -37,9 +37,7 @@ class AccountBankStatementLine(models.Model): @api.model def _prepare_move_line_default_vals(self, counterpart_account_id=None): - line_vals_list = super( - AccountBankStatementLine, self - )._prepare_move_line_default_vals(counterpart_account_id) + line_vals_list = super()._prepare_move_line_default_vals(counterpart_account_id) if self.folio_ids: for line in line_vals_list: line.update( @@ -49,36 +47,6 @@ def _prepare_move_line_default_vals(self, counterpart_account_id=None): ) return line_vals_list - def _get_payment_move_lines_to_reconcile(self): - self.ensure_one() - payment_move_line = False - folio_ids = self.folio_ids and self.folio_ids.ids or False - domain = [("move_id.folio_ids", "in", folio_ids)] if folio_ids else [] - domain.extend( - [ - ("move_id.ref", "=", self.payment_ref), - ("date", "=", self.date), - ("reconciled", "=", False), - "|", - ( - "account_id", - "=", - self.journal_id.payment_debit_account_id.id, - ), - ( - "account_id", - "=", - self.journal_id.payment_credit_account_id.id, - ), - ("journal_id", "=", self.journal_id.id), - ] - ) - to_reconcile_move_lines = self.env["account.move.line"].search(domain) - # We try to reconcile by amount - for record in to_reconcile_move_lines: - payment_move_line = record if record.balance == self.amount else False - return payment_move_line - def _create_counterpart_and_new_aml( self, counterpart_moves, counterpart_aml_dicts, new_aml_dicts ): diff --git a/pms/models/account_move_line.py b/pms/models/account_move_line.py index e49198bc61..d7a81805b5 100644 --- a/pms/models/account_move_line.py +++ b/pms/models/account_move_line.py @@ -8,8 +8,6 @@ class AccountMoveLine(models.Model): _inherit = "account.move.line" _check_pms_properties_auto = True - # Fields declaration - # TODO: REVIEW why not a Many2one? name = fields.Char( compute="_compute_name", store=True, @@ -59,7 +57,6 @@ class AccountMoveLine(models.Model): ) move_id = fields.Many2one(check_pms_properties=True) - # pylint: disable=W8110 @api.depends("account_id", "partner_id", "product_id", "pms_property_id") def _compute_analytic_distribution(self): properties = self.mapped("pms_property_id") @@ -70,6 +67,7 @@ def _compute_analytic_distribution(self): super( AccountMoveLine, records.with_context(pms_property_id=pms_property.id) )._compute_analytic_distribution() + return @api.depends("move_id.payment_reference", "quantity") def _compute_name(self): @@ -130,7 +128,7 @@ def reconcile(self): Reconcile the account move """ # Update partner in payments and statement lines - res = super(AccountMoveLine, self).reconcile() + res = super().reconcile() for record in self: if record.payment_id: old_payment_partner = record.payment_id.partner_id @@ -145,10 +143,11 @@ def reconcile(self): if old_payment_partner: record.payment_id.message_post( body=_( - f""" - Partner modify automatically from invoice: - {old_payment_partner.name} to {new_payment_partner.name} - """ + "Partner modify automatically from" + " invoice: {old_partner} to {new_partner}" + ).format( + old_partner=old_payment_partner.name, + new_partner=new_payment_partner.name, ) ) if record.statement_line_id: @@ -164,10 +163,11 @@ def reconcile(self): if old_statement_partner: record.statement_line_id.message_post( body=_( - f""" - Partner modify automatically from invoice: - {old_statement_partner.name} to {new_payment_partner.name} - """ + "Partner modify automatically from " + "invoice: {old_partner} to {new_partner}" + ).format( + old_partner=old_statement_partner.name, + new_partner=new_payment_partner.name, ) ) return res @@ -176,7 +176,7 @@ def _get_lock_date_protected_fields(self): """Inherited from account.move.line to avoid to lock partner_id in reconciliation_fnames """ - lock_types = super(AccountMoveLine, self)._get_lock_date_protected_fields() + lock_types = super()._get_lock_date_protected_fields() reconciliation_fnames = lock_types.get("reconciliation", []) # Remove partner_id from reconciliation_fnames # because it is not a protected field diff --git a/pms/models/account_payment.py b/pms/models/account_payment.py index 380d1630a0..a27ace4964 100644 --- a/pms/models/account_payment.py +++ b/pms/models/account_payment.py @@ -83,9 +83,7 @@ def _compute_folio_ids(self): rec.folio_ids = False def _prepare_move_line_default_vals(self, write_off_line_vals=None): - line_vals_list = super(AccountPayment, self)._prepare_move_line_default_vals( - write_off_line_vals - ) + line_vals_list = super()._prepare_move_line_default_vals(write_off_line_vals) if self.folio_ids: for line in line_vals_list: line.update( @@ -97,7 +95,7 @@ def _prepare_move_line_default_vals(self, write_off_line_vals=None): # pylint: disable=W8110 def _synchronize_to_moves(self, changed_fields): - super(AccountPayment, self)._synchronize_to_moves(changed_fields) + super()._synchronize_to_moves(changed_fields) if "folio_ids" in changed_fields: for pay in self.with_context(skip_account_move_synchronization=True): pay.move_id.write( @@ -124,7 +122,7 @@ def action_draft(self): ) else: downpayment_invoices.unlink() - return super(AccountPayment, self).action_draft() + return super().action_draft() @api.model def auto_invoice_downpayments(self, offset=0): diff --git a/pms/models/ir_pms_property.py b/pms/models/ir_pms_property.py index 97250bbfb8..954c237933 100644 --- a/pms/models/ir_pms_property.py +++ b/pms/models/ir_pms_property.py @@ -136,4 +136,4 @@ def create(self, vals_list): "field_id": field_id.id, } ) - return super(IrPmsProperty, self).create(vals) + return super().create(vals) diff --git a/pms/models/mail_compose_message.py b/pms/models/mail_compose_message.py index 24af8478ad..ba5c03e792 100644 --- a/pms/models/mail_compose_message.py +++ b/pms/models/mail_compose_message.py @@ -8,7 +8,7 @@ class MailComposeMessage(models.TransientModel): _inherit = "mail.compose.message" def send_mail(self, auto_commit=False): - res = super(MailComposeMessage, self).send_mail(auto_commit=auto_commit) + res = super().send_mail(auto_commit=auto_commit) if ( self._context.get("default_model") == "pms.folio" and self._context.get("active_model") == "pms.reservation" diff --git a/pms/models/pms_board_service_line.py b/pms/models/pms_board_service_line.py index 09cfa93cc9..7e314c68a4 100644 --- a/pms/models/pms_board_service_line.py +++ b/pms/models/pms_board_service_line.py @@ -75,7 +75,7 @@ def create(self, vals_list): "pms_property_ids": properties, } ) - return super(PmsBoardServiceLine, self).create(vals_list) + return super().create(vals_list) def write(self, vals): properties = False @@ -90,7 +90,7 @@ def write(self, vals): "pms_property_ids": properties, } ) - return super(PmsBoardServiceLine, self).write(vals) + return super().write(vals) @api.constrains("adults", "children") def _check_adults_children(self): diff --git a/pms/models/pms_board_service_room_type.py b/pms/models/pms_board_service_room_type.py index 2338a99dc0..4155574a9f 100644 --- a/pms/models/pms_board_service_room_type.py +++ b/pms/models/pms_board_service_room_type.py @@ -132,14 +132,14 @@ def create(self, vals_list): vals["pms_board_service_id"] ) ) - return super(PmsBoardServiceRoomType, self).create(vals_list) + return super().create(vals_list) def write(self, vals): if "pms_board_service_id" in vals and "board_service_line_ids" not in vals: vals.update( self.prepare_board_service_reservation_ids(vals["pms_board_service_id"]) ) - return super(PmsBoardServiceRoomType, self).write(vals) + return super().write(vals) @api.model def prepare_board_service_reservation_ids(self, board_service_id): diff --git a/pms/models/pms_checkin_partner.py b/pms/models/pms_checkin_partner.py index 3e9f0394c7..e450b36629 100644 --- a/pms/models/pms_checkin_partner.py +++ b/pms/models/pms_checkin_partner.py @@ -620,7 +620,7 @@ def _compute_sign_on(self): # pylint: disable=W8110 def _compute_access_url(self): - super(PmsCheckinPartner, self)._compute_access_url() + super()._compute_access_url() for checkin in self: checkin.access_url = "/my/folios/%s/reservations/%s/checkins/%s" % ( checkin.folio_id.id, @@ -787,7 +787,7 @@ def create(self, vals_list): if len(reservation.checkin_partner_ids) < ( reservation.adults + reservation.children ): - records += super(PmsCheckinPartner, self).create(vals) + records += super().create(vals) elif len(dummy_checkins) > 0: dummy_checkins[0].write(vals) records += dummy_checkins[0] diff --git a/pms/models/pms_property.py b/pms/models/pms_property.py index 7846af0eac..ab22d6703c 100644 --- a/pms/models/pms_property.py +++ b/pms/models/pms_property.py @@ -263,7 +263,6 @@ def _compute_free_room_ids(self): current_lines = self.env.context.get("current_lines", False) if current_lines and not isinstance(current_lines, list): current_lines = [current_lines] - pricelist_id = self.env.context.get("pricelist_id", False) room_type_id = self.env.context.get("room_type_id", False) class_id = self._context.get("class_id", False) diff --git a/pms/models/pms_reservation.py b/pms/models/pms_reservation.py index 4c22084ca8..5cd20fc40a 100644 --- a/pms/models/pms_reservation.py +++ b/pms/models/pms_reservation.py @@ -1111,7 +1111,7 @@ def _compute_ready_for_checkin(self): # pylint: disable=W8110 def _compute_access_url(self): - super(PmsReservation, self)._compute_access_url() + super()._compute_access_url() for reservation in self: reservation.access_url = "/my/reservations/%s" % (reservation.id) @@ -1162,7 +1162,7 @@ def _compute_checkout(self): # pylint: disable=W8110 def _compute_precheckin_url(self): - super(PmsReservation, self)._compute_access_url() + super()._compute_access_url() for reservation in self: reservation.access_url = "/my/reservations/precheckin/%s" % (reservation.id) @@ -1990,9 +1990,7 @@ def name_search(self, name="", args=None, operator="ilike", limit=100): ("folio_id.name", operator, name), ("preferred_room_id.name", operator, name), ] - return super(PmsReservation, self).name_search( - name="", args=args, operator="ilike", limit=limit - ) + return super().name_search(name="", args=args, operator="ilike", limit=limit) def name_get(self): result = [] @@ -2073,7 +2071,7 @@ def create(self, vals_list): if "state" in vals: reservation_state = vals["state"] vals.pop("state") - records = super(PmsReservation, self).create(vals_list) + records = super().create(vals_list) for record in records: record._check_capacity() if ( @@ -2143,7 +2141,7 @@ def write(self, vals): folios_to_update_channel = self.get_folios_to_update_channel(vals) lines_to_update_channel = self.get_lines_to_update_channel(vals) services_to_update_channel = self.get_services_to_update_channel(vals) - res = super(PmsReservation, self).write(vals) + res = super().write(vals) if folios_to_update_channel: folios_to_update_channel.sale_channel_origin_id = vals[ "sale_channel_origin_id" diff --git a/pms/models/pms_room.py b/pms/models/pms_room.py index 64e0390f0d..a2ab9edcda 100644 --- a/pms/models/pms_room.py +++ b/pms/models/pms_room.py @@ -311,7 +311,7 @@ def create(self, vals_list): vals.update({"short_name": short_name}) else: vals.update({"short_name": vals["name"]}) - return super(PmsRoom, self).create(vals_list) + return super().create(vals_list) def write(self, vals): if vals.get("name") and not vals.get("short_name"): @@ -320,7 +320,7 @@ def write(self, vals): vals.update({"short_name": short_name}) else: vals.update({"short_name": vals["name"]}) - return super(PmsRoom, self).write(vals) + return super().write(vals) def calculate_short_name(self, vals): short_name = vals["name"][:2].upper() diff --git a/pms/models/pms_service.py b/pms/models/pms_service.py index b24ed37140..8c487e74c4 100644 --- a/pms/models/pms_service.py +++ b/pms/models/pms_service.py @@ -552,9 +552,7 @@ def name_search(self, name="", args=None, operator="ilike", limit=100): ("reservation_id.name", operator, name), ("name", operator, name), ] - return super(PmsService, self).name_search( - name="", args=args, operator="ilike", limit=limit - ) + return super().name_search(name="", args=args, operator="ilike", limit=limit) def _get_display_price(self, product): folio = self.folio_id @@ -638,14 +636,14 @@ def create(self, vals_list): folio = self.env["pms.folio"].browse(vals["folio_id"]) if folio.sale_channel_origin_id: vals["sale_channel_origin_id"] = folio.sale_channel_origin_id.id - return super(PmsService, self).create(vals_list) + return super().create(vals_list) def write(self, vals): folios_to_update_channel = self.env["pms.folio"] lines_to_update_channel = self.env["pms.service.line"] if "sale_channel_origin_id" in vals: folios_to_update_channel = self.get_folios_to_update_channel(vals) - res = super(PmsService, self).write(vals) + res = super().write(vals) if folios_to_update_channel: folios_to_update_channel.sale_channel_origin_id = vals[ "sale_channel_origin_id" diff --git a/pms/models/product_pricelist.py b/pms/models/product_pricelist.py index 04f4137ce8..8267a69138 100644 --- a/pms/models/product_pricelist.py +++ b/pms/models/product_pricelist.py @@ -73,9 +73,7 @@ class ProductPricelist(models.Model): ) def _get_applicable_rules_domain(self, products, date, **kwargs): - domain = super(ProductPricelist, self)._get_applicable_rules_domain( - products, date, **kwargs - ) + domain = super()._get_applicable_rules_domain(products, date, **kwargs) consumption_date = kwargs.get("consumption_date") if consumption_date: domain.extend( @@ -105,7 +103,7 @@ def _compute_price_rule(self, products, qty, uom=None, date=False, **kwargs): """ consumption_date = kwargs.get("consumption_date") if not consumption_date: - return super(ProductPricelist, self)._compute_price_rule( + return super()._compute_price_rule( products, qty, uom=uom, date=date, **kwargs ) self.ensure_one() @@ -159,81 +157,6 @@ def _compute_price_rule(self, products, qty, uom=None, date=False, **kwargs): return results - # V14.0 - # def _compute_price_rule_get_items( - # self, products_qty_partner, date, uom_id, prod_tmpl_ids, prod_ids, categ_ids - # ): - # board_service = True if self._context.get("board_service") else False - # if ( - # "property" in self._context - # and self._context["property"] - # and self._context.get("consumption_date") - # ): - # self.env.cr.execute( - # """ - # SELECT item.id - # FROM product_pricelist_item item - # LEFT JOIN product_category categ - # ON item.categ_id = categ.id - # LEFT JOIN product_pricelist_pms_property_rel cab - # ON item.pricelist_id = cab.product_pricelist_id - # LEFT JOIN product_pricelist_item_pms_property_rel lin - # ON item.id = lin.product_pricelist_item_id - # WHERE (lin.pms_property_id = %s OR lin.pms_property_id IS NULL) - # AND (cab.pms_property_id = %s OR cab.pms_property_id IS NULL) - # AND (item.product_tmpl_id IS NULL - # OR item.product_tmpl_id = ANY(%s)) - # AND (item.product_id IS NULL OR item.product_id = ANY(%s)) - # AND (item.categ_id IS NULL OR item.categ_id = ANY(%s)) - # AND (item.pricelist_id = %s) - # AND (item.date_start IS NULL OR item.date_start <=%s) - # AND (item.date_end IS NULL OR item.date_end >=%s) - # AND (item.date_start_consumption IS NULL - # OR item.date_start_consumption <=%s) - # AND (item.date_end_consumption IS NULL - # OR item.date_end_consumption >=%s) - # GROUP BY item.id - # ORDER BY item.applied_on, - # /* REVIEW: priotrity date sale / date consumption */ - # item.date_end - item.date_start ASC, - # item.date_end_consumption - item.date_start_consumption ASC, - # NULLIF((SELECT COUNT(1) - # FROM product_pricelist_item_pms_property_rel l - # WHERE item.id = l.product_pricelist_item_id) - # + (SELECT COUNT(1) - # FROM product_pricelist_pms_property_rel c - # WHERE item.pricelist_id = c.product_pricelist_id),0) - # NULLS LAST, - # item.id DESC; - # """, - # ( - # self._context["property"], - # self._context["property"], - # prod_tmpl_ids, - # prod_ids, - # categ_ids, - # self.id, - # date, - # date, - # self._context["consumption_date"], - # self._context["consumption_date"], - # ), - # ) - # item_ids = [x[0] for x in self.env.cr.fetchall()] - # items = self.env["product.pricelist.item"].browse(item_ids) - # if board_service: - # items = items.filtered( - # lambda x: x.board_service_room_type_id.id - # == self._context.get("board_service") - # ) - # else: - # items = items.filtered(lambda x: not x.board_service_room_type_id.id) - # else: - # items = super(ProductPricelist, self)._compute_price_rule_get_items( - # products_qty_partner, date, uom_id, prod_tmpl_ids, prod_ids, categ_ids - # ) - # return items - @api.constrains("is_pms_available", "availability_plan_id") def _check_is_pms_available(self): for record in self: diff --git a/pms/models/product_pricelist_item.py b/pms/models/product_pricelist_item.py index 1b26a9a46a..33c79273fc 100644 --- a/pms/models/product_pricelist_item.py +++ b/pms/models/product_pricelist_item.py @@ -5,6 +5,9 @@ class ProductPricelistItem(models.Model): _inherit = "product.pricelist.item" + _order = ( + "applied_on, min_quantity desc, categ_id desc, has_properties desc, id desc" + ) _check_pms_properties_auto = True pms_property_ids = fields.Many2many( @@ -40,10 +43,7 @@ class ProductPricelistItem(models.Model): check_pms_properties=True, ) product_id = fields.Many2one( - string="Product", - help="Product associated with the item", - index=True, - check_pms_properties=True, + string="Product", help="Product associated with the item", index=True ) product_tmpl_id = fields.Many2one( string="Product Template", @@ -66,6 +66,13 @@ class ProductPricelistItem(models.Model): readonly=False, compute="_compute_allowed_board_service_room_type_ids", ) + has_properties = fields.Boolean(compute="_compute_has_properties", store=True) + + @api.depends("pms_property_ids") + def _compute_has_properties(self): + """Compute if the pricelist has properties associated.""" + for record in self: + record.has_properties = len(record.pms_property_ids) != 0 @api.depends("board_service_room_type_id") def _compute_allowed_board_service_product_ids(self): diff --git a/pms/models/product_product.py b/pms/models/product_product.py index 70ae1e7581..51e4cf4fba 100644 --- a/pms/models/product_product.py +++ b/pms/models/product_product.py @@ -21,7 +21,7 @@ class ProductProduct(models.Model): @api.depends_context("consumption_date", "board_service_line_id") # pylint: disable=W8110 def _compute_product_price(self): - super(ProductProduct, self)._compute_product_price() + super()._compute_product_price() @api.depends_context("consumption_date", "board_service_line_id") def _compute_board_price(self): @@ -56,6 +56,4 @@ def price_compute( ): if self._context.get("board_service_line_id"): price_type = "board_price" - return super(ProductProduct, self).price_compute( - price_type, uom, currency, company, date - ) + return super().price_compute(price_type, uom, currency, company, date) diff --git a/pms/models/product_template.py b/pms/models/product_template.py index 3fa4a39e7e..c15478d9f8 100644 --- a/pms/models/product_template.py +++ b/pms/models/product_template.py @@ -130,7 +130,7 @@ def write(self, vals): vals["is_pms_available"] = True vals["per_day"] = True vals["consumed_on"] = "before" - return super(ProductTemplate, self).write(vals) + return super().write(vals) def _get_mmdd_selection(self): lang = self.env.lang or "en_US" @@ -152,7 +152,7 @@ def _get_mmdd_selection(self): options = [] for month in range(1, 13): for day in range(1, days_by_month[month] + 1): - mmdd = f"{month:02d}-{day:02d}" + mmdd = "{month:02d}-{day:02d}".format(month=month, day=day) dt = date(2024, month, day) # Dummy year label = babel.dates.format_date(dt, format="d MMMM", locale=lang) options.append((mmdd, label.capitalize())) diff --git a/pms/models/res_partner.py b/pms/models/res_partner.py index d7d314d661..85dd8a4577 100644 --- a/pms/models/res_partner.py +++ b/pms/models/res_partner.py @@ -751,7 +751,7 @@ def create(self, vals_list): check_missing_document = self._check_document_partner_required(vals) if check_missing_document: raise ValidationError(_("A document identification is required")) - return super(ResPartner, self).create(vals_list) + return super().create(vals_list) def write(self, vals): check_missing_document = self._check_document_partner_required( diff --git a/pms/security/ir.model.access.csv b/pms/security/ir.model.access.csv index 9500e98e45..3f9e79aa4a 100644 --- a/pms/security/ir.model.access.csv +++ b/pms/security/ir.model.access.csv @@ -55,7 +55,6 @@ user_access_pms_massive_changes_wizard,user_access_pms_massive_changes_wizard,mo user_access_pms_advanced_filters_wizard,user_access_pms_advanced_filters_wizard,model_pms_advanced_filters_wizard,pms.group_pms_user,1,1,1,1 user_access_pms_booking_engine,user_access_pms_booking_engine,model_pms_booking_engine,pms.group_pms_user,1,1,1,1 user_access_pms_folio_availability_wizard,user_access_pms_folio_availability_wizard,model_pms_folio_availability_wizard,pms.group_pms_user,1,1,1,1 -user_access_pms_num_rooms_selection,user_access_pms_num_rooms_selection,model_pms_num_rooms_selection,pms.group_pms_user,1,1,1,1 user_access_pms_folio_sale_line,user_access_pms_folio_sale_line,model_folio_sale_line,pms.group_pms_user,1,1,1,1 user_access_folio_make_invoice_advance,user_access_folio_make_invoice_advance,model_folio_advance_payment_inv,pms.group_pms_user,1,1,1,1 user_access_wizard_payment_folio,user_access_wizard_payment_folio,model_wizard_payment_folio,pms.group_pms_user,1,1,1,1 diff --git a/pms/static/src/js/folio_portal_sidebar.js b/pms/static/src/js/folio_portal_sidebar.js deleted file mode 100644 index c73bb61efd..0000000000 --- a/pms/static/src/js/folio_portal_sidebar.js +++ /dev/null @@ -1,150 +0,0 @@ -odoo.define("account.FolioPortalSidebar", function (require) { - "use strict"; - - const dom = require("web.dom"); - var publicWidget = require("web.public.widget"); - var PortalSidebar = require("portal.PortalSidebar"); - var utils = require("web.utils"); - - publicWidget.registry.FolioPortalSidebar = PortalSidebar.extend({ - selector: ".o_portal_folio_sidebar", - - /** - * @class - */ - init: function (parent, options) { - this._super.apply(this, arguments); - this.authorizedTextTag = ["em", "b", "i", "u"]; - this.spyWatched = $('body[data-target=".navspy"]'); - }, - /** - * @override - */ - start: function () { - var def = this._super.apply(this, arguments); - var $spyWatcheElement = this.$el.find('[data-id="portal_sidebar"]'); - this._setElementId($spyWatcheElement); - // Nav Menu ScrollSpy - this._generateMenu(); - // After signature, automatically open the popup for payment - if ( - $.bbq.getState("allow_payment") === "yes" && - this.$("#o_sale_portal_paynow").length - ) { - this.el.querySelector("#o_sale_portal_paynow").click(); - $.bbq.removeState("allow_payment"); - } - return def; - }, - - // -------------------------------------------------------------------------- - // Private - // --------------------------------------------------------------------------- - - /** - * create an unique id and added as a attribute of spyWatched element - * - * @private - * @param {String} prefix - * @param {Object} $el - * - */ - _setElementId: function (prefix, $el) { - var id = _.uniqueId(prefix); - this.spyWatched.find($el).attr("id", id); - return id; - }, - /** - * Generate the new spy menu - * - * @private - * - */ - _generateMenu: function () { - var self = this, - lastLI = false, - lastUL = null, - $bsSidenav = this.$el.find(".bs-sidenav"); - - $( - "#quote_content [id^=quote_header_], #quote_content [id^=quote_]", - this.spyWatched - ).attr("id", ""); - _.each( - this.spyWatched.find("#quote_content h2, #quote_content h3"), - function (el) { - var id, text; - switch (el.tagName.toLowerCase()) { - case "h2": - id = self._setElementId("quote_header_", el); - text = self._extractText($(el)); - if (!text) { - break; - } - lastLI = $("