mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[8.0]-mrp_production_raw_material_procurement_group - Improvements (#1)
* [IMP] - When a manufacturing order is copied, do not copy the procurement group - When a manufacturing order is confirm, the procurement group is assigned to the stock moves from raw material location to the routing location. * [IMP] -added some more tests to cover the previous changes. * [FIX] errors in tests
This commit is contained in:
@@ -59,6 +59,7 @@ Contributors
|
|||||||
------------
|
------------
|
||||||
|
|
||||||
* Andhitia Rama <andhitia.r@gmail.com>
|
* Andhitia Rama <andhitia.r@gmail.com>
|
||||||
|
* Lois Rilo <lois.rilo@eficent.com>
|
||||||
|
|
||||||
Maintainer
|
Maintainer
|
||||||
----------
|
----------
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright 2016 OpenSynergy Indonesia
|
# Copyright 2016 OpenSynergy Indonesia
|
||||||
|
# Copyright 2016 Eficent Business and IT Consulting Services, S.L.
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
from openerp import models, fields, api
|
from openerp import models, fields, api
|
||||||
@@ -12,6 +13,7 @@ class MrpProduction(models.Model):
|
|||||||
string="Raw Material Procurement Group",
|
string="Raw Material Procurement Group",
|
||||||
comodel_name="procurement.group",
|
comodel_name="procurement.group",
|
||||||
readonly=True,
|
readonly=True,
|
||||||
|
copy=False,
|
||||||
states={
|
states={
|
||||||
"draft": [("readonly", False)],
|
"draft": [("readonly", False)],
|
||||||
},
|
},
|
||||||
@@ -37,9 +39,8 @@ class MrpProduction(models.Model):
|
|||||||
"procurement.group"]
|
"procurement.group"]
|
||||||
if self.auto_create_procurement_group and \
|
if self.auto_create_procurement_group and \
|
||||||
not self.raw_material_procurement_group_id:
|
not self.raw_material_procurement_group_id:
|
||||||
obj_group.create({
|
self.raw_material_procurement_group_id = obj_group.create({
|
||||||
"name": self.name,
|
"name": self.name})
|
||||||
})
|
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _make_consume_line_from_data(
|
def _make_consume_line_from_data(
|
||||||
@@ -59,3 +60,16 @@ class MrpProduction(models.Model):
|
|||||||
move.write(
|
move.write(
|
||||||
{"group_id": production.raw_material_procurement_group_id.id})
|
{"group_id": production.raw_material_procurement_group_id.id})
|
||||||
return move_id
|
return move_id
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _create_previous_move(self, move_id, product, source_location_id,
|
||||||
|
dest_location_id):
|
||||||
|
move_id2 = super(MrpProduction, self)._create_previous_move(
|
||||||
|
move_id, product, source_location_id, dest_location_id)
|
||||||
|
move1 = self.env['stock.move'].browse(move_id)
|
||||||
|
move2 = self.env['stock.move'].browse(move_id2)
|
||||||
|
if move1.raw_material_production_id.raw_material_procurement_group_id:
|
||||||
|
move2.group_id = \
|
||||||
|
move1.raw_material_production_id.\
|
||||||
|
raw_material_procurement_group_id
|
||||||
|
return move2.id
|
||||||
|
|||||||
@@ -147,3 +147,56 @@ class MrpProductionCase(TransactionCase):
|
|||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
raw.group_id,
|
raw.group_id,
|
||||||
mo.raw_material_procurement_group_id)
|
mo.raw_material_procurement_group_id)
|
||||||
|
|
||||||
|
def test_copy_mo_1(self):
|
||||||
|
# Create MO
|
||||||
|
group1 = self._create_procurement_group(
|
||||||
|
"X 001")
|
||||||
|
mo = self._create_mo(
|
||||||
|
group=group1.id)
|
||||||
|
mo2 = mo.copy()
|
||||||
|
|
||||||
|
self.assertNotEqual(
|
||||||
|
mo.raw_material_procurement_group_id,
|
||||||
|
mo2.raw_material_procurement_group_id)
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
mo2.raw_material_procurement_group_id.id, False)
|
||||||
|
|
||||||
|
def test_copy_mo_2(self):
|
||||||
|
# Create MO
|
||||||
|
mo = self._create_mo(auto=True)
|
||||||
|
# Click confirm button
|
||||||
|
mo.signal_workflow("button_confirm")
|
||||||
|
|
||||||
|
self.assertNotEqual(
|
||||||
|
mo.raw_material_procurement_group_id.id, False)
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
mo.raw_material_procurement_group_id.name, mo.name)
|
||||||
|
|
||||||
|
def test_routing(self):
|
||||||
|
location = self.env['stock.location'].create({
|
||||||
|
'name': 'Shop floor',
|
||||||
|
})
|
||||||
|
routing = self.env['mrp.routing'].create({
|
||||||
|
'name': 'test',
|
||||||
|
'location_id': location.id,
|
||||||
|
})
|
||||||
|
self.bom1.write({
|
||||||
|
"routing_id": routing.id})
|
||||||
|
# Create MO
|
||||||
|
mo = self._create_mo(auto=True)
|
||||||
|
mo2 = self._create_mo(auto=True)
|
||||||
|
# Click confirm button
|
||||||
|
mo.signal_workflow("button_confirm")
|
||||||
|
mo2.signal_workflow("button_confirm")
|
||||||
|
|
||||||
|
# Check that the pickings are split by procurement group
|
||||||
|
pick = self.env['stock.picking'].search(
|
||||||
|
[('group_id', '=', mo.raw_material_procurement_group_id.id)])
|
||||||
|
self.assertNotEqual(pick, False)
|
||||||
|
|
||||||
|
pick2 = self.env['stock.picking'].search(
|
||||||
|
[('group_id', '=', mo2.raw_material_procurement_group_id.id)])
|
||||||
|
self.assertNotEqual(pick2, False)
|
||||||
|
|||||||
Reference in New Issue
Block a user