Skip to content
Snippets Groups Projects
Commit 874e4246 authored by Maruan Aguerdouh (magm)'s avatar Maruan Aguerdouh (magm)
Browse files

[FIX] stock: set location as replenishment posible without warehouse


Steps to reproduce:

- Install purchase, inventory and manufacturing.
- Now create a subcontractor, with it's corresponding location, it's set
by default.
- Go to this new location and set it as replenishment location.
- Now create a Request for Quotation using this subcontractor.
- We will receive a traceback whent trying to access replenishment.

Issue:

We got a traceback caused by the fact that we are trying to set
as replenishment location, a location that doesn't have a warehouse.

Solution:

We need to add the handling of this case, so we won't always need
a warehouse for the orderpoint.

opw-3164276

closes odoo/odoo#113361

Signed-off-by: default avatarWilliam Henrotin (whe) <whe@odoo.com>
parent 2e4f8ff5
Branches
Tags
No related merge requests found
......@@ -184,3 +184,53 @@ class MrpSubcontractingPurchaseTest(TestMrpSubcontractingCommon):
self.assertEqual(self.finished2.qty_available, 7.0)
self.assertEqual(po.order_line.qty_received, 10.0)
def test_orderpoint_warehouse_not_required(self):
"""
The user creates a subcontracted bom for the product,
then we create a po for the subcontracted bom we are gonna get
orderpoints for the components without warehouse.Notice this is
when our subcontracting location is also a replenish location.
The test ensure that we can get those orderpoints without warehouse.
"""
product = self.env['product.product'].create({
'name': 'Product',
'detailed_type': 'product',
})
component = self.env['product.product'].create({
'name': 'Component',
'detailed_type': 'product',
})
subcontractor = self.env['res.partner'].create({
'name': 'Subcontractor',
'property_stock_subcontractor': self.env.company.subcontracting_location_id.id,
})
self.env.company.subcontracting_location_id.replenish_location = True
self.env['mrp.bom'].create({
'product_tmpl_id': product.product_tmpl_id.id,
'product_qty': 1,
'product_uom_id': product.uom_id.id,
'type': 'subcontract',
'subcontractor_ids': [(subcontractor.id)],
'bom_line_ids': [(0, 0, {
'product_id': component.id,
'product_qty': 1,
'product_uom_id': component.uom_id.id,
})],
})
po = self.env['purchase.order'].create({
'partner_id': subcontractor.id,
'order_line': [(0, 0, {
'product_id': product.id,
'product_qty': 1,
'product_uom': product.uom_id.id,
'name': product.name,
'price_unit': 1,
})],
})
po.button_confirm()
self.env['stock.warehouse.orderpoint']._get_orderpoint_action()
self.assertTrue(self.env['stock.warehouse.orderpoint'].search([('product_id', '=', component.id)]))
......@@ -408,11 +408,11 @@ class StockWarehouseOrderpoint(models.Model):
self.env['stock.warehouse.orderpoint'].browse(orderpoint_id).qty_forecast += product_qty
else:
orderpoint_values = self.env['stock.warehouse.orderpoint']._get_orderpoint_values(product, location_id)
warehouse_id = self.env['stock.location'].browse(location_id).warehouse_id
location = self.env['stock.location'].browse(location_id)
orderpoint_values.update({
'name': _('Replenishment Report'),
'warehouse_id': warehouse_id.id,
'company_id': warehouse_id.company_id.id,
'warehouse_id': location.warehouse_id.id or self.env['stock.warehouse'].search([('company_id', '=', location.company_id.id)]).id,
'company_id': location.company_id.id,
})
orderpoint_values_list.append(orderpoint_values)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment