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

[15.0][FIX] product_supplierinfo_for_customer_sale #3282

Merged

Conversation

imlopes
Copy link

@imlopes imlopes commented Aug 21, 2024

When adding a new line on sale.order.line we have a traceback :

RPC_ERROR
Odoo Server Error
Traceback (most recent call last):
  File "/odoo/src/odoo/models.py", line 5240, in ensure_one
    _id, = self._ids
ValueError: not enough values to unpack (expected 1, got 0)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/odoo/src/odoo/addons/base/models/ir_http.py", line 242, in _dispatch
    result = request.dispatch()
  File "/odoo/src/odoo/http.py", line 702, in dispatch
    result = self._call_function(**self.params)
  File "/odoo/src/odoo/http.py", line 368, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/odoo/src/odoo/service/model.py", line 94, in wrapper
    return f(dbname, *args, **kwargs)
  File "/odoo/src/odoo/http.py", line 357, in checked_call
    result = self.endpoint(*a, **kw)
  File "/odoo/src/odoo/http.py", line 925, in call
    return self.method(*args, **kw)
  File "/odoo/src/odoo/http.py", line 546, in response_wrap
    response = f(*args, **kw)
  File "/odoo/src/addons/web/controllers/main.py", line 1324, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/odoo/src/addons/web/controllers/main.py", line 1316, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/odoo/src/odoo/api.py", line 471, in call_kw
    result = _call_kw_multi(method, model, args, kwargs)
  File "/odoo/src/odoo/api.py", line 456, in _call_kw_multi
    result = method(recs, *args, **kwargs)
  File "/odoo/src/odoo/models.py", line 6523, in onchange
    record._onchange_eval(name, field_onchange[name], result)
  File "/odoo/src/odoo/models.py", line 6256, in _onchange_eval
    method_res = method(self)
  File "/odoo/external-src/enterprise/sale_renting/models/sale.py", line 195, in _onchange_rental_info
    self._update_description()
  File "/odoo/external-src/sale-workflow/product_supplierinfo_for_customer_sale/models/sale_order_line.py", line 38, in _update_description
    customerinfo = self.product_id._select_customerinfo(
  File "/odoo/external-src/product-attribute/product_supplierinfo_for_customer/models/product_product.py", line 128, in _select_customerinfo
    domain = self._prepare_domain_customerinfo(params)
  File "/odoo/external-src/product-attribute/product_supplierinfo_for_customer/models/product_product.py", line 107, in _prepare_domain_customerinfo
    self.ensure_one()
  File "/odoo/src/odoo/models.py", line 5243, in ensure_one
    raise ValueError("Expected singleton: %s" % self)
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/odoo/src/odoo/http.py", line 658, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/odoo/src/odoo/http.py", line 301, in _handle_exception
    raise exception.with_traceback(None) from new_cause
ValueError: Expected singleton: product.product()

This error is linked to the fact that an EE module (sale_renting) calls _onchange_rental_info and we have no product_id at this point and so, this is not compatible with :

    def _prepare_domain_customerinfo(self, params):
        self.ensure_one()

@imlopes imlopes force-pushed the 15.0-fix-product_supplierinfo_for_customer_sale branch from 4c75b25 to c5c4e79 Compare August 21, 2024 20:16
@rousseldenis rousseldenis added this to the 15.0 milestone Aug 22, 2024
Copy link
Contributor

@rousseldenis rousseldenis left a comment

Choose a reason for hiding this comment

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

Code review.

Seems fair

@imlopes imlopes force-pushed the 15.0-fix-product_supplierinfo_for_customer_sale branch from c5c4e79 to d479b81 Compare August 22, 2024 11:06
@imlopes imlopes requested a review from pedrobaeza August 22, 2024 11:07
@rousseldenis
Copy link
Contributor

/ocabot merge patch

@OCA-git-bot
Copy link
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 15.0-ocabot-merge-pr-3282-by-rousseldenis-bump-patch, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit aba17e8 into OCA:15.0 Sep 16, 2024
10 of 11 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at d06fc8f. Thanks a lot for contributing to OCA. ❤️

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

Successfully merging this pull request may close these issues.

6 participants