mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[IMP] mrp_subcontracting_purchase_link: add post init hook to populate the PO line on previous manufacturing orders
This commit is contained in:
committed by
Marina Alapont
parent
05368d3fd5
commit
da713ef8e8
@@ -2,10 +2,13 @@
|
||||
Link Purchase Order Line to Subcontract Productions
|
||||
===================================================
|
||||
|
||||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
..
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! source digest: sha256:074986a18935844303cc29216277c6fd630f383750f4ef24800ab0cf07c6a4c3
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
|
||||
:target: https://odoo-community.org/page/development-status
|
||||
@@ -19,11 +22,11 @@ Link Purchase Order Line to Subcontract Productions
|
||||
.. |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
|
||||
: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
|
||||
:alt: Try me on Runbot
|
||||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
|
||||
:target: https://runboat.odoo-community.org/builds?repo=OCA/manufacture&target_branch=14.0
|
||||
:alt: Try me on Runboat
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
|
||||
This module does the following:
|
||||
|
||||
@@ -40,7 +43,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
|
||||
If you spotted it first, help us to smash 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**>`_.
|
||||
|
||||
Do not contact contributors directly about support or help with technical issues.
|
||||
@@ -52,6 +55,7 @@ Authors
|
||||
~~~~~~~
|
||||
|
||||
* Quartile Limited
|
||||
* ForgeFlow
|
||||
|
||||
Contributors
|
||||
~~~~~~~~~~~~
|
||||
@@ -61,6 +65,11 @@ Contributors
|
||||
* Yoshi Tashiro <tashiro@quartile.co>
|
||||
* Tim Lai <tl@quartile.com>
|
||||
|
||||
* `ForgeFlow <https://www.forgeflow.com>`__:
|
||||
|
||||
* Thiago Mulero <thuago.mulero@forgeflow.com>
|
||||
* Jordi Ballester <jordi.ballester@forgeflow.com>
|
||||
|
||||
Maintainers
|
||||
~~~~~~~~~~~
|
||||
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
from . import models
|
||||
from .hooks import post_init_hook
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
# 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": "14.0.2.1.0",
|
||||
"category": "Manufacturing",
|
||||
"license": "LGPL-3",
|
||||
"author": "Quartile Limited, Odoo Community Association (OCA)",
|
||||
"author": "Quartile Limited, ForgeFlow, Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/manufacture",
|
||||
"depends": ["purchase", "mrp_subcontracting"],
|
||||
"data": ["views/purchase_order_views.xml", "views/mrp_production_views.xml"],
|
||||
"post_init_hook": "post_init_hook",
|
||||
"installable": True,
|
||||
}
|
||||
|
||||
39
mrp_subcontracting_purchase_link/hooks.py
Normal file
39
mrp_subcontracting_purchase_link/hooks.py
Normal file
@@ -0,0 +1,39 @@
|
||||
# Copyright 2023 ForgeFlow, S.L.
|
||||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
|
||||
|
||||
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 post_init_hook(cr, registry):
|
||||
update_po_line_in_mrp_production(cr)
|
||||
@@ -1,3 +1,5 @@
|
||||
# Copyright 2023 ForgeFlow, S.L.
|
||||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
|
||||
import logging
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -2,3 +2,8 @@
|
||||
|
||||
* Yoshi Tashiro <tashiro@quartile.co>
|
||||
* Tim Lai <tl@quartile.com>
|
||||
|
||||
* `ForgeFlow <https://www.forgeflow.com>`__:
|
||||
|
||||
* Thiago Mulero <thuago.mulero@forgeflow.com>
|
||||
* Jordi Ballester <jordi.ballester@forgeflow.com>
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<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: https://docutils.sourceforge.io/" />
|
||||
<title>Link Purchase Order Line to Subcontract Productions</title>
|
||||
<style type="text/css">
|
||||
|
||||
/*
|
||||
:Author: David Goodger (goodger@python.org)
|
||||
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
|
||||
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
|
||||
:Copyright: This stylesheet has been placed in the public domain.
|
||||
|
||||
Default cascading style sheet for the HTML output of Docutils.
|
||||
|
||||
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
|
||||
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
|
||||
customize this style sheet.
|
||||
*/
|
||||
|
||||
@@ -366,8 +366,10 @@ ul.auto-toc {
|
||||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! source digest: sha256:074986a18935844303cc29216277c6fd630f383750f4ef24800ab0cf07c6a4c3
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<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 image-reference" 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 image-reference" 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 image-reference" 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 image-reference" 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 image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/manufacture&target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-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>
|
||||
@@ -376,43 +378,49 @@ ul.auto-toc {
|
||||
<p><strong>Table of contents</strong></p>
|
||||
<div class="contents local topic" id="contents">
|
||||
<ul class="simple">
|
||||
<li><a class="reference internal" href="#bug-tracker" id="id1">Bug Tracker</a></li>
|
||||
<li><a class="reference internal" href="#credits" id="id2">Credits</a><ul>
|
||||
<li><a class="reference internal" href="#authors" id="id3">Authors</a></li>
|
||||
<li><a class="reference internal" href="#contributors" id="id4">Contributors</a></li>
|
||||
<li><a class="reference internal" href="#maintainers" id="id5">Maintainers</a></li>
|
||||
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-1">Bug Tracker</a></li>
|
||||
<li><a class="reference internal" href="#credits" id="toc-entry-2">Credits</a><ul>
|
||||
<li><a class="reference internal" href="#authors" id="toc-entry-3">Authors</a></li>
|
||||
<li><a class="reference internal" href="#contributors" id="toc-entry-4">Contributors</a></li>
|
||||
<li><a class="reference internal" href="#maintainers" id="toc-entry-5">Maintainers</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="bug-tracker">
|
||||
<h1><a class="toc-backref" href="#id1">Bug Tracker</a></h1>
|
||||
<h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1>
|
||||
<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
|
||||
If you spotted it first, help us to smash 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>
|
||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||
</div>
|
||||
<div class="section" id="credits">
|
||||
<h1><a class="toc-backref" href="#id2">Credits</a></h1>
|
||||
<h1><a class="toc-backref" href="#toc-entry-2">Credits</a></h1>
|
||||
<div class="section" id="authors">
|
||||
<h2><a class="toc-backref" href="#id3">Authors</a></h2>
|
||||
<h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
|
||||
<ul class="simple">
|
||||
<li>Quartile Limited</li>
|
||||
<li>ForgeFlow</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="contributors">
|
||||
<h2><a class="toc-backref" href="#id4">Contributors</a></h2>
|
||||
<h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
|
||||
<ul class="simple">
|
||||
<li><a class="reference external" href="https://www.quartile.co">Quartile Limited</a>:<ul>
|
||||
<li>Yoshi Tashiro <<a class="reference external" href="mailto:tashiro@quartile.co">tashiro@quartile.co</a>></li>
|
||||
<li>Tim Lai <<a class="reference external" href="mailto:tl@quartile.com">tl@quartile.com</a>></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference external" href="https://www.forgeflow.com">ForgeFlow</a>:<ul>
|
||||
<li>Thiago Mulero <<a class="reference external" href="mailto:thuago.mulero@forgeflow.com">thuago.mulero@forgeflow.com</a>></li>
|
||||
<li>Jordi Ballester <<a class="reference external" href="mailto:jordi.ballester@forgeflow.com">jordi.ballester@forgeflow.com</a>></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="maintainers">
|
||||
<h2><a class="toc-backref" href="#id5">Maintainers</a></h2>
|
||||
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
|
||||
<p>This module is maintained by the OCA.</p>
|
||||
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
|
||||
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||
|
||||
Reference in New Issue
Block a user