64 lines
2.8 KiB
Python
64 lines
2.8 KiB
Python
# -*- coding: utf-8 -*-
|
|
##############################################################################
|
|
#
|
|
# Stock Transfer Continue Later module for Odoo
|
|
# Copyright (C) 2015 Akretion (http://www.akretion.com)
|
|
# Copyright (C) 2015 Odoo S.A.
|
|
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU Affero General Public License as
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
# License, or (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU Affero General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
##############################################################################
|
|
|
|
|
|
from openerp import models, api
|
|
from datetime import datetime
|
|
|
|
|
|
class StockTransferDetails(models.TransientModel):
|
|
_inherit = 'stock.transfer_details'
|
|
|
|
@api.multi
|
|
def continue_later(self):
|
|
# This is a copy-paste of the method do_detailed_transfer()
|
|
# from odoo/addons/stock/wizard/stock_transfer_details.py
|
|
# without the last line "self.picking_id.do_transfer()"
|
|
processed_ids = []
|
|
# Create new and update existing pack operations
|
|
for lstits in [self.item_ids, self.packop_ids]:
|
|
for prod in lstits:
|
|
pack_datas = {
|
|
'product_id': prod.product_id.id,
|
|
'product_uom_id': prod.product_uom_id.id,
|
|
'product_qty': prod.quantity,
|
|
'package_id': prod.package_id.id,
|
|
'lot_id': prod.lot_id.id,
|
|
'location_id': prod.sourceloc_id.id,
|
|
'location_dest_id': prod.destinationloc_id.id,
|
|
'result_package_id': prod.result_package_id.id,
|
|
'date': prod.date if prod.date else datetime.now(),
|
|
'owner_id': prod.owner_id.id,
|
|
}
|
|
if prod.packop_id:
|
|
prod.packop_id.with_context(no_recompute=True).write(pack_datas)
|
|
processed_ids.append(prod.packop_id.id)
|
|
else:
|
|
pack_datas['picking_id'] = self.picking_id.id
|
|
packop_id = self.env['stock.pack.operation'].create(pack_datas)
|
|
processed_ids.append(packop_id.id)
|
|
# Delete the others
|
|
packops = self.env['stock.pack.operation'].search(['&', ('picking_id', '=', self.picking_id.id), '!', ('id', 'in', processed_ids)])
|
|
packops.unlink()
|
|
return True
|