<commit_before># -*- coding: utf-8 -*-
# © <YEAR(S)> <AUTHOR(S)>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import _, api, fields, models


class MrpShipmentSaleOrder(models.TransientModel):
    _name = 'mrp.shipment.sale.order'

    sale_ids = fields.Many2many(
        'sale.order',
        string=_('Sale Order'),
    )

    @api.multi
    def add_sale_order(self):
        shipment_obj = self.env['mrp.shipment']
        shipment_line_obj = self.env['mrp.shipment.line']
        ship_sale_obj = self.env['mrp.shipment.sale']
        active_ids = self._context.get('active_ids', []) or []
        shipment = shipment_obj.browse(active_ids)
        order_line_id = []
        sale_id = []
        for sale in shipment.sale_ids:
            sale_id.append(sale.sale_id.id)
        for lines in shipment.line_ids:
            order_line_id.append(lines.order_line_id.id)
        for shipment_sale in self:
            for sale in shipment_sale.sale_ids:
                if sale.state == "done":
                    for line in sale.order_line:
                        if line.id not in order_line_id:
                            if line.missing_quantity > 0:
                                # miss_seg = line.segment_qty
                                # miss_seg = miss_seg - line.quantity_shipped
                                # if miss_seg > 0:
                                if sale.id not in sale_id:
                                    ship_sale = ship_sale_obj.create({
                                        'sale_id': sale.id,
                                        'shipment_id': shipment.id
                                    })
                                    sale_id.append(sale.id)
                                else:
                                    ship_sale = ship_sale_obj.search([
                                        ('sale_id', '=', sale.id),
                                        ('shipment_id', '=', shipment.id)
                                    ])
                                shipment_line_obj.create({
                                    'shipment_id': shipment.id,
                                    'shipment_sale_id': ship_sale.id,
                                    'partner_id': line.order_partner_id.id,
                                    'sale_order_id': sale.id,
                                    'order_line_id': line.id,
                                    'product_id': line.product_id.id,
                                    'price_unit': line.price_unit,
                                    'quantity': line.missing_quantity,<commit_msg>[IMP] add estate 'sale' in .py<commit_after># -*- coding: utf-8 -*-
# © <YEAR(S)> <AUTHOR(S)>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import _, api, fields, models


class MrpShipmentSaleOrder(models.TransientModel):
    _name = 'mrp.shipment.sale.order'

    sale_ids = fields.Many2many(
        'sale.order',
        string=_('Sale Order'),
    )

    @api.multi
    def add_sale_order(self):
        shipment_obj = self.env['mrp.shipment']
        shipment_line_obj = self.env['mrp.shipment.line']
        ship_sale_obj = self.env['mrp.shipment.sale']
        active_ids = self._context.get('active_ids', []) or []
        shipment = shipment_obj.browse(active_ids)
        order_line_id = []
        sale_id = []
        for sale in shipment.sale_ids:
            sale_id.append(sale.sale_id.id)
        for lines in shipment.line_ids:
            order_line_id.append(lines.order_line_id.id)
        for shipment_sale in self:
            for sale in shipment_sale.sale_ids:
                if sale.state in ("done", "sale"):
                    for line in sale.order_line:
                        if line.id not in order_line_id:
                            if line.missing_quantity > 0:
                                # miss_seg = line.segment_qty
                                # miss_seg = miss_seg - line.quantity_shipped
                                # if miss_seg > 0:
                                if sale.id not in sale_id:
                                    ship_sale = ship_sale_obj.create({
                                        'sale_id': sale.id,
                                        'shipment_id': shipment.id
                                    })
                                    sale_id.append(sale.id)
                                else:
                                    ship_sale = ship_sale_obj.search([
                                        ('sale_id', '=', sale.id),
                                        ('shipment_id', '=', shipment.id)
                                    ])
                                shipment_line_obj.create({
                                    'shipment_id': shipment.id,
                                    'shipment_sale_id': ship_sale.id,
                                    'partner_id': line.order_partner_id.id,
                                    'sale_order_id': sale.id,
                                    'order_line_id': line.id,
                                    'product_id': line.product_id.id,
                                    'price_unit': line.price_unit,
                                    'quantity': line.missing_quantity,
{'fraction_non_alphanumeric': 0.09434316857733509, 'fraction_numerical': 0.0022552151851155796, 'mean_word_length': 1.0627906976744186, 'pattern_counts': {'":': 1, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 42, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5892688', 'n_tokens_mistral': 1498, 'n_tokens_neox': 1375, 'n_words': 244}