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

Not assigned field #25

Open
dante-envalia opened this issue Jun 13, 2024 · 0 comments
Open

Not assigned field #25

dante-envalia opened this issue Jun 13, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@dante-envalia
Copy link

Module

The name of the module that has a bug.

Describe the bug

Calculated fields should always have a value assignes
ValueError: Compute method failed to assign product.template(<NewId 0x76bc99cbe860>,).qty_available_not_res
File: stock_available_unreserved/models/product_template.py

Original code:

    @api.depends("product_variant_ids.qty_available_not_res")
    def _compute_product_available_not_res(self):
        for tmpl in self:
            if isinstance(tmpl.id, models.NewId):
                continue
            tmpl.qty_available_not_res = sum(
                tmpl.mapped("product_variant_ids.qty_available_not_res")
            )

Proposed code:

    @api.depends("product_variant_ids.qty_available_not_res")
    def _compute_product_available_not_res(self):
        for tmpl in self:
            if isinstance(tmpl.id, models.NewId):
                tmpl.qty_available_not_res = False
                continue
            tmpl.qty_available_not_res = sum(
                tmpl.mapped("product_variant_ids.qty_available_not_res")
            )
@dante-envalia dante-envalia added the bug Something isn't working label Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant