Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP] mrp_production_unreserve_movements: #144

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions mrp_production_unreserve_movements/__openerp__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# This program is free software: you can redistribute it and/or modify
Expand All @@ -17,15 +17,16 @@
##############################################################################
{
'name': 'MRP Production Unreserve Movements',
'version': "1.0",
'version': "8.0.1.1.0",
'author': 'OdooMRP team,'
'AvanzOSC,'
'Serv. Tecnol. Avanzados - Pedro M. Baeza',
'website': "http://www.odoomrp.com",
"contributors": [
"Pedro M. Baeza <pedro.baeza@serviciosbaeza.com",
"Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>",
"Ana Juaristi <anajuaristi@avanzosc.es>",
"Alfredo de la Fuente <alfredodelafuente@avanzosc.es>",
"Ainara Galdona <ainaragaldona@avanzosc.es>"
],
'category': 'Manufacturing',
'depends': ['mrp',
Expand All @@ -34,6 +35,7 @@
],
'data': ["views/mrp_production_view.xml",
"views/mrp_production_workcenter_line_view.xml",
"views/mrp_production_workflow.xml"
],
'installable': True,
}
1 change: 1 addition & 0 deletions mrp_production_unreserve_movements/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
# For copyright and license notices, see __openerp__.py file in root directory
##############################################################################
from . import mrp_production
from . import stock_move
9 changes: 9 additions & 0 deletions mrp_production_unreserve_movements/models/mrp_production.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ def button_unreserve(self):
not x.work_order or x.work_order.state == 'draft'))
return moves.do_unreserve()

@api.multi
def check_unreserved_moves(self):
self.ensure_one()
moves = self.move_lines.filtered(
lambda x: x.state in ('assigned', 'done'))
if moves:
return False
return True


class MrpProductionWorkcenterLine(models.Model):
_inherit = 'mrp.production.workcenter.line'
Expand Down
17 changes: 17 additions & 0 deletions mrp_production_unreserve_movements/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
# (c) 2016 Ainara Galdona - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from openerp import models, api


class StockMove(models.Model):

_inherit = 'stock.move'

@api.multi
def do_unreserve(self):
res = super(StockMove, self).do_unreserve()
self.mapped('raw_material_production_id').signal_workflow(
'button_not_ready')
return res
5 changes: 5 additions & 0 deletions mrp_production_unreserve_movements/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# (c) 2016 Ainara Galdona - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from . import test_mrp_production_unreserve_movements
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
# (c) 2016 Ainara Galdona - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

import openerp.tests.common as common


class TestMrpProductionUnreserveMovements(common.TransactionCase):

def setUp(self):
super(TestMrpProductionUnreserveMovements, self).setUp()
self.production = self.env.ref(
'mrp_operations_extension.mrp_production_opeext')
self.production.signal_workflow('button_confirm')
self.production.force_production()

def test_unreserve_workcenter_lines(self):
wk_line = self.production.workcenter_lines[:1]
assigned_lines = wk_line.move_lines.filtered(lambda x: x.state ==
'assigned')
self.assertTrue(assigned_lines, 'There is no stock for products.')
self.assertTrue(wk_line.show_unreserve)
self.assertFalse(wk_line.show_force_reservation)
self.assertFalse(wk_line.show_check_availability)
wk_line.button_unreserve()
assigned_lines = wk_line.move_lines.filtered(lambda x: x.state ==
'assigned')
self.assertFalse(assigned_lines, 'There are some moves assigned.')
self.assertFalse(wk_line.show_unreserve)
self.assertTrue(wk_line.show_force_reservation)
self.assertTrue(wk_line.show_check_availability)

def test_unreserve_production(self):
assigned_lines = self.production.move_lines.filtered(
lambda x: x.state == 'assigned')
self.assertTrue(assigned_lines, 'There is no stock for products.')
self.assertEqual(self.production.state, 'ready')
self.assertTrue(self.production.show_unreserve)
self.assertFalse(self.production.show_force_reservation)
self.assertFalse(self.production.show_check_availability)
self.production.button_unreserve()
assigned_lines = self.production.move_lines.filtered(
lambda x: x.state == 'assigned')
self.assertFalse(assigned_lines, 'There are some moves assigned.')
self.assertEqual(self.production.state, 'confirmed')
self.assertFalse(self.production.show_unreserve)
self.assertTrue(self.production.show_force_reservation)
self.assertTrue(self.production.show_check_availability)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="prod_trans_ready_to_confirm" model="workflow.transition">
<field name="act_from" ref="mrp.prod_act_ready"/>
<field name="act_to" ref="mrp.prod_act_confirmed"/>
<field name="signal">button_not_ready</field>
<field name="condition">check_unreserved_moves()</field>
</record>
</data>
</openerp>