<commit_before># Copyright 2018 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models, _
from odoo.exceptions import UserError


def format_link(object):
    return '<a href=# data-oe-model=%s data-oe-id=%d>%s</a>' % (
        object._name, object.id, object.name)


class StockMove(models.Model):

    _inherit = 'stock.move'

    def _action_cancel(self):

        orig_moves = self.mapped('move_orig_ids')
        all_om_canceled_or_done = all(
            move.state in ('cancel', 'done') for move in orig_moves)
        all_om_in_self = all(om in self for om in orig_moves)

        if (
                self.env.context.get('bypass_check_state') or
                all_om_canceled_or_done or
                all_om_in_self
        ):
            return super(StockMove, self.with_context(
                bypass_check_state=True))._action_cancel()
        else:
            blocking_moves = self.get_blocking_moves(orig_moves)
            blocking_objects = self.identify_blocking_objects(blocking_moves)
            error_objects = ''
            for object_type, objects in blocking_objects.items():
                error_objects += _('- %s : %s. \n' % (
                    object_type, ','.join([format_link(o) for o in objects])))
            # TODO Fix error message:
            # We'd like the links to be clickable but they are interpreted as
            # raw text<commit_msg>Remove HTML formatting as exceptions cannot display it<commit_after># Copyright 2018 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models, _
from odoo.exceptions import UserError


class StockMove(models.Model):

    _inherit = 'stock.move'

    def _action_cancel(self):

        orig_moves = self.mapped('move_orig_ids')
        all_om_canceled_or_done = all(
            move.state in ('cancel', 'done') for move in orig_moves)
        all_om_in_self = all(om in self for om in orig_moves)

        if (
                self.env.context.get('bypass_check_state') or
                all_om_canceled_or_done or
                all_om_in_self
        ):
            return super(StockMove, self.with_context(
                bypass_check_state=True))._action_cancel()
        else:
            blocking_moves = self.get_blocking_moves(orig_moves)
            blocking_objects = self.identify_blocking_objects(blocking_moves)
            error_objects = ''
            for object_type, objects in blocking_objects.items():
                error_objects += _('- %s : %s. \n' % (
                    object_type, ','.join([o.name for o in objects])))
{'fraction_non_alphanumeric': 0.09818043972706596, 'fraction_numerical': 0.004548900682335102, 'mean_word_length': 2.2823383084577116, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5451607', 'n_tokens_mistral': 838, 'n_tokens_neox': 798, 'n_words': 185}