Skip to content

Commit

Permalink
fixup! [MIG] delivery_carrier_label_batch: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
yankinmax committed Feb 20, 2025
1 parent dd119da commit 02b51d3
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions delivery_carrier_label_batch/models/stock_batch_picking.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright 2013-2019 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
from odoo import Command, api, fields, models
from odoo.exceptions import UserError


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

carrier_id = fields.Many2one(
comodel_name="delivery.carrier",
string="Carrier",
)
option_ids = fields.Many2many(
comodel_name="delivery.carrier.option",
string="Options",
)
option_ids_domain = fields.Binary(
string="Options domain",
Expand Down Expand Up @@ -61,20 +60,19 @@ def onchange_carrier_id(self):

@api.onchange("option_ids")
def onchange_option_ids(self):
res = {}
if not self.carrier_id:
return res
return

for available_option in self.carrier_id.available_option_ids:
if available_option.mandatory and available_option not in self.option_ids:
res["warning"] = {
"title": self.env._("User Error !"),
"message": self.env._(
"You can not remove a mandatory option."
"\nPlease reset options to default."
),
}
# Optionally, reset the options to the default values.
self.option_ids = self._get_options_to_add()
return res
raise UserError(
self.env._(
"You cannot remove a mandatory option. "
"\nPlease reset options to default."
)
)

def _values_with_carrier_options(self, values):
values = values.copy()
Expand Down

0 comments on commit 02b51d3

Please sign in to comment.