Skip to content

Commit 02b51d3

Browse files
committed
fixup! [MIG] delivery_carrier_label_batch: Migration to 18.0
1 parent dd119da commit 02b51d3

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

delivery_carrier_label_batch/models/stock_batch_picking.py

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright 2013-2019 Camptocamp SA
22
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
33
from odoo import Command, api, fields, models
4+
from odoo.exceptions import UserError
45

56

67
class StockBatchPicking(models.Model):
@@ -14,11 +15,9 @@ class StockBatchPicking(models.Model):
1415

1516
carrier_id = fields.Many2one(
1617
comodel_name="delivery.carrier",
17-
string="Carrier",
1818
)
1919
option_ids = fields.Many2many(
2020
comodel_name="delivery.carrier.option",
21-
string="Options",
2221
)
2322
option_ids_domain = fields.Binary(
2423
string="Options domain",
@@ -61,20 +60,19 @@ def onchange_carrier_id(self):
6160

6261
@api.onchange("option_ids")
6362
def onchange_option_ids(self):
64-
res = {}
6563
if not self.carrier_id:
66-
return res
64+
return
65+
6766
for available_option in self.carrier_id.available_option_ids:
6867
if available_option.mandatory and available_option not in self.option_ids:
69-
res["warning"] = {
70-
"title": self.env._("User Error !"),
71-
"message": self.env._(
72-
"You can not remove a mandatory option."
73-
"\nPlease reset options to default."
74-
),
75-
}
68+
# Optionally, reset the options to the default values.
7669
self.option_ids = self._get_options_to_add()
77-
return res
70+
raise UserError(
71+
self.env._(
72+
"You cannot remove a mandatory option. "
73+
"\nPlease reset options to default."
74+
)
75+
)
7876

7977
def _values_with_carrier_options(self, values):
8078
values = values.copy()

0 commit comments

Comments
 (0)