[IMP] mrp_operations_extension: new method for computing value

This commit is contained in:
oihane
2016-05-19 15:31:37 +02:00
parent 20127ddba5
commit 61a0c37684
2 changed files with 7 additions and 7 deletions

View File

@@ -56,15 +56,14 @@ class MrpProductionProductLine(models.Model):
class MrpProductionWorkcenterLine(models.Model):
_inherit = 'mrp.production.workcenter.line'
@api.one
@api.multi
@api.depends('move_lines', 'move_lines.state')
def _compute_is_material_ready(self):
self.is_material_ready = True
if self.product_line:
moves = self.env['stock.move'].search(
[('work_order', '=', self.id)])
self.is_material_ready = not any(
for line in self:
line.is_material_ready = (not any(
x not in ('assigned', 'cancel', 'done') for x in
moves.mapped('state'))
line.mapped('move_lines.state'))
if line.product_line else True)
@api.multi
@api.depends('routing_wc_line')

View File

@@ -156,6 +156,7 @@ class TestMrpOperationsExtension(common.TransactionCase):
self.production.action_confirm()
def test_confirm_production_operation_extension_case1(self):
self.assertEqual(self.production.state, 'draft')
self.production.signal_workflow('button_confirm')
self.assertFalse(self.production.workcenter_lines[0].is_material_ready)
self.production.force_production()