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:
committed by
Meritxell Abellan
parent
0012430f55
commit
f4165cde63
@@ -1,7 +1,7 @@
|
|||||||
# Copyright 2020 Quartile Limited
|
# Copyright 2020 Quartile Limited
|
||||||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
|
# 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",
|
"version": "14.0.1.0.1",
|
||||||
"category": "Manufacturing",
|
"category": "Manufacturing",
|
||||||
"license": "LGPL-3",
|
"license": "LGPL-3",
|
||||||
|
|||||||
@@ -8,5 +8,13 @@ class MrpProduction(models.Model):
|
|||||||
_inherit = "mrp.production"
|
_inherit = "mrp.production"
|
||||||
|
|
||||||
purchase_order_id = fields.Many2one(
|
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):
|
class PurchaseOrder(models.Model):
|
||||||
_inherit = "purchase.order"
|
_inherit = "purchase.order"
|
||||||
|
|
||||||
|
subcontract_production_count = fields.Integer(
|
||||||
|
compute="_compute_subcontract_production_count"
|
||||||
|
)
|
||||||
|
|
||||||
subcontract_production_ids = fields.One2many(
|
subcontract_production_ids = fields.One2many(
|
||||||
"mrp.production",
|
"mrp.production",
|
||||||
"purchase_order_id",
|
"purchase_order_id",
|
||||||
"Subcontract Production Orders",
|
"Subcontract Production Orders",
|
||||||
readonly=True,
|
readonly=True,
|
||||||
)
|
)
|
||||||
subcontract_production_count = fields.Integer(
|
|
||||||
compute="_compute_subcontract_production_count"
|
|
||||||
)
|
|
||||||
|
|
||||||
def action_view_mrp(self):
|
def action_view_mrp(self):
|
||||||
productions = self.subcontract_production_ids
|
productions = self.subcontract_production_ids
|
||||||
|
|||||||
@@ -10,5 +10,5 @@ class StockPicking(models.Model):
|
|||||||
def _prepare_subcontract_mo_vals(self, subcontract_move, bom):
|
def _prepare_subcontract_mo_vals(self, subcontract_move, bom):
|
||||||
vals = super()._prepare_subcontract_mo_vals(subcontract_move, bom)
|
vals = super()._prepare_subcontract_mo_vals(subcontract_move, bom)
|
||||||
if subcontract_move.purchase_line_id:
|
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
|
return vals
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
This module does the following:
|
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.
|
- 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(
|
self.assertEqual(
|
||||||
picking._prepare_subcontract_mo_vals(
|
picking._prepare_subcontract_mo_vals(
|
||||||
move, move._get_subcontract_bom()
|
move, move._get_subcontract_bom()
|
||||||
)["purchase_order_id"],
|
)["purchase_line_id"],
|
||||||
purchase_order.id,
|
purchase_order.order_line.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_02_compute_subcontract_production_count(self):
|
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")]
|
action["views"], [(self.env.ref("mrp.mrp_production_form_view").id, "form")]
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
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()
|
action = purchase_order2.action_view_mrp()
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//field[@name='company_id']" position="after">
|
<xpath expr="//field[@name='company_id']" position="after">
|
||||||
<field name="purchase_order_id" groups="purchase.group_purchase_user" />
|
<field name="purchase_order_id" groups="purchase.group_purchase_user" />
|
||||||
|
<field name="purchase_line_id" groups="purchase.group_purchase_user" />
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
Reference in New Issue
Block a user