-
-
Notifications
You must be signed in to change notification settings - Fork 630
[19.0][MIG] base_substate #1198
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
base: 19.0
Are you sure you want to change the base?
Conversation
Note that because inheritance was poorly implemented in inheriting modules (such as sale_substate) this function was never called, hiding the bug. auto_delete_message was removed in odoo@9140ce06
Currently translated at 100.0% (33 of 33 strings) Translation: server-ux-17.0/server-ux-17.0-base_substate Translate-URL: https://translation.odoo-community.org/projects/server-ux-17-0/server-ux-17-0-base_substate/it/
e1f5397 to
96cbcde
Compare
| @api.depends("line_ids") | ||
| def _compute_amount_total(self): | ||
| for record in self: | ||
| record.amount_total = 0 # Initialize to 0 |
There was a problem hiding this comment.
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
rrebollo
left a comment
There was a problem hiding this 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 | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| from odoo.fields import Domain | |
| domain = [ | ||
| ("target_state_value_id.target_state_value", "=", state_val), | ||
| ("target_state_value_id.base_substate_type_id", "=", substate_type.id), | ||
| ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| [("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)], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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 | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| model = cls.env["ir.model"].search([("model", "=", model_name)], limit=1) | |
| model = cls.env["ir.model"].search(Domain("model", "=", model_name), limit=1) |
| [ | ||
| ("model_id", "=", model.id), | ||
| ("name", "ilike", f"access {model.name}%"), | ||
| ], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| [ | |
| ("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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| model = cls.env["ir.model"].search([("model", "=", model_name)], limit=1) | |
| model = cls.env["ir.model"].search(Domain("model", "=", model_name), limit=1) |
| [ | ||
| ("model_id", "=", model.id), | ||
| ("name", "ilike", f"access {model.name}%"), | ||
| ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| [ | |
| ("model_id", "=", model.id), | |
| ("name", "ilike", f"access {model.name}%"), | |
| ] | |
| Domain("model_id", "=", model.id) \ | |
| & Domain("name", "ilike", f"access {model.name}%") |
Standard migration using odoo-module-migrator
/ocabot migration base_substate .