Skip to content

Commit

Permalink
[MIG] sale_substate: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed Osman committed Nov 25, 2024
1 parent 5b74cea commit 0eccd7c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 39 deletions.
2 changes: 1 addition & 1 deletion sale_substate/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": "Sale Sub State",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"category": "Tools",
"author": "Akretion, " "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/sale-workflow",
Expand Down
38 changes: 1 addition & 37 deletions sale_substate/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Copyright 2019 Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

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


class BaseSubstateType(models.Model):
Expand All @@ -16,38 +15,3 @@ class BaseSubstateType(models.Model):
class SaleOrder(models.Model):
_inherit = ["sale.order", "base.substate.mixin"]
_name = "sale.order"

@api.constrains("substate_id", "state")
def check_substate_id_value(self):
sale_states = dict(self._fields["state"].selection)
for order in self:
target_state = order.substate_id.target_state_value_id.target_state_value
if order.substate_id and order.state != target_state:
raise ValidationError(
_(
"The substate %(name)s is not defined for the state"
" %(state)s but for %(target_state)s "
)
% {
"name": order.substate_id.name,
"state": _(sale_states[order.state]),
"target_state": _(sale_states[target_state]),
}
)

def _track_template(self, changes):
res = super(SaleOrder, self)._track_template(changes)
track = self[0]
if "substate_id" in changes and track.substate_id.mail_template_id:
res["substate_id"] = (
track.substate_id.mail_template_id,
{
"composition_mode": "comment",
"auto_delete_message": True,
"subtype_id": self.env["ir.model.data"]._xmlid_to_res_id(
"mail.mt_note"
),
"email_layout_xmlid": "mail.mail_notification_light",
},
)
return res
2 changes: 1 addition & 1 deletion sale_substate/tests/test_sale_substate.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class TestBaseSubstate(TransactionCase):
def setUp(self):
super(TestBaseSubstate, self).setUp()
super().setUp()
self.substate_test_sale = self.env["sale.order"]
self.substate_test_sale_line = self.env["sale.order.line"]

Expand Down

0 comments on commit 0eccd7c

Please sign in to comment.