<commit_before># -*- coding: utf-8 -*-
# Copyright 2015-17 Eficent Business and IT Consulting Services S.L.
# Copyright 2015-17 Serpent Consulting Services Pvt. Ltd.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import api, fields, models
from odoo.tools.translate import _
from odoo.exceptions import ValidationError


class MrpProduction(models.Model):

    _inherit = 'mrp.production'

    operating_unit_id = fields.Many2one(
        'operating.unit', 'Operating Unit',
        readonly=True,
        states={'draft': [('readonly', False)]},
        default=lambda self: self.env['res.users'
                                      ].operating_unit_default_get(self._uid)
    )

    @api.constrains('operating_unit_id', 'location_src_id', 'location_dest_id')<commit_msg>[FIX] mrp_operating_unit: Operating unit can't be edited in the view form<commit_after># -*- coding: utf-8 -*-
# Copyright 2015-17 Eficent Business and IT Consulting Services S.L.
# Copyright 2015-17 Serpent Consulting Services Pvt. Ltd.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import api, fields, models
from odoo.tools.translate import _
from odoo.exceptions import ValidationError


class MrpProduction(models.Model):

    _inherit = 'mrp.production'

    operating_unit_id = fields.Many2one(
        'operating.unit', 'Operating Unit',
        readonly=True,
        states={'confirmed': [('readonly', False)]},
        default=lambda self: self.env['res.users'
                                      ].operating_unit_default_get(self._uid)
    )

    @api.constrains('operating_unit_id', 'location_src_id', 'location_dest_id')
{'fraction_non_alphanumeric': 0.11933174224343675, 'fraction_numerical': 0.01909307875894988, 'mean_word_length': 3.3110539845758353, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6179485', 'n_tokens_mistral': 548, 'n_tokens_neox': 511, 'n_words': 123}