[MIG] mrp_auto_assign: Migration to 14.0

This commit is contained in:
JordiMForgeFlow
2024-05-21 09:40:36 +02:00
parent bd35c2a08e
commit 48b0b37619
9 changed files with 60 additions and 46 deletions

View File

@@ -17,19 +17,19 @@ Mrp Auto Assign
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github
:target: https://github.com/OCA/manufacture/tree/12.0/mrp_auto_assign :target: https://github.com/OCA/manufacture/tree/14.0/mrp_auto_assign
:alt: OCA/manufacture :alt: OCA/manufacture
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/manufacture-12-0/manufacture-12-0-mrp_auto_assign :target: https://translation.odoo-community.org/projects/manufacture-14-0/manufacture-14-0-mrp_auto_assign
:alt: Translate me on Weblate :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/manufacture&target_branch=12.0 :target: https://runboat.odoo-community.org/builds?repo=OCA/manufacture&target_branch=14.0
:alt: Try me on Runboat :alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
Simple module that make MO to reserve the raw material moves automatically Simple module that make MO to reserve the raw material moves automatically
at creation. at confirmation.
**Table of contents** **Table of contents**
@@ -41,19 +41,25 @@ Usage
To use this module, you need to: To use this module, you need to:
#. Go to *Manufacturing* and create a Manufacturing Order. #. Go to *Manufacturing* and create and confirm a Manufacturing Order.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot :alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/129/12.0 :target: https://runbot.odoo-community.org/runbot/129/12.0
Known issues / Roadmap
======================
This module is not needed in higher versions, as in V15 Odoo introduces the
option to decide how stock moves should be assigned based on the operation type.
Bug Tracker Bug Tracker
=========== ===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/manufacture/issues>`_. 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. In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash 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_auto_assign%0Aversion:%2012.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_auto_assign%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. Do not contact contributors directly about support or help with technical issues.
@@ -70,6 +76,7 @@ Contributors
* Florian da Costa <florian.dacosta@akretion.com> * Florian da Costa <florian.dacosta@akretion.com>
* Sudhir Arya <sudhir@erpharbor.com> * Sudhir Arya <sudhir@erpharbor.com>
* Jordi Masvidal <jordi.masvidal@forgeflow.com>
Maintainers Maintainers
~~~~~~~~~~~ ~~~~~~~~~~~
@@ -84,6 +91,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/12.0/mrp_auto_assign>`_ project on GitHub. This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/14.0/mrp_auto_assign>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -8,7 +8,7 @@
"author": "Akretion, Odoo Community Association (OCA)", "author": "Akretion, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/manufacture", "website": "https://github.com/OCA/manufacture",
"category": "Manufacturing", "category": "Manufacturing",
"version": "12.0.1.0.0", "version": "14.0.1.0.0",
"license": "AGPL-3", "license": "AGPL-3",
"depends": ["mrp"], "depends": ["mrp"],
"application": False, "application": False,

View File

@@ -2,15 +2,15 @@
# @author Florian DA COSTA <florian.dacosta@akretion.com> # @author Florian DA COSTA <florian.dacosta@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, models from odoo import models
class MrpProduction(models.Model): class MrpProduction(models.Model):
_inherit = "mrp.production" _inherit = "mrp.production"
@api.model def action_confirm(self):
def create(self, values): res = super(MrpProduction, self).action_confirm()
production = super(MrpProduction, self).create(values) to_assign = self.filtered(lambda p: p.reservation_state)
if production.availability != "none": if to_assign:
production.action_assign() to_assign.action_assign()
return production return res

View File

@@ -1,2 +1,3 @@
* Florian da Costa <florian.dacosta@akretion.com> * Florian da Costa <florian.dacosta@akretion.com>
* Sudhir Arya <sudhir@erpharbor.com> * Sudhir Arya <sudhir@erpharbor.com>
* Jordi Masvidal <jordi.masvidal@forgeflow.com>

View File

@@ -1,2 +1,2 @@
Simple module that make MO to reserve the raw material moves automatically Simple module that make MO to reserve the raw material moves automatically
at creation. at confirmation.

View File

@@ -0,0 +1,2 @@
This module is not needed in higher versions, as in V15 Odoo introduces the
option to decide how stock moves should be assigned based on the operation type.

View File

@@ -1,6 +1,6 @@
To use this module, you need to: To use this module, you need to:
#. Go to *Manufacturing* and create a Manufacturing Order. #. Go to *Manufacturing* and create and confirm a Manufacturing Order.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot :alt: Try me on Runbot

View File

