mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[14.0][FIX] mrp_subcontracting_purchase_link: link to PO line, not PO
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# Copyright 2020 Quartile Limited
|
||||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
|
||||
{
|
||||
"name": "Link Purchase Order to Subcontract Productions",
|
||||
"name": "Link Purchase Order Line to Subcontract Productions",
|
||||
"version": "14.0.1.0.1",
|
||||
"category": "Manufacturing",
|
||||
"license": "LGPL-3",
|
||||
|
||||
@@ -8,5 +8,13 @@ class MrpProduction(models.Model):
|
||||
_inherit = "mrp.production"
|
||||
|
||||
purchase_order_id = fields.Many2one(
|
||||
"purchase.order", "Subcontract Purchase Order", readonly=True
|
||||
"purchase.order",
|
||||
"Subcontract Purchase Order",
|
||||
readonly=True,
|
||||
related="purchase_line_id.order_id",
|
||||
store=True,
|
||||
)
|
||||
|
||||
purchase_line_id = fields.Many2one(
|
||||
"purchase.order.line", "Subcontract Purchase Order Line", readonly=True
|
||||
)
|
||||
|
||||
@@ -7,15 +7,16 @@ from odoo import fields, models
|
||||
class PurchaseOrder(models.Model):
|
||||
_inherit = "purchase.order"
|
||||
|
||||
subcontract_production_count = fields.Integer(
|
||||
compute="_compute_subcontract_production_count"
|
||||
)
|
||||
|
||||
subcontract_production_ids = fields.One2many(
|
||||
"mrp.production",
|
||||
"purchase_order_id",
|
||||
"Subcontract Production Orders",
|
||||
readonly=True,
|
||||
)
|
||||
subcontract_production_count = fields.Integer(
|
||||
compute="_compute_subcontract_production_count"
|
||||
)
|
||||
|
||||
def action_view_mrp(self):
|
||||
productions = self.subcontract_production_ids
|
||||
|
||||
@@ -10,5 +10,5 @@ class StockPicking(models.Model):
|
||||
def _prepare_subcontract_mo_vals(self, subcontract_move, bom):
|
||||
vals = super()._prepare_subcontract_mo_vals(subcontract_move, bom)
|
||||
if subcontract_move.purchase_line_id:
|
||||
vals["purchase_order_id"] = subcontract_move.purchase_line_id.order_id.id
|
||||
vals["purchase_line_id"] = subcontract_move.purchase_line_id.id
|
||||
return vals
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
This module does the following:
|
||||
|
||||
- Extends _prepare_subcontract_mo_vals() and adds the purchase order reference to the subcontracted manufacturing orders.
|
||||
- Extends _prepare_subcontract_mo_vals() and adds the purchase order line reference to the subcontracted manufacturing orders.
|
||||
- Adds an action button in the purchase order form view to open related subcontracted manufacturing orders.
|
||||
|
||||
@@ -44,8 +44,8 @@ class TestMrpSubcontractingPurchaseLink(TestMrpSubcontractingCommon):
|
||||
self.assertEqual(
|
||||
picking._prepare_subcontract_mo_vals(
|
||||
move, move._get_subcontract_bom()
|
||||
)["purchase_order_id"],
|
||||
purchase_order.id,
|
||||
)["purchase_line_id"],
|
||||
purchase_order.order_line.id,
|
||||
)
|
||||
|
||||
def test_02_compute_subcontract_production_count(self):
|
||||
@@ -62,7 +62,8 @@ class TestMrpSubcontractingPurchaseLink(TestMrpSubcontractingCommon):
|
||||
action["views"], [(self.env.ref("mrp.mrp_production_form_view").id, "form")]
|
||||
)
|
||||
self.assertEqual(
|
||||
action["res_id"], purchase_order1.subcontract_production_ids[0].id
|
||||
action["res_id"],
|
||||
purchase_order1.subcontract_production_ids[0].id,
|
||||
)
|
||||
action = purchase_order2.action_view_mrp()
|
||||
self.assertEqual(
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='company_id']" position="after">
|
||||
<field name="purchase_order_id" groups="purchase.group_purchase_user" />
|
||||
<field name="purchase_line_id" groups="purchase.group_purchase_user" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user