Skip to content
Snippets Groups Projects
Commit 829369d3 authored by Rémy Voet (ryv)'s avatar Rémy Voet (ryv)
Browse files

[IMP] mrp_subcontracting: take produce_delay in account


In subcontracting, there wasn't a way to make
the subcontracting resupply delivery plan before
the subcontracting receipt.

Now the hidden subcontracted MO, take in account
(in his planning) the `produce_delay` (in days) of
the product which is automatically plan the
subcontracting resupply delivery correctly.

task-2486811

closes odoo/odoo#74999

Signed-off-by: default avatarArnold Moyaux <amoyaux@users.noreply.github.com>
parent d3feb26c
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@ from datetime import timedelta
from odoo import api, fields, models
from odoo.tools.float_utils import float_compare
from dateutil.relativedelta import relativedelta
class StockPicking(models.Model):
......@@ -112,7 +113,7 @@ class StockPicking(models.Model):
'location_dest_id': subcontract_move.picking_id.partner_id.with_company(subcontract_move.company_id).property_stock_subcontractor.id,
'product_qty': subcontract_move.product_uom_qty,
'picking_type_id': warehouse.subcontracting_type_id.id,
'date_planned_start': subcontract_move.date
'date_planned_start': subcontract_move.date - relativedelta(days=product.produce_delay)
}
return vals
......
......@@ -6,6 +6,7 @@ from odoo.tests.common import TransactionCase
from odoo.addons.mrp_subcontracting.tests.common import TestMrpSubcontractingCommon
from odoo.tests import tagged
from dateutil.relativedelta import relativedelta
@tagged('post_install', '-at_install')
......@@ -111,6 +112,9 @@ class TestSubcontractingFlows(TestMrpSubcontractingCommon):
l.location_id == self.env.company.subcontracting_location_id and
l.location_src_id == self.warehouse.lot_stock_id)
resupply_warehouse_rule.copy({'location_id': partner_subcontract_location.id})
# Add a manufacturing lead time to check that the resupply delivery is correctly planned 2 days
# before the subcontracting receipt
self.finished.produce_delay = 2
# Create a receipt picking from the subcontractor
picking_form = Form(self.env['stock.picking'])
......@@ -136,6 +140,8 @@ class TestSubcontractingFlows(TestMrpSubcontractingCommon):
# The picking should be a delivery order
self.assertEqual(picking.picking_type_id, wh.out_type_id)
# The date planned should be correct
self.assertEqual(picking_receipt.scheduled_date, picking.scheduled_date + relativedelta(days=self.finished.produce_delay))
self.assertEqual(mo.picking_type_id, wh.subcontracting_type_id)
self.assertFalse(mo.picking_type_id.active)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment