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

[16.0][FIX] contract: proper condition for auto price #1158

Merged
merged 1 commit into from
Dec 17, 2024

Conversation

rvalyi
Copy link
Member

@rvalyi rvalyi commented Dec 11, 2024

IMPORTANT EDIT: the bug is present on 16.0 but it is not present in 15.0 nor 17.0. So no port will be needed for these versions.

without these conditions, if you create a new contract template with a new line with the price set as "automatic" (checkbox) while the contract has no pricelist, then you get this error (easy to reproduce on the Runboat):

  File "/opt/odoo/odoo/models.py", line 6622, in onchange
    todo = [
  File "/opt/odoo/odoo/models.py", line 6625, in <listcomp>
    if name not in done and snapshot0.has_changed(name)
  File "/opt/odoo/odoo/models.py", line 6408, in has_changed
    return self[name] != record[name]
  File "/opt/odoo/odoo/models.py", line 5957, in __getitem__
    return self._fields[key].__get__(self, self.env.registry[self._name])
  File "/opt/odoo/odoo/fields.py", line 1210, in __get__
    self.compute_value(recs)
  File "/opt/odoo/odoo/fields.py", line 1392, in compute_value
    records._compute_field_value(self)
  File "/opt/odoo/odoo/models.py", line 4241, in _compute_field_value
    fields.determine(field.compute, self)
  File "/opt/odoo/odoo/fields.py", line 98, in determine
    return needle(*args)
  File "/mnt/data/odoo-addons-dir/contract/models/abstract_contract_line.py", line 214, in _compute_price_unit
    line.price_unit = pricelist._get_product_price(product, quantity=1)
  File "/opt/odoo/addons/product/models/product_pricelist.py", line 84, in _get_product_price
    self.ensure_one()
  File "/opt/odoo/odoo/models.py", line 5186, in ensure_one
    raise ValueError("Expected singleton: %s" % self)
ValueError: Expected singleton: product.pricelist()

@pedrobaeza pedrobaeza added this to the 16.0 milestone Dec 12, 2024
@rvalyi
Copy link
Member Author

rvalyi commented Dec 16, 2024

IMPORTANT NOTE: the bug is present on 16.0 but it is not present in 15.0 nor 17.0. So no port will be needed for these versions.

@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@pedrobaeza
Copy link
Member

/ocabot merge minor

Please fw-port it to 17

@OCA-git-bot
Copy link
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 16.0-ocabot-merge-pr-1158-by-pedrobaeza-bump-minor, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 7e7f4b5 into OCA:16.0 Dec 17, 2024
6 checks passed
@OCA-git-bot
Copy link
Contributor

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

@rvalyi
Copy link
Member Author

rvalyi commented Dec 17, 2024

/ocabot merge minor

Please fw-port it to 17
@pedrobaeza as I commented the bug is not present in v15 nor v17... It's probably related to the way fields are computed. Do you want me to put a blacklist in the oca-port metadata? I can also forward-port it, it is harmless but also useless.

@pedrobaeza
Copy link
Member

OK, don't worry then.

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.

4 participants