[MIG] mrp_subcontracting_purchase_link: Migration to 16.0

This commit is contained in:
Aungkokolin1997
2023-03-15 09:20:31 +06:30
parent 71e57c1ce4
commit 02b52ef6f2
5 changed files with 11 additions and 49 deletions

View File

@@ -14,13 +14,13 @@ Link Purchase Order Line to Subcontract Productions
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github
:target: https://github.com/OCA/manufacture/tree/14.0/mrp_subcontracting_purchase_link
:target: https://github.com/OCA/manufacture/tree/16.0/mrp_subcontracting_purchase_link
:alt: OCA/manufacture
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/manufacture-14-0/manufacture-14-0-mrp_subcontracting_purchase_link
:target: https://translation.odoo-community.org/projects/manufacture-16-0/manufacture-16-0-mrp_subcontracting_purchase_link
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/129/14.0
:target: https://runbot.odoo-community.org/runbot/129/16.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -41,7 +41,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/manufacture/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/manufacture/issues/new?body=module:%20mrp_subcontracting_purchase_link%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/manufacture/issues/new?body=module:%20mrp_subcontracting_purchase_link%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
@@ -74,6 +74,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/14.0/mrp_subcontracting_purchase_link>`_ project on GitHub.
This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/16.0/mrp_subcontracting_purchase_link>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -2,7 +2,7 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
{
"name": "Link Purchase Order Line to Subcontract Productions",
"version": "14.0.2.0.0",
"version": "16.0.1.0.0",
"category": "Manufacturing",
"license": "LGPL-3",
"author": "Quartile Limited, Odoo Community Association (OCA)",

View File

@@ -1,38 +0,0 @@
import logging
_logger = logging.getLogger(__name__)
def update_po_line_in_mrp_production(cr):
""" """
_logger.info("Updating PO line in MRP production")
cr.execute(
"""
UPDATE mrp_production
SET
purchase_line_id = Q.purchase_line_id,
purchase_order_id = Q.purchase_id
FROM (
SELECT po_sm.purchase_line_id, mo_sm.production_id, po.id as purchase_id
FROM stock_move as po_sm
INNER JOIN stock_move_move_rel as rel
ON rel.move_dest_id = po_sm.id
INNER JOIN stock_move as mo_sm
ON mo_sm.id = rel.move_orig_id
INNER JOIN purchase_order_line as pol
ON pol.id = po_sm.purchase_line_id
INNER JOIN purchase_order as po
ON po.id = pol.order_id
where po_sm.is_subcontract = true
AND po_sm.purchase_line_id is not null
AND mo_sm.production_id is not null
) AS Q
WHERE mrp_production.id = Q.production_id
"""
)
def migrate(cr, version=None):
if not version:
return
update_po_line_in_mrp_production(cr)

View File

@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Link Purchase Order Line to Subcontract Productions</title>
<style type="text/css">
@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/manufacture/tree/14.0/mrp_subcontracting_purchase_link"><img alt="OCA/manufacture" src="https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/manufacture-14-0/manufacture-14-0-mrp_subcontracting_purchase_link"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/129/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/manufacture/tree/16.0/mrp_subcontracting_purchase_link"><img alt="OCA/manufacture" src="https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/manufacture-16-0/manufacture-16-0-mrp_subcontracting_purchase_link"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/129/16.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module does the following:</p>
<ul class="simple">
<li>Extends _prepare_subcontract_mo_vals() and adds the purchase order line reference to the subcontracted manufacturing orders.</li>
@@ -390,7 +390,7 @@ ul.auto-toc {
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/manufacture/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/manufacture/issues/new?body=module:%20mrp_subcontracting_purchase_link%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/manufacture/issues/new?body=module:%20mrp_subcontracting_purchase_link%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
@@ -418,7 +418,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/manufacture/tree/14.0/mrp_subcontracting_purchase_link">OCA/manufacture</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/manufacture/tree/16.0/mrp_subcontracting_purchase_link">OCA/manufacture</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

View File

@@ -40,7 +40,7 @@ class TestMrpSubcontractingPurchaseLink(TestMrpSubcontractingCommon):
def test_01_prepare_subcontract_mo_vals(self):
purchase_order = self._create_sub_po(self.finished)
for picking in purchase_order.picking_ids:
for move in picking.move_lines:
for move in picking.move_ids:
self.assertEqual(
picking._prepare_subcontract_mo_vals(
move, move._get_subcontract_bom()