<commit_before># -*- encoding: utf-8 -*-
##############################################################################
# For copyright and license notices, see __openerp__.py file in root directory
##############################################################################

from openerp import models, api, exceptions, _


class SaleOrder(models.Model):
    _inherit = "sale.order"

    @api.multi
    def button_draft(self):
        # go from canceled state to draft state
        for order in self:
            if order.state != 'cancel':
                raise exceptions.Warning(
                    _("You can't back any order that it's not on cancel "
                      "state. Order: %s" % order.name))
            order.order_line.write({'state': 'draft'})
            order.procurement_group_id.unlink()
            for line in order.order_line:
                line.procurement_ids.unlink()
            order.write({'state': 'draft'})
            order.delete_workflow()
            order.create_workflow()
        return True<commit_msg>[FIX] Delete procurement as superuser<commit_after># -*- encoding: utf-8 -*-
##############################################################################
# For copyright and license notices, see __openerp__.py file in root directory
##############################################################################

from openerp import models, api, exceptions, _


class SaleOrder(models.Model):
    _inherit = "sale.order"

    @api.multi
    def button_draft(self):
        # go from canceled state to draft state
        for order in self:
            if order.state != 'cancel':
                raise exceptions.Warning(
                    _("You can't back any order that it's not on cancel "
                      "state. Order: %s" % order.name))
            order.order_line.write({'state': 'draft'})
            order.procurement_group_id.sudo().unlink()
            for line in order.order_line:
                line.procurement_ids.sudo().unlink()
            order.write({'state': 'draft'})
            order.delete_workflow()
            order.create_workflow()
        return True
{'fraction_non_alphanumeric': 0.2344186046511628, 'fraction_numerical': 0.0009302325581395349, 'mean_word_length': 2.520458265139116, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '7475806', 'n_tokens_mistral': 552, 'n_tokens_neox': 510, 'n_words': 145}