Skip to content

Commit

Permalink
[FIX] mrp_repair_cancel_reason: wizard does not launch + permissions …
Browse files Browse the repository at this point in the history
…+ dependencies
  • Loading branch information
oihane committed Sep 10, 2024
1 parent c518729 commit 84b972c
Show file tree
Hide file tree
Showing 11 changed files with 325 additions and 64 deletions.
7 changes: 4 additions & 3 deletions mrp_repair_cancel_reason/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

========================
MRP repair cancel reason
========================
====================
Repair cancel reason
====================

This module creates the new object "Repair Cancel Reason". When canceling a
repair, we will display a wizard in which you have to select the
"reason for cancellation". By confirming the wizard, the "reason for
Expand Down
12 changes: 3 additions & 9 deletions mrp_repair_cancel_reason/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
# (c) 2015 Alfredo de la Fuente - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
{
"name": "MRP Repair Cancel Reason",
"name": "Repair Cancel Reason",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "AvanzOSC",
"website": "https://github.com/avanzosc/mrp-repair-addons",
"contributors": [
"Ana Juaristi <[email protected]>",
"Alfredo de la Fuente <[email protected]>",
],
"category": "Manufacturing",
"category": "Inventory/Inventory",
"depends": [
"product",
"stock",
"mrp",
"repair",
"stock",
],
"data": [
"security/ir.model.access.csv",
Expand Down
124 changes: 124 additions & 0 deletions mrp_repair_cancel_reason/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_repair_cancel_reason
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-09-10 12:49+0000\n"
"PO-Revision-Date: 2024-09-10 12:49+0000\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_repair_cancel_reason
#: model:ir.model,name:mrp_repair_cancel_reason.model_wiz_repair_order_cancel_reason
msgid "Ask a reason from the repair cancellation"
msgstr ""

#. module: mrp_repair_cancel_reason
#: model_terms:ir.ui.view,arch_db:mrp_repair_cancel_reason.wiz_repair_order_cancel_reason_form_view
msgid "Cancel"
msgstr ""

#. module: mrp_repair_cancel_reason
#: model_terms:ir.ui.view,arch_db:mrp_repair_cancel_reason.view_repair_order_form_inh_cancel_reason
msgid "Cancel Repair"
msgstr "Cancelar reparación"

#. module: mrp_repair_cancel_reason
#: model:repair.order.cancel.reason,name:mrp_repair_cancel_reason.mrp_cancel_reason_customer
msgid "Canceled at customer request"
msgstr "Cancelado por petición del cliente"

#. module: mrp_repair_cancel_reason
#: model_terms:ir.ui.view,arch_db:mrp_repair_cancel_reason.wiz_repair_order_cancel_reason_form_view
msgid ""
"Choose the reason for the cancellation of the\n"
" repair."
msgstr ""

#. module: mrp_repair_cancel_reason
#: model_terms:ir.ui.view,arch_db:mrp_repair_cancel_reason.wiz_repair_order_cancel_reason_form_view
msgid "Confirm"
msgstr "Confirmar"

#. module: mrp_repair_cancel_reason
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_repair_order_cancel_reason__create_uid
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_wiz_repair_order_cancel_reason__create_uid
msgid "Created by"
msgstr "Creado por"

#. module: mrp_repair_cancel_reason
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_repair_order_cancel_reason__create_date
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_wiz_repair_order_cancel_reason__create_date
msgid "Created on"
msgstr ""

#. module: mrp_repair_cancel_reason
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_repair_order_cancel_reason__display_name
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_wiz_repair_order_cancel_reason__display_name
msgid "Display Name"
msgstr ""

#. module: mrp_repair_cancel_reason
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_repair_order_cancel_reason__id
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_wiz_repair_order_cancel_reason__id
msgid "ID"
msgstr ""

#. module: mrp_repair_cancel_reason
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_repair_order_cancel_reason____last_update
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_wiz_repair_order_cancel_reason____last_update
msgid "Last Modified on"
msgstr ""

#. module: mrp_repair_cancel_reason
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_repair_order_cancel_reason__write_uid
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_wiz_repair_order_cancel_reason__write_uid
msgid "Last Updated by"
msgstr ""

#. module: mrp_repair_cancel_reason
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_repair_order_cancel_reason__write_date
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_wiz_repair_order_cancel_reason__write_date
msgid "Last Updated on"
msgstr ""

#. module: mrp_repair_cancel_reason
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_repair_order_cancel_reason__name
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_wiz_repair_order_cancel_reason__reason_id
msgid "Reason"
msgstr ""

#. module: mrp_repair_cancel_reason
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_repair_order__cancel_reason_id
msgid "Reason for cancellation"
msgstr ""

#. module: mrp_repair_cancel_reason
#: model:ir.actions.act_window,name:mrp_repair_cancel_reason.action_repair_order_cancel_with_reason
#: model_terms:ir.ui.view,arch_db:mrp_repair_cancel_reason.wiz_repair_order_cancel_reason_form_view
msgid "Reason for the cancellation"
msgstr ""

#. module: mrp_repair_cancel_reason
#: model:ir.actions.act_window,name:mrp_repair_cancel_reason.action_repair_order_cancel_reason
#: model:ir.model,name:mrp_repair_cancel_reason.model_repair_order_cancel_reason
#: model:ir.ui.menu,name:mrp_repair_cancel_reason.menu_repair_order_cancel_reason
msgid "Repair Cancel Reason"
msgstr ""

#. module: mrp_repair_cancel_reason
#: model:ir.model,name:mrp_repair_cancel_reason.model_repair_order
msgid "Repair Order"
msgstr "Orden de reparación"

#. module: mrp_repair_cancel_reason
#: model_terms:ir.ui.view,arch_db:mrp_repair_cancel_reason.wiz_repair_order_cancel_reason_form_view
msgid "or"
msgstr ""
124 changes: 124 additions & 0 deletions mrp_repair_cancel_reason/i18n/mrp_repair_cancel_reason.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_repair_cancel_reason
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-09-10 12:49+0000\n"
"PO-Revision-Date: 2024-09-10 12:49+0000\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_repair_cancel_reason
#: model:ir.model,name:mrp_repair_cancel_reason.model_wiz_repair_order_cancel_reason
msgid "Ask a reason from the repair cancellation"
msgstr ""

#. module: mrp_repair_cancel_reason
#: model_terms:ir.ui.view,arch_db:mrp_repair_cancel_reason.wiz_repair_order_cancel_reason_form_view
msgid "Cancel"
msgstr ""

#. module: mrp_repair_cancel_reason
#: model_terms:ir.ui.view,arch_db:mrp_repair_cancel_reason.view_repair_order_form_inh_cancel_reason
msgid "Cancel Repair"
msgstr ""

#. module: mrp_repair_cancel_reason
#: model:repair.order.cancel.reason,name:mrp_repair_cancel_reason.mrp_cancel_reason_customer
msgid "Canceled at customer request"
msgstr ""

#. module: mrp_repair_cancel_reason
#: model_terms:ir.ui.view,arch_db:mrp_repair_cancel_reason.wiz_repair_order_cancel_reason_form_view
msgid ""
"Choose the reason for the cancellation of the\n"
" repair."
msgstr ""

#. module: mrp_repair_cancel_reason
#: model_terms:ir.ui.view,arch_db:mrp_repair_cancel_reason.wiz_repair_order_cancel_reason_form_view
msgid "Confirm"
msgstr ""

#. module: mrp_repair_cancel_reason
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_repair_order_cancel_reason__create_uid
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_wiz_repair_order_cancel_reason__create_uid
msgid "Created by"
msgstr ""

#. module: mrp_repair_cancel_reason
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_repair_order_cancel_reason__create_date
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_wiz_repair_order_cancel_reason__create_date
msgid "Created on"
msgstr ""

#. module: mrp_repair_cancel_reason
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_repair_order_cancel_reason__display_name
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_wiz_repair_order_cancel_reason__display_name
msgid "Display Name"
msgstr ""

#. module: mrp_repair_cancel_reason
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_repair_order_cancel_reason__id
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_wiz_repair_order_cancel_reason__id
msgid "ID"
msgstr ""

#. module: mrp_repair_cancel_reason
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_repair_order_cancel_reason____last_update
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_wiz_repair_order_cancel_reason____last_update
msgid "Last Modified on"
msgstr ""

#. module: mrp_repair_cancel_reason
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_repair_order_cancel_reason__write_uid
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_wiz_repair_order_cancel_reason__write_uid
msgid "Last Updated by"
msgstr ""

#. module: mrp_repair_cancel_reason
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_repair_order_cancel_reason__write_date
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_wiz_repair_order_cancel_reason__write_date
msgid "Last Updated on"
msgstr ""

#. module: mrp_repair_cancel_reason
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_repair_order_cancel_reason__name
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_wiz_repair_order_cancel_reason__reason_id
msgid "Reason"
msgstr ""

#. module: mrp_repair_cancel_reason
#: model:ir.model.fields,field_description:mrp_repair_cancel_reason.field_repair_order__cancel_reason_id
msgid "Reason for cancellation"
msgstr ""

#. module: mrp_repair_cancel_reason
#: model:ir.actions.act_window,name:mrp_repair_cancel_reason.action_repair_order_cancel_with_reason
#: model_terms:ir.ui.view,arch_db:mrp_repair_cancel_reason.wiz_repair_order_cancel_reason_form_view
msgid "Reason for the cancellation"
msgstr ""

#. module: mrp_repair_cancel_reason
#: model:ir.actions.act_window,name:mrp_repair_cancel_reason.action_repair_order_cancel_reason
#: model:ir.model,name:mrp_repair_cancel_reason.model_repair_order_cancel_reason
#: model:ir.ui.menu,name:mrp_repair_cancel_reason.menu_repair_order_cancel_reason
msgid "Repair Cancel Reason"
msgstr ""

#. module: mrp_repair_cancel_reason
#: model:ir.model,name:mrp_repair_cancel_reason.model_repair_order
msgid "Repair Order"
msgstr ""

#. module: mrp_repair_cancel_reason
#: model_terms:ir.ui.view,arch_db:mrp_repair_cancel_reason.wiz_repair_order_cancel_reason_form_view
msgid "or"
msgstr ""
22 changes: 19 additions & 3 deletions mrp_repair_cancel_reason/models/repair_order.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
# (c) 2015 Alfredo de la Fuente - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from odoo import fields, models
from odoo import _, fields, models
from odoo.exceptions import UserError


class MrpRepair(models.Model):
_inherit = "repair.order"

cancel_reason_id = fields.Many2one(
"repair.order.cancel.reason",
comodel_name="repair.order.cancel.reason",
string="Reason for cancellation",
readonly=True,
copy=False,
ondelete="restrict",
)

def action_repair_cancel(self):
if any(repair.state == 'done' for repair in self):
raise UserError(_("You cannot cancel a completed repair order."))
if not all(repair.cancel_reason_id for repair in self):
action = self.env["ir.actions.actions"]._for_xml_id("mrp_repair_cancel_reason.action_repair_order_cancel_with_reason")
action["context"] = dict(self._context, create=False)
return action

return super().action_repair_cancel()


class MrpRepairCancelReason(models.Model):
_name = "repair.order.cancel.reason"
_description = "Repair Cancel Reason"

name = fields.Char("Reason", required=True, translate=True)
name = fields.Char(
string="Reason",
required=True,
translate=True,
)
5 changes: 3 additions & 2 deletions mrp_repair_cancel_reason/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_repair_order_cancel_reason_user,access_repair_order_cancel_reason user,model_repair_order_cancel_reason,mrp.group_mrp_user,1,0,0,0
access_repair_order_cancel_reason_manager,access_repair_order_cancel_reason manager,model_repair_order_cancel_reason,mrp.group_mrp_manager,1,1,1,1
access_repair_order_cancel_reason_user,access_repair_order_cancel_reason user,model_repair_order_cancel_reason,stock.group_stock_user,1,0,0,0
access_repair_order_cancel_reason_manager,access_repair_order_cancel_reason manager,model_repair_order_cancel_reason,stock.group_stock_manager,1,1,1,1
access_wiz_repair_order_cancel_reason,access_wiz_repair_order_cancel_reason,mrp_repair_cancel_reason.model_wiz_repair_order_cancel_reason,stock.group_stock_user,1,1,1,1
36 changes: 19 additions & 17 deletions mrp_repair_cancel_reason/tests/test_repair_order_cancel_reason.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
# (c) 2015 Alfredo de la Fuente - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
import openerp.tests.common as common

from odoo.tests import common, tagged


@tagged("post_install", "-at_install")
class TestMrpRepairCancelReason(common.TransactionCase):

def setUp(self):
super().setUp()
self.data_model = self.env["ir.model.data"]
self.repair_order_model = self.env["repair.order"]
self.wiz_model = self.env["wiz.repair.order.cancel.reason"]
self.product = self.env.ref("product.product_product_6")
self.warehouse = self.data_model.get_object("stock", "warehouse0")
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.data_model = cls.env["ir.model.data"]
cls.repair_order_model = cls.env["repair.order"]
cls.wiz_model = cls.env["wiz.repair.order.cancel.reason"]
cls.product = cls.env.ref("product.product_product_6")
cls.warehouse = cls.env["stock.warehouse"].search(
[("company_id", "=", cls.env.company.id)], limit=1
)
vals = {
"product_id": self.product.id,
"location_id": self.warehouse.lot_stock_id.id,
"location_dest_id": self.warehouse.lot_stock_id.id,
"product_uom": self.product.uom_id.id,
"product_id": cls.product.id,
"location_id": cls.warehouse.lot_stock_id.id,
"product_uom": cls.product.uom_id.id,
}
self.repair_order = self.repair_order_model.create(vals)
self.reason = self.env.ref(
"repair_order_cancel_reason.mrp_cancel_reason_customer"
)
cls.repair_order = cls.repair_order_model.create(vals)
cls.reason = cls.env.ref("mrp_repair_cancel_reason.mrp_cancel_reason_customer")

def test_wizard_cancel_draft_repair_with_reason(self):
vals = {"reason_id": self.reason.id}
Expand All @@ -37,7 +39,7 @@ def test_wizard_cancel_draft_repair_with_reason(self):
)

def test_wizard_cancel_confirmed_repair_with_reason(self):
self.repair_order.signal_workflow("repair_confirm")
self.repair_order.action_repair_confirm()
vals = {"reason_id": self.reason.id}
wiz = self.wiz_model.create(vals)
wiz.with_context(active_ids=[self.repair_order.id]).confirm_cancel()
Expand Down
Loading

0 comments on commit 84b972c

Please sign in to comment.