Browse Source

May 14: [FIX] Bug Fixed 'cancel_mo'

pull/317/head
RisvanaCybro 12 months ago
parent
commit
471d0ec920
  1. 4
      cancel_mo/__manifest__.py
  2. 14
      cancel_mo/models/mrp_production.py
  3. 14
      cancel_mo/models/res_config_settings.py
  4. 9
      cancel_mo/views/mrp_production_views.xml

4
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,
}

14
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)

14
cancel_mo/models/res_config_settings.py

@ -19,7 +19,7 @@
# If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################
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})

9
cancel_mo/views/mrp_production_views.xml

@ -6,9 +6,14 @@
<field name="inherit_id" ref="mrp.mrp_production_form_view"/>
<field name="arch" type="xml">
<button name="action_cancel" position="before">
<button name="action_cancel_mo" invisible="state != 'done'"
<button name="action_cancel_mo"
invisible="state != 'done' or cancel_inventory_moves != True and cancel_workorder != True"
type="object" string="Cancel"/>
</button>
<field name="lot_producing_id" position="after">
<field name="cancel_inventory_moves" invisible="1"/>
<field name="cancel_workorder" invisible="1"/>
</field>
</field>
</record>
</odoo>
</odoo>

Loading…
Cancel
Save