[MIG] mo_back_to_draft to 18.0

This commit is contained in:
Marc Durepos 2025-09-10 14:18:26 -04:00
parent 59fa4703ab
commit 73c74412e0
5 changed files with 67 additions and 0 deletions

View file

@ -0,0 +1 @@
from . import models

View file

@ -0,0 +1,33 @@
#
# Bemade Inc.
#
# Copyright (C) 2023-June Bemade Inc. (<https://www.bemade.org>).
# Author: Marc Durepos (Contact : marc@bemade.org)
#
# This program is under the terms of the GNU Lesser General Public License,
# version 3.
#
# For full license details, see https://www.gnu.org/licenses/lgpl-3.0.en.html.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
{
"name": "MO Back to Draft",
"version": "18.0.1.0.0",
"summary": "Allow putting an MO back to draft state",
"category": "Manufacturing/Manufacturing",
"author": "Bemade Inc.",
"website": "http://www.bemade.org",
"license": "LGPL-3",
"depends": ["mrp"],
"data": ["views/mrp_production_views.xml"],
"assets": {},
"installable": True,
"auto_install": False,
}

View file

@ -0,0 +1 @@
from . import mrp_production

View file

@ -0,0 +1,16 @@
from odoo import models, fields, _
from odoo.exceptions import UserError
class MrpProduction(models.Model):
_inherit = "mrp.production"
def action_back_to_draft(self):
self.ensure_one()
if self.state != 'cancel':
raise UserError(_(
'Only manufacturing orders in canceled'
'state can be set back to draft.'
))
self.state = False
return True

View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="mrp_production_view_form_inherit" model="ir.ui.view">
<field name="name">mrp.production.view.form.inherit</field>
<field name="inherit_id" ref="mrp.mrp_production_form_view"/>
<field name="model">mrp.production</field>
<field name="arch" type="xml">
<header position="inside">
<button name="action_back_to_draft"
invisible="state != 'cancel'"
type="object"
string="Back to Draft"/>
</header>
</field>
</record>
</odoo>