-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] repair_calendar_view: Migration to 16.0
- Loading branch information
Showing
56 changed files
with
468 additions
and
329 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,28 @@ | ||
# -*- coding: utf-8 -*- | ||
# (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": "MRP Repair Cancel Reason", | ||
"version": "16.0.1.0.0", | ||
"license": 'AGPL-3', | ||
"author": 'AvanzOSC', | ||
'website': "http://www.odoomrp.com", | ||
"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', | ||
'depends': ['product', | ||
'stock', | ||
'mrp', | ||
'repair', | ||
], | ||
'data': ['security/ir.model.access.csv', | ||
'data/repair_order_cancel_reason.xml', | ||
'wizard/wiz_repair_order_cancel_reason_view.xml', | ||
'views/repair_order_view.xml', | ||
'views/repair_order_cancel_reason_view.xml', | ||
], | ||
'installable': True, | ||
], | ||
"category": "Manufacturing", | ||
"depends": [ | ||
"product", | ||
"stock", | ||
"mrp", | ||
"repair", | ||
], | ||
"data": [ | ||
"security/ir.model.access.csv", | ||
"data/repair_order_cancel_reason.xml", | ||
"wizard/wiz_repair_order_cancel_reason_view.xml", | ||
"views/repair_order_view.xml", | ||
"views/repair_order_cancel_reason_view.xml", | ||
], | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# -*- coding: utf-8 -*- | ||
# (c) 2015 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
from . import repair_order |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
# -*- coding: utf-8 -*- | ||
# (c) 2015 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
from odoo import models, fields | ||
from odoo import fields, models | ||
|
||
|
||
class MrpRepair(models.Model): | ||
_inherit = 'repair.order' | ||
_inherit = "repair.order" | ||
|
||
cancel_reason_id = fields.Many2one( | ||
'repair.order.cancel.reason', string='Reason for cancellation', | ||
readonly=True, ondelete='restrict') | ||
"repair.order.cancel.reason", | ||
string="Reason for cancellation", | ||
readonly=True, | ||
ondelete="restrict", | ||
) | ||
|
||
|
||
class MrpRepairCancelReason(models.Model): | ||
_name = 'repair.order.cancel.reason' | ||
_description = 'Repair Cancel Reason' | ||
_name = "repair.order.cancel.reason" | ||
_description = "Repair Cancel Reason" | ||
|
||
name = fields.Char('Reason', required=True, translate=True) | ||
name = fields.Char("Reason", required=True, translate=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# -*- coding: utf-8 -*- | ||
# (c) 2015 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
from . import test_repair_order_cancel_reason |
55 changes: 31 additions & 24 deletions
55
mrp_repair_cancel_reason/tests/test_repair_order_cancel_reason.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,52 @@ | ||
# -*- coding: utf-8 -*- | ||
# (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 | ||
|
||
|
||
class TestMrpRepairCancelReason(common.TransactionCase): | ||
|
||
def setUp(self): | ||
super(TestMrpRepairCancelReason, self).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') | ||
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} | ||
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") | ||
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, | ||
} | ||
self.repair_order = self.repair_order_model.create(vals) | ||
self.reason = self.env.ref( | ||
'repair_order_cancel_reason.mrp_cancel_reason_customer') | ||
"repair_order_cancel_reason.mrp_cancel_reason_customer" | ||
) | ||
|
||
def test_wizard_cancel_draft_repair_with_reason(self): | ||
vals = {'reason_id': self.reason.id} | ||
vals = {"reason_id": self.reason.id} | ||
wiz = self.wiz_model.create(vals) | ||
wiz.with_context(active_ids=[self.repair_order.id]).confirm_cancel() | ||
self.assertEqual( | ||
self.repair_order.state, 'cancel', | ||
'Repair order not in CANCEL state') | ||
self.repair_order.state, "cancel", "Repair order not in CANCEL state" | ||
) | ||
self.assertEqual( | ||
self.repair_order.cancel_reason_id.id, self.reason.id, | ||
'Repair order canceled without cancel reason') | ||
self.repair_order.cancel_reason_id.id, | ||
self.reason.id, | ||
"Repair order canceled without cancel reason", | ||
) | ||
|
||
def test_wizard_cancel_confirmed_repair_with_reason(self): | ||
self.repair_order.signal_workflow('repair_confirm') | ||
vals = {'reason_id': self.reason.id} | ||
self.repair_order.signal_workflow("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() | ||
self.assertEqual( | ||
self.repair_order.state, 'cancel', | ||
'Confirmed Repair order not in CANCEL state') | ||
self.repair_order.state, | ||
"cancel", | ||
"Confirmed Repair order not in CANCEL state", | ||
) | ||
self.assertEqual( | ||
self.repair_order.cancel_reason_id.id, self.reason.id, | ||
'Confirmed Repair order canceled without cancel reason') | ||
self.repair_order.cancel_reason_id.id, | ||
self.reason.id, | ||
"Confirmed Repair order canceled without cancel reason", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# -*- coding: utf-8 -*- | ||
# (c) 2015 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
from . import wiz_repair_order_cancel_reason |
21 changes: 10 additions & 11 deletions
21
mrp_repair_cancel_reason/wizard/wiz_repair_order_cancel_reason.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,29 @@ | ||
# -*- coding: utf-8 -*- | ||
# (c) 2015 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
from odoo import models, fields, api | ||
from odoo import fields, models | ||
|
||
QUOTATION_STATES = ['draft'] | ||
QUOTATION_STATES = ["draft"] | ||
|
||
|
||
class WizMrpRepairCancelReason(models.TransientModel): | ||
|
||
_name = 'wiz.repair.order.cancel.reason' | ||
_description = 'Ask a reason from the repair cancellation' | ||
_name = "wiz.repair.order.cancel.reason" | ||
_description = "Ask a reason from the repair cancellation" | ||
|
||
reason_id = fields.Many2one( | ||
'repair.order.cancel.reason', string='Reason', required=True) | ||
"repair.order.cancel.reason", string="Reason", required=True | ||
) | ||
|
||
def confirm_cancel(self): | ||
self.ensure_one() | ||
act_close = {'type': 'ir.actions.act_window_close'} | ||
repair_ids = self.env.context.get('active_ids', False) | ||
act_close = {"type": "ir.actions.act_window_close"} | ||
repair_ids = self.env.context.get("active_ids", False) | ||
if not repair_ids: | ||
return act_close | ||
assert len(repair_ids) == 1, "Only 1 repair ID expected" | ||
repair = self.env['repair.order'].browse(repair_ids) | ||
repair = self.env["repair.order"].browse(repair_ids) | ||
repair.cancel_reason_id = self.reason_id.id | ||
if repair.state in QUOTATION_STATES: | ||
repair.signal_workflow('cancel') | ||
repair.signal_workflow("cancel") | ||
else: | ||
repair.action_cancel() | ||
return act_close |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
# (c) 2015 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
{ | ||
'name': 'MRP Repair Date', | ||
"name": "MRP Repair Date", | ||
"version": "16.0.1.0.0", | ||
"license": 'AGPL-3', | ||
"author": 'OdooMRP team,' | ||
'AvanzOSC,' | ||
'Serv. Tecnol. Avanzados - Pedro M. Baeza', | ||
'website': "http://www.odoomrp.com", | ||
"license": "AGPL-3", | ||
"author": "OdooMRP team," "AvanzOSC," "Serv. Tecnol. Avanzados - Pedro M. Baeza", | ||
"website": "https://github.com/avanzosc/mrp-repair-addons", | ||
"contributors": [ | ||
"Ana Juaristi <[email protected]>", | ||
"Oihane Crucelaegui <[email protected]>", | ||
"Alfredo de la Fuente <[email protected]>", | ||
], | ||
'category': 'Manufacturing', | ||
'depends': ['mrp_repair', | ||
], | ||
'data': ['views/mrp_repair_view.xml', | ||
], | ||
'installable': True, | ||
], | ||
"category": "Manufacturing", | ||
"depends": [ | ||
"mrp_repair", | ||
], | ||
"data": [ | ||
"views/mrp_repair_view.xml", | ||
], | ||
"installable": True, | ||
} |
Oops, something went wrong.