<commit_before># Copyright 2018 Tecnativa - <NAME>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields, models


class StockPickingType(models.Model):
    _inherit = 'stock.picking.type'

    auto_create_lot = fields.Boolean(string='Auto Create Lot')


class StockPicking(models.Model):
    _inherit = 'stock.picking'

    def button_validate(self):
        if self.picking_type_id.auto_create_lot:
            for line in self.move_line_ids.filtered(lambda x: (
                    not x.lot_id and
                    x.product_id.tracking != 'none' and
                    x.product_id.auto_create_lot)):
                line.lot_id = self.env['stock.production.lot'].create({
                    'product_id': line.product_id.id,
                })
        return super().button_validate()<commit_msg>[11.0][FIX] stock_picking_auto_create_lot: Not create lot if lot_name is stored in move_line<commit_after># Copyright 2018 Tecnativa - <NAME>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields, models


class StockPickingType(models.Model):
    _inherit = 'stock.picking.type'

    auto_create_lot = fields.Boolean(string='Auto Create Lot')


class StockPicking(models.Model):
    _inherit = 'stock.picking'

    def button_validate(self):
        if self.picking_type_id.auto_create_lot:
            for line in self.move_line_ids.filtered(lambda x: (
                    not x.lot_id and not x.lot_name and
                    x.product_id.tracking != 'none' and
                    x.product_id.auto_create_lot)):
                line.lot_id = self.env['stock.production.lot'].create({
                    'product_id': line.product_id.id,
                })
        return super().button_validate()
{'fraction_non_alphanumeric': 0.10830527497194165, 'fraction_numerical': 0.008417508417508417, 'mean_word_length': 2.4288461538461537, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '1558874', 'n_tokens_mistral': 567, 'n_tokens_neox': 532, 'n_words': 110}