diff --git a/cancel_mo/__manifest__.py b/cancel_mo/__manifest__.py
index 43ab1cb2c..b3e6403dd 100644
--- a/cancel_mo/__manifest__.py
+++ b/cancel_mo/__manifest__.py
@@ -21,7 +21,7 @@
###############################################################################
{
'name': 'Cancel Manufacturing Order',
- 'version': '17.0.1.0.0',
+ 'version': '17.0.2.1.1',
'summary': 'You can cancell the manufcturing order',
'category': 'Manufcturing',
'description': 'This is used to cancel the manufcatring order and also '
@@ -39,7 +39,7 @@
],
'license': 'LGPL-3',
'installable': True,
- 'application': False,
'auto_install': False,
+ 'application': False,
}
diff --git a/cancel_mo/models/mrp_production.py b/cancel_mo/models/mrp_production.py
index 668e6fb74..121f1fa8d 100644
--- a/cancel_mo/models/mrp_production.py
+++ b/cancel_mo/models/mrp_production.py
@@ -20,23 +20,29 @@
#
#############################################################################
from collections import defaultdict
-from odoo import models
+from odoo import fields, models
class MrpProduction(models.Model):
"""inheriting mrp.production to add more functionality"""
_inherit = 'mrp.production'
+ cancel_inventory_moves = fields.Boolean(string="Cancel Inventory Moves",
+ help="Whether to cancel "
+ "the inventory moves")
+ cancel_workorder = fields.Boolean(string="Cancel WorkOrder",
+ help="Whether to cancel "
+ "the work order")
+
def action_cancel_mo(self):
"""Cancels the mo"""
- self.action_cancel()
- self.state = 'cancel'
inventory_move_status = self.env[
'ir.config_parameter'].sudo().get_param(
'cancel_mo.is_cancel_inventory_moves')
work_order_status = self.env['ir.config_parameter'].sudo().get_param(
'cancel_mo.is_cancel_workorder')
if inventory_move_status:
+ self.state = 'cancel'
move_lines_ids = self.env['stock.move.line'].search(
[('reference', '=', self.name)])
for rec in move_lines_ids:
@@ -49,7 +55,7 @@ class MrpProduction(models.Model):
rec.action_cancel()
def _action_cancel(self):
- """Overriding the cancel methode"""
+ """Overriding the cancel method"""
documents_by_production = {}
for production in self:
documents = defaultdict(list)
diff --git a/cancel_mo/models/res_config_settings.py b/cancel_mo/models/res_config_settings.py
index 6ff62f142..fba712b4c 100644
--- a/cancel_mo/models/res_config_settings.py
+++ b/cancel_mo/models/res_config_settings.py
@@ -19,7 +19,7 @@
# If not, see .
#
#############################################################################
-from odoo import fields, models
+from odoo import api, fields, models
class ResConfigSettings(models.TransientModel):
@@ -34,3 +34,15 @@ class ResConfigSettings(models.TransientModel):
help="Whether to cancel the work order",
config_parameter="cancel_mo"
".is_cancel_workorder")
+
+ @api.onchange('is_cancel_inventory_moves', 'is_cancel_inventory_moves')
+ def _onchange_cancel_mo(self):
+ """Onchange function to write corresponding boolean fields in
+ mrp_production"""
+ mrp_orders = self.env['mrp.production'].search([('state', '=', 'done')])
+ if self.is_cancel_inventory_moves:
+ mrp_orders.write(
+ {'cancel_inventory_moves': self.is_cancel_inventory_moves})
+ if self.is_cancel_workorder:
+ mrp_orders.write(
+ {'cancel_workorder': self.is_cancel_workorder})
diff --git a/cancel_mo/views/mrp_production_views.xml b/cancel_mo/views/mrp_production_views.xml
index b1f15db75..22d0f0c7a 100644
--- a/cancel_mo/views/mrp_production_views.xml
+++ b/cancel_mo/views/mrp_production_views.xml
@@ -6,9 +6,14 @@
+
+
+
+
-
\ No newline at end of file
+