[FIX] mrp_subcontracting: return to subcontract location

Before this commit a returns would select the classic
partner location. However in the case of a subcontractor return
it should be returned to the subcontract location
This commit is contained in:
Arnold Moyaux
2019-08-19 15:03:59 +00:00
parent 5d809fd6b4
commit 673450df40
3 changed files with 23 additions and 0 deletions
@@ -75,6 +75,14 @@ class TestSubcontractingFlows(TestMrpSubcontractingCommon):
self.assertEquals(avail_qty_comp2, -1)
self.assertEquals(avail_qty_finished, 1)
# Ensure returns to subcontractor location
return_form = Form(self.env['stock.return.picking'].with_context(active_id=picking_receipt.id, active_model='stock.picking'))
return_wizard = return_form.save()
return_picking_id, pick_type_id = return_wizard._create_returns()
return_picking = self.env['stock.picking'].browse(return_picking_id)
self.assertEqual(len(return_picking), 1)
self.assertEqual(return_picking.move_lines.location_dest_id, self.subcontractor_partner1.property_stock_subcontractor)
def test_flow_2(self):
""" Tick "Resupply Subcontractor on Order" on the components and trigger the creation of
the subcontracting manufacturing order through a receipt picking. Checks if the resupplying
@@ -2,3 +2,4 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import mrp_product_produce
from . import stock_picking_return
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
class ReturnPicking(models.TransientModel):
_inherit = 'stock.return.picking'
def _prepare_move_default_values(self, return_line, new_picking):
vals = super(ReturnPicking, self)._prepare_move_default_values(return_line, new_picking)
if return_line.move_id.is_subcontract:
vals['location_dest_id'] = self.picking_id.partner_id.property_stock_subcontractor.id
return vals