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

[FIX] pos_self_order_sale: check if the field really exists #161921

Conversation

Axel927
Copy link
Contributor

@Axel927 Axel927 commented Apr 15, 2024

When the module "sale_product_configurator" is not installed, an AttributeError is raised

Steps to reproduce:

  • Install the "point_of_sale" app, the "pos_self_order_sale" module and remove the "sale_product_configurator" module
  • Go to settings -> point of sale -> Self ordering: QR Menu -> preview web interface

Cause:
The field "optional_product_ids" is provided by the module "sale_product_configurator" which is not a dependency of this module

opw-3850421


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@robodoo
Copy link
Contributor

robodoo commented Apr 15, 2024

Pull request status dashboard.

@C3POdoo C3POdoo added the OE the report is linked to a support ticket (opw-...) label Apr 15, 2024
@@ -9,5 +9,9 @@ class ProductProduct(models.Model):
def _get_product_for_ui(self, pos_config):
self.ensure_one()
product = super()._get_product_for_ui(pos_config)

if "optional_product_ids" not in self.env["product.product"]:
Copy link
Member

Choose a reason for hiding this comment

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

could be better but I'm not sure

        product_configurator = self.env['ir.module.module']._get('sale_product_configurator')
        if product_configurator.state != 'installed':
            return product
``

Copy link
Contributor

@nle-odoo nle-odoo left a comment

Choose a reason for hiding this comment

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

looks good to me if there is no better way

the clean way to do this would be to have a bridge between pos_self_order and sale_product_configurator and do this override in that bridge but it would mean adding a new module (that I think needs an exception and so on)

the other nearly clean way would be to:

  • add a method _get_product_for_ui returning eg. empty dict in point_of_sale
  • transfer this override to pos_sale_product_configurator
  • modify the method in pos_self_order so it calls the new method from point_of_sale and extend the dictionary

but maybe it's too many changes not worth the hustle.

addons/pos_self_order_sale/models/product_product.py Outdated Show resolved Hide resolved
When the module "sale_product_configurator" is not installed, an AttributeError is raised

Steps to reproduce:

Install the "point_of_sale" app, the "pos_self_order_sale" module and remove the "sale_product_configurator" module
Go to settings -> point of sale -> Self ordering: QR Menu -> preview web interface
Cause:
The field "optional_product_ids" is provided by the module "sale_product_configurator" which is not a dependency of this module

opw-3850421
@Axel927 Axel927 force-pushed the 17.0-opw-3850421-pos_menu_no_attribute-axtr branch from dce8b99 to a1d697c Compare April 17, 2024 10:09
@Axel927 Axel927 marked this pull request as ready for review April 17, 2024 11:42
@C3POdoo C3POdoo requested review from a team and caburj and removed request for a team April 17, 2024 11:44
Copy link
Contributor

@caburj caburj left a comment

Choose a reason for hiding this comment

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

robodoo r+

@robodoo robodoo closed this in 33bad6e Apr 23, 2024
willylohws pushed a commit to willylohws/odoo that referenced this pull request May 1, 2024
When the module "sale_product_configurator" is not installed, an AttributeError is raised

Steps to reproduce:

Install the "point_of_sale" app, the "pos_self_order_sale" module and remove the "sale_product_configurator" module
Go to settings -> point of sale -> Self ordering: QR Menu -> preview web interface
Cause:
The field "optional_product_ids" is provided by the module "sale_product_configurator" which is not a dependency of this module

opw-3850421

closes odoo#161921

Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
@fw-bot fw-bot deleted the 17.0-opw-3850421-pos_menu_no_attribute-axtr branch May 7, 2024 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OE the report is linked to a support ticket (opw-...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants