mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[10.0][FIX] mrp_production_request: issue propagating context to undesired places
This commit is contained in:
committed by
Jordi Ballester Alomar
parent
8cbe35a7d2
commit
ea0c5475de
@@ -51,9 +51,7 @@ class TestMrpProductionRequest(TransactionCase):
|
||||
request.button_to_approve()
|
||||
request.button_approved()
|
||||
self.assertEqual(request.pending_qty, 4.0)
|
||||
wiz = self.wiz_model.create({
|
||||
'mrp_production_request_id': request.id,
|
||||
})
|
||||
wiz = self.wiz_model.with_context(active_ids=request.ids).create({})
|
||||
wiz.compute_product_line_ids()
|
||||
wiz.mo_qty = 4.0
|
||||
wiz.create_mo()
|
||||
@@ -68,9 +66,7 @@ class TestMrpProductionRequest(TransactionCase):
|
||||
request and not from manufacturing order."""
|
||||
proc = self.create_procurement('TEST/02', self.product)
|
||||
request = proc.mrp_production_request_id
|
||||
wiz = self.wiz_model.create({
|
||||
'mrp_production_request_id': request.id,
|
||||
})
|
||||
wiz = self.wiz_model.with_context(active_ids=request.ids).create({})
|
||||
wiz.mo_qty = 4.0
|
||||
wiz.create_mo()
|
||||
with self.assertRaises(UserError):
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
string="Approve" type="object" class="oe_highlight"
|
||||
groups="mrp_production_request.group_mrp_production_request_manager"/>
|
||||
<button name="%(mrp_production_request_create_mo_action)d"
|
||||
context="{'default_mrp_production_request_id':active_id}"
|
||||
states="approved"
|
||||
string="Create Manufacturing Order" type="action"/>
|
||||
<button name="button_done" states="approved"
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
# Copyright 2017-18 Eficent Business and IT Consulting Services S.L.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, fields, models
|
||||
from odoo import api, fields, models, _
|
||||
import odoo.addons.decimal_precision as dp
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class MrpProductionRequestCreateMo(models.TransientModel):
|
||||
@@ -59,6 +60,17 @@ class MrpProductionRequestCreateMo(models.TransientModel):
|
||||
string="Products needed",
|
||||
inverse_name="mrp_production_request_create_mo_id", readonly=True)
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields):
|
||||
rec = super(MrpProductionRequestCreateMo, self).default_get(fields)
|
||||
active_ids = self._context.get('active_ids')
|
||||
if not active_ids:
|
||||
raise UserError(_(
|
||||
"Programming error: wizard action executed without "
|
||||
"active_ids in context."))
|
||||
rec['mrp_production_request_id'] = active_ids[0]
|
||||
return rec
|
||||
|
||||
def _prepare_product_line(self, pl):
|
||||
return {
|
||||
'product_id': pl[0].product_id.id,
|
||||
|
||||
Reference in New Issue
Block a user