@@ -1,4 +1,3 @@
<?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"> <!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"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <head>
@@ -369,18 +368,19 @@ ul.auto-toc {
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:276050fc7d5e77ab8d2b2d6ed43d1e3d3547da369c89f0004d8a400a56b4c4ea !! source digest: sha256:276050fc7d5e77ab8d2b2d6ed43d1e3d3547da369c89f0004d8a400a56b4c4ea
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/manufacture/tree/12.0/mrp_auto_assign"><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-12-0/manufacture-12-0-mrp_auto_assign"><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&amp;target_branch=12.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-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/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/manufacture/tree/14.0/mrp_auto_assign"><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_auto_assign"><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&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Simple module that make MO to reserve the raw material moves automatically <p>Simple module that make MO to reserve the raw material moves automatically
at creation.</p> at confirmation.</p>
<p><strong>Table of contents</strong></p> <p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents"> <div class="contents local topic" id="contents">
<ul class="simple"> <ul class="simple">
<li><a class="reference internal" href="#usage" id="toc-entry-1">Usage</a></li> <li><a class="reference internal" href="#usage" id="toc-entry-1">Usage</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-2">Bug Tracker</a></li> <li><a class="reference internal" href="#known-issues-roadmap" id="toc-entry-2">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-3">Credits</a><ul> <li><a class="reference internal" href="#bug-tracker" id="toc-entry-3">Bug Tracker</a></li>
<li><a class="reference internal" href="#authors" id="toc-entry-4">Authors</a></li> <li><a class="reference internal" href="#credits" id="toc-entry-4">Credits</a><ul>
<li><a class="reference internal" href="#contributors" id="toc-entry-5">Contributors</a></li> <li><a class="reference internal" href="#authors" id="toc-entry-5">Authors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-6">Maintainers</a></li> <li><a class="reference internal" href="#contributors" id="toc-entry-6">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-7">Maintainers</a></li>
</ul> </ul>
</li> </li>
</ul> </ul>
@@ -389,41 +389,47 @@ at creation.</p>
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1> <h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
<p>To use this module, you need to:</p> <p>To use this module, you need to:</p>
<ol class="arabic simple"> <ol class="arabic simple">
<li>Go to <em>Manufacturing</em> and create a Manufacturing Order.</li> <li>Go to <em>Manufacturing</em> and create and confirm a Manufacturing Order.</li>
</ol> </ol>
<a class="reference external image-reference" href="https://runbot.odoo-community.org/runbot/129/12.0"><img alt="Try me on Runbot" src="https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas" /></a> <a class="reference external image-reference" href="https://runbot.odoo-community.org/runbot/129/12.0"><img alt="Try me on Runbot" src="https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas" /></a>
</div> </div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h1>
<p>This module is not needed in higher versions, as in V15 Odoo introduces the
option to decide how stock moves should be assigned based on the operation type.</p>
</div>
<div class="section" id="bug-tracker"> <div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1> <h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/manufacture/issues">GitHub Issues</a>. <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. In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash 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_auto_assign%0Aversion:%2012.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_auto_assign%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> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
<h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1> <h1><a class="toc-backref" href="#toc-entry-4">Credits</a></h1>
<div class="section" id="authors"> <div class="section" id="authors">
<h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2> <h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
<ul class="simple"> <ul class="simple">
<li>Akretion</li> <li>Akretion</li>
</ul> </ul>
</div> </div>
<div class="section" id="contributors"> <div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2> <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<ul class="simple"> <ul class="simple">
<li>Florian da Costa &lt;<a class="reference external" href="mailto:florian.dacosta&#64;akretion.com">florian.dacosta&#64;akretion.com</a>&gt;</li> <li>Florian da Costa &lt;<a class="reference external" href="mailto:florian.dacosta&#64;akretion.com">florian.dacosta&#64;akretion.com</a>&gt;</li>
<li>Sudhir Arya &lt;<a class="reference external" href="mailto:sudhir&#64;erpharbor.com">sudhir&#64;erpharbor.com</a>&gt;</li> <li>Sudhir Arya &lt;<a class="reference external" href="mailto:sudhir&#64;erpharbor.com">sudhir&#64;erpharbor.com</a>&gt;</li>
<li>Jordi Masvidal &lt;<a class="reference external" href="mailto:jordi.masvidal&#64;forgeflow.com">jordi.masvidal&#64;forgeflow.com</a>&gt;</li>
</ul> </ul>
</div> </div>
<div class="section" id="maintainers"> <div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2> <h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p> <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> <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 <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/manufacture/tree/12.0/mrp_auto_assign">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/14.0/mrp_auto_assign">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> <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>
</div> </div>

View File

@@ -2,6 +2,7 @@
# @author Florian DA COSTA <florian.dacosta@akretion.com> # @author Florian DA COSTA <florian.dacosta@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo.tests import Form
from odoo.tests.common import TransactionCase from odoo.tests.common import TransactionCase
@@ -38,6 +39,7 @@ class TestMrpAutoAssign(TransactionCase):
{ {
"product_id": self.product_manuf.id, "product_id": self.product_manuf.id,
"product_tmpl_id": self.product_manuf.product_tmpl_id.id, "product_tmpl_id": self.product_manuf.product_tmpl_id.id,
"type": "normal",
"bom_line_ids": ( "bom_line_ids": (
[ [
( (
@@ -56,25 +58,21 @@ class TestMrpAutoAssign(TransactionCase):
def _update_product_qty(self, product, location, quantity): def _update_product_qty(self, product, location, quantity):
"""Update Product quantity.""" """Update Product quantity."""
product_qty = self.env["stock.change.product.qty"].create( product_qty = self.env["stock.quant"].create(
{ {
"location_id": location.id, "location_id": location.id,
"product_id": product.id, "product_id": product.id,
"new_quantity": quantity, "quantity": quantity,
} }
) )
product_qty.change_product_qty()
return product_qty return product_qty
def test_01_manufacture_auto_assign(self): def test_01_manufacture_auto_assign(self):
"""Test if Manufacturing order is auto-assigned.""" """Test if Manufacturing order is auto-assigned."""
mo_form = Form(self.env["mrp.production"])
production = self.production_model.create( mo_form.product_id = self.product_manuf
{ mo_form.bom_id = self.bom
"product_id": self.product_manuf.id, mo_form.product_qty = 1
"product_qty": 1, production = mo_form.save()
"product_uom_id": self.uom_unit.id, production.action_confirm()
"bom_id": self.bom.id, self.assertEqual(production.reservation_state, "assigned")
}
)
self.assertEqual(production.availability, "assigned")