<commit_before># © 2019 Comunitea
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import models, fields, api


class MrpProduction(models.Model):

    _inherit = 'mrp.production'

    final_prod_lot = fields.Many2one('stock.production.lot', 'Final lot')
    type_ids = fields.Many2many(
        'mrp.customize.type', 'mrp_customizations_rel',
        'production_id', 'customization_id', 'Type')
    sale_line_id = fields.Many2one('sale.order.line', 'order line')
    sale_id = fields.Many2one(related="sale_line_id.order_id",
                              relation="sale.order", string="Sale",
                              readonly=True)
    production_name = fields.Char("Production ref", readonly=True)
    picking_out = fields.Many2one(
        'stock.picking', "Out picking", readonly=True)
    picking_in = fields.Many2one(
        'stock.picking', "In picking", readonly=True)

    def action_assign(self):
        res = super().action_assign()
        for production in self:
            for move in production.move_raw_ids:
                if move.state == 'confirmed':
                    reserv_dict = {
                        'date_validity': False,
                        'name': "{} ({})".format(production.name, move.name),
                        'mrp_id': production.id,
                        'move_id': move.id
                    }
                    reservation = self.env['stock.reservation'].create(
                        reserv_dict)
                    reservation.reserve()
        return res

    @api.multi
    def create_out_picking(self):
        picking = self.env['stock.picking']
        # Create out picking
        pick_out = picking.create({'partner_id': self.company_id.partner_id.id,<commit_msg>[FIX]sale_product_customize: se eliminan las reservas previas antes de crear una nueva para que no se dupliquen<commit_after># © 2019 Comunitea
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import models, fields, api


class MrpProduction(models.Model):

    _inherit = 'mrp.production'

    final_prod_lot = fields.Many2one('stock.production.lot', 'Final lot')
    type_ids = fields.Many2many(
        'mrp.customize.type', 'mrp_customizations_rel',
        'production_id', 'customization_id', 'Type')
    sale_line_id = fields.Many2one('sale.order.line', 'order line')
    sale_id = fields.Many2one(related="sale_line_id.order_id",
                              relation="sale.order", string="Sale",
                              readonly=True)
    production_name = fields.Char("Production ref", readonly=True)
    picking_out = fields.Many2one(
        'stock.picking', "Out picking", readonly=True)
    picking_in = fields.Many2one(
        'stock.picking', "In picking", readonly=True)

    def action_assign(self):
        res = super().action_assign()
        for production in self:
            for move in production.move_raw_ids:
                reserves = self.env['stock.reservation'].search([('move_id', '=', move.id)])
                if move.state == 'confirmed':
                    reserves.unlink()
                    reserv_dict = {
                        'date_validity': False,
                        'name': "{} ({})".format(production.name, move.name),
                        'mrp_id': production.id,
                        'move_id': move.id
                    }
                    reservation = self.env['stock.reservation'].create(
                        reserv_dict)
                    reservation.reserve()
        return res

    @api.multi
    def create_out_picking(self):
        picking = self.env['stock.picking']
        # Create out picking
        pick_out = picking.create({'partner_id': self.company_id.partner_id.id,
{'fraction_non_alphanumeric': 0.11892752853729759, 'fraction_numerical': 0.00637111760021237, 'mean_word_length': 2.080948487326247, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7658733', 'n_tokens_mistral': 1118, 'n_tokens_neox': 1073, 'n_words': 212}