Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][MIG] mrp_production_back_to_draft: Migration to 16.0 #1431

Open
wants to merge 9 commits into
base: 16.0
Choose a base branch
from
Open
77 changes: 77 additions & 0 deletions mrp_production_back_to_draft/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
============================
MRP Production Back to Draft
============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:08cbd81c049ee4f4b818d59d4bfa0d0bff3e0ac4cc0fdb985a61d12bbb9caa4e
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github
:target: https://github.com/OCA/manufacture/tree/16.0/mrp_production_back_to_draft
:alt: OCA/manufacture
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/manufacture-16-0/manufacture-16-0-mrp_production_back_to_draft
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/manufacture&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows to return to draft a confirmed or cancelled MO.

**Table of contents**

.. contents::
:local:

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 to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/manufacture/issues/new?body=module:%20mrp_production_back_to_draft%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.

Credits
=======

Authors
-------

* ForgeFlow

Contributors
------------

- David Jiménez <[email protected]>
- Meritxell Abellan <[email protected]>

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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/16.0/mrp_production_back_to_draft>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions mrp_production_back_to_draft/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2024 ForgeFlow S.L. (http://www.forgeflow.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import models
17 changes: 17 additions & 0 deletions mrp_production_back_to_draft/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2024 ForgeFlow S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "MRP Production Back to Draft",
"version": "16.0.1.0.0",
"author": "ForgeFlow, Odoo Community Association (OCA)",
"summary": "Allows to return to draft a confirmed or cancelled MO.",
"website": "https://github.com/OCA/manufacture",
"category": "Manufacturing/Manufacturing",
"license": "AGPL-3",
"depends": ["mrp"],
"data": [
"views/mrp_production_views.xml",
],
"installable": True,
}
52 changes: 52 additions & 0 deletions mrp_production_back_to_draft/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_production_back_to_draft
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-12-19 10:06+0000\n"
"Last-Translator: mymage <[email protected]>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 5.6.2\n"

#. module: mrp_production_back_to_draft
#: model:ir.model.fields,field_description:mrp_production_back_to_draft.field_mrp_production__display_name
msgid "Display Name"
msgstr "Nome visualizzato"

#. module: mrp_production_back_to_draft
#: model:ir.model.fields,field_description:mrp_production_back_to_draft.field_mrp_production__id
msgid "ID"
msgstr "ID"

#. module: mrp_production_back_to_draft
#: model:ir.model.fields,field_description:mrp_production_back_to_draft.field_mrp_production____last_update
msgid "Last Modified on"
msgstr "Ultima modifica il"

#. module: mrp_production_back_to_draft
#: model:ir.model,name:mrp_production_back_to_draft.model_mrp_production
msgid "Production Order"
msgstr "Ordine di produzione"

#. module: mrp_production_back_to_draft
#: model_terms:ir.ui.view,arch_db:mrp_production_back_to_draft.mrp_production_form_view_return_to_draft
msgid "Return to Draft"
msgstr "Riporta a bozza"

#. module: mrp_production_back_to_draft
#: code:addons/mrp_production_back_to_draft/models/mrp_production.py:0
#, python-format
msgid ""
"You cannot return to draft the following MO: %s. Only confirmed or cancelled"
" MO can be returned to draft."
msgstr ""
"Non si può riportare a bozza il seguente OP: %s. Solo OP confermati o "
"annullati possono essere riportati a bozza."
40 changes: 40 additions & 0 deletions mrp_production_back_to_draft/i18n/mrp_production_back_to_draft.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_production_back_to_draft
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: mrp_production_back_to_draft
#. odoo-python
#: code:addons/mrp_production_back_to_draft/models/mrp_production.py:0
#, python-format
msgid "Could not set the production order back to draft"
msgstr ""

#. module: mrp_production_back_to_draft
#: model:ir.model,name:mrp_production_back_to_draft.model_mrp_production
msgid "Production Order"
msgstr ""

#. module: mrp_production_back_to_draft
#: model_terms:ir.ui.view,arch_db:mrp_production_back_to_draft.mrp_production_form_view_return_to_draft
msgid "Return to Draft"
msgstr ""

#. module: mrp_production_back_to_draft
#. odoo-python
#: code:addons/mrp_production_back_to_draft/models/mrp_production.py:0
#, python-format
msgid ""
"You cannot return to draft the following MO: %s. Only confirmed or cancelled"
" MO can be returned to draft."
msgstr ""
4 changes: 4 additions & 0 deletions mrp_production_back_to_draft/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2024 ForgeFlow S.L. (http://www.forgeflow.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import mrp_production
41 changes: 41 additions & 0 deletions mrp_production_back_to_draft/models/mrp_production.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2024 ForgeFlow S.L. (http://www.forgeflow.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import _, api, models
from odoo.exceptions import UserError


class MrpProduction(models.Model):
_inherit = "mrp.production"

def action_return_to_draft(self):
self._check_company()
for rec in self:
if rec.state not in ["confirmed", "cancel"]:
raise UserError(
_(
"You cannot return to draft the following MO: %s. "
"Only confirmed or cancelled MO can be returned to draft."
)
% rec.name
)
else:
(rec.move_raw_ids + rec.move_finished_ids)._action_cancel()
(rec.move_raw_ids + rec.move_finished_ids).write({"state": "draft"})
rec.workorder_ids.write({"state": "waiting"})
if rec.state != "draft":
raise UserError(

Check warning on line 27 in mrp_production_back_to_draft/models/mrp_production.py

View check run for this annotation

Codecov / codecov/patch

mrp_production_back_to_draft/models/mrp_production.py#L27

Added line #L27 was not covered by tests
_("Could not set the production order back to draft")
)

@api.depends("move_raw_ids.state", "move_finished_ids.state")
def _compute_state(self):
super()._compute_state()
for production in self:
if (
production.state == "cancel"
and all(m.state == "draft" for m in production.move_raw_ids)
and all(m.state == "draft" for m in production.move_finished_ids)
):
production.state = "draft"
return
3 changes: 3 additions & 0 deletions mrp_production_back_to_draft/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
2 changes: 2 additions & 0 deletions mrp_production_back_to_draft/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- David Jiménez \<<[email protected]>\>
- Meritxell Abellan \<<[email protected]>\>
1 change: 1 addition & 0 deletions mrp_production_back_to_draft/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module allows to return to draft a confirmed or cancelled MO.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading