Skip to content

Conversation

@bosd
Copy link
Contributor

@bosd bosd commented Nov 29, 2025

Standard migration using odoo-module-migrator
/ocabot migration base_substate .

@bosd bosd force-pushed the 19.0-mig-base_substate branch from e1f5397 to 96cbcde Compare November 29, 2025 16:19
@bosd bosd marked this pull request as ready for review December 1, 2025 11:59
@api.depends("line_ids")
def _compute_amount_total(self):
for record in self:
record.amount_total = 0 # Initialize to 0
Copy link
Contributor

Choose a reason for hiding this comment

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

You can do it outside the loop with self.amount_total = 0

Copy link

@rrebollo rrebollo left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution. Please, consider my suggestions.


from odoo import api, fields, models
from odoo.exceptions import ValidationError

Choose a reason for hiding this comment

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

Suggested change
from odoo.fields import Domain

Comment on lines +50 to +53
domain = [
("target_state_value_id.target_state_value", "=", state_val),
("target_state_value_id.base_substate_type_id", "=", substate_type.id),
]

Choose a reason for hiding this comment

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

Suggested change
domain = [
("target_state_value_id.target_state_value", "=", state_val),
("target_state_value_id.base_substate_type_id", "=", substate_type.id),
]
domain = (
Domain('target_state_value_id.target_state_value', '=', state_val) &
Domain('target_state_value_id.base_substate_type_id', '=', substate_type.id)
)

def _get_substate_type(self):
"""Override this method to change substate_type (get by xml id for example)"""
return self.env["base.substate.type"].search(
[("model", "=", self._name)], limit=1

Choose a reason for hiding this comment

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

Suggested change
[("model", "=", self._name)], limit=1
Domain("model", "=", self._name), limit=1

ondelete="restrict",
default=lambda self: self._get_default_substate_id(),
index=True,
domain=lambda self: [("model", "=", self._name)],

Choose a reason for hiding this comment

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

Suggested change
domain=lambda self: [("model", "=", self._name)],
domain=lambda self: Domain("model", "=", self._name),

# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo.addons.base.tests.common import BaseCommon

Choose a reason for hiding this comment

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

Suggested change
from odoo.fields import Domain

# Create access rights for the test models if they exist
model_names = ["base.substate.test.sale", "base.substate.test.sale.line"]
for model_name in model_names:
model = cls.env["ir.model"].search([("model", "=", model_name)], limit=1)

Choose a reason for hiding this comment

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

Suggested change
model = cls.env["ir.model"].search([("model", "=", model_name)], limit=1)
model = cls.env["ir.model"].search(Domain("model", "=", model_name), limit=1)

Comment on lines +26 to +29
[
("model_id", "=", model.id),
("name", "ilike", f"access {model.name}%"),
],

Choose a reason for hiding this comment

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

Suggested change
[
("model_id", "=", model.id),
("name", "ilike", f"access {model.name}%"),
],
Domain("model_id", "=", model.id) \
& Domain("name", "ilike", f"access {model.name}%"),

# Clean up any access rights created during tests
model_names = ["base.substate.test.sale", "base.substate.test.sale.line"]
for model_name in model_names:
model = cls.env["ir.model"].search([("model", "=", model_name)], limit=1)

Choose a reason for hiding this comment

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

Suggested change
model = cls.env["ir.model"].search([("model", "=", model_name)], limit=1)
model = cls.env["ir.model"].search(Domain("model", "=", model_name), limit=1)

Comment on lines +53 to +56
[
("model_id", "=", model.id),
("name", "ilike", f"access {model.name}%"),
]

Choose a reason for hiding this comment

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

Suggested change
[
("model_id", "=", model.id),
("name", "ilike", f"access {model.name}%"),
]
Domain("model_id", "=", model.id) \
& Domain("name", "ilike", f"access {model.name}%")

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.