@ -0,0 +1,39 @@ |
|||||
|
.. image:: https://img.shields.io/badge/license-LGPL--3-green.svg |
||||
|
:target: https://www.gnu.org/licenses/lgpl.html |
||||
|
:alt: License: LGPL-3 |
||||
|
|
||||
|
Cancel Manufacturing Order |
||||
|
========================= |
||||
|
This is used to cancel the Manufacturing Order and also cancel the inventory moves and work orders along with the mo cancellation |
||||
|
|
||||
|
Company |
||||
|
------- |
||||
|
* `Cybrosys Techno Solutions <https://cybrosys.com/>`__ |
||||
|
|
||||
|
Credits |
||||
|
------- |
||||
|
Developer:(V17) Gayathri V |
||||
|
(V18) Anzil K A |
||||
|
Contact: odoo@cybrosys.com |
||||
|
|
||||
|
Contacts |
||||
|
-------- |
||||
|
* Mail Contact : odoo@cybrosys.com |
||||
|
* Website : https://cybrosys.com |
||||
|
|
||||
|
Bug Tracker |
||||
|
----------- |
||||
|
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. |
||||
|
|
||||
|
Maintainer |
||||
|
========== |
||||
|
.. image:: https://cybrosys.com/images/logo.png |
||||
|
:target: https://cybrosys.com |
||||
|
|
||||
|
This module is maintained by Cybrosys Technologies. |
||||
|
|
||||
|
For support and more information, please visit `Our Website <https://cybrosys.com/>`__ |
||||
|
|
||||
|
Further information |
||||
|
=================== |
||||
|
HTML Description: `<static/description/index.html>`__ |
@ -0,0 +1,22 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################### |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Anzil K A (odoo@cybrosys.com) |
||||
|
# |
||||
|
# This program is free software: you can modify |
||||
|
# it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE (LGPL) as |
||||
|
# published by the Free Software Foundation, either version 3 of the |
||||
|
# License, or (at your option) any later version. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU LESSER GENERAL PUBLIC LICENSE for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################### |
||||
|
from . import models |
@ -0,0 +1,44 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################### |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Anzil K A (odoo@cybrosys.com) |
||||
|
# |
||||
|
# This program is free software: you can modify |
||||
|
# it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE (LGPL) as |
||||
|
# published by the Free Software Foundation, either version 3 of the |
||||
|
# License, or (at your option) any later version. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU LESSER GENERAL PUBLIC LICENSE for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################### |
||||
|
{ |
||||
|
'name': 'Cancel Manufacturing Order', |
||||
|
'version': '18.0.1.0.0', |
||||
|
'summary': 'You can cancell the manufcturing order', |
||||
|
'category': 'Manufcturing', |
||||
|
'description': 'This is used to cancel the manufcatring order and also ' |
||||
|
'cancel the inventory moves and work orders along with the ' |
||||
|
'mo cancellation.', |
||||
|
'author': 'Cybrosys Techno Solutions', |
||||
|
'company': 'Cybrosys Techno Solutions', |
||||
|
'maintainer': 'Cybrosys Techno Solutions', |
||||
|
'images': ['static/description/banner.jpg'], |
||||
|
'website': 'https://www.cybrosys.com', |
||||
|
'depends': ['mrp'], |
||||
|
'data': [ |
||||
|
'views/mrp_production_views.xml', |
||||
|
'views/res_config_settings_views.xml', |
||||
|
], |
||||
|
'license': 'LGPL-3', |
||||
|
'installable': True, |
||||
|
'auto_install': False, |
||||
|
'application': False, |
||||
|
} |
@ -0,0 +1,7 @@ |
|||||
|
## Module <cancel_mo> |
||||
|
|
||||
|
#### 19.03.2025 |
||||
|
#### Version 18.0.1.0.0 |
||||
|
#### ADD |
||||
|
|
||||
|
- Initial commit for Cancel Manufacturing Order |
@ -0,0 +1,23 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################### |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Anzil K A (odoo@cybrosys.com) |
||||
|
# |
||||
|
# This program is free software: you can modify |
||||
|
# it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE (LGPL) as |
||||
|
# published by the Free Software Foundation, either version 3 of the |
||||
|
# License, or (at your option) any later version. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU LESSER GENERAL PUBLIC LICENSE for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################### |
||||
|
from . import res_config_settings |
||||
|
from . import mrp_production |
@ -0,0 +1,129 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################### |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Anzil K A (odoo@cybrosys.com) |
||||
|
# |
||||
|
# This program is free software: you can modify |
||||
|
# it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE (LGPL) as |
||||
|
# published by the Free Software Foundation, either version 3 of the |
||||
|
# License, or (at your option) any later version. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU LESSER GENERAL PUBLIC LICENSE for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################### |
||||
|
from collections import defaultdict |
||||
|
from odoo import fields, models |
||||
|
|
||||
|
|
||||
|
class MrpProduction(models.Model): |
||||
|
"""inheriting mrp.production to add more functionality""" |
||||
|
_inherit = 'mrp.production' |
||||
|
|
||||
|
def _default_cancel_inventory(self): |
||||
|
"""To set default value from configration settings""" |
||||
|
is_cancel_inventory_moves = self.env[ |
||||
|
'ir.config_parameter'].sudo().get_param( |
||||
|
'cancel_mo.is_cancel_inventory_moves') |
||||
|
return is_cancel_inventory_moves |
||||
|
|
||||
|
def _default_cancel_workorder(self): |
||||
|
"""To set default value from configration settings""" |
||||
|
is_cancel_workorder = self.env['ir.config_parameter'].sudo().get_param( |
||||
|
'cancel_mo.is_cancel_workorder') |
||||
|
return is_cancel_workorder |
||||
|
|
||||
|
cancel_inventory_moves = fields.Boolean( |
||||
|
string="Cancel Inventory Moves", |
||||
|
default=_default_cancel_inventory, |
||||
|
help="Whether to cancel the inventory moves") |
||||
|
cancel_workorder = fields.Boolean( |
||||
|
string="Cancel WorkOrder", |
||||
|
default=_default_cancel_workorder, |
||||
|
help="Whether to cancel the work order") |
||||
|
|
||||
|
def action_cancel_mo(self): |
||||
|
"""Cancels the mo""" |
||||
|
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: |
||||
|
rec.write({'state': 'cancel'}) |
||||
|
|
||||
|
if work_order_status: |
||||
|
work_order_ids = self.env['mrp.workorder'].search( |
||||
|
[('production_id', '=', self.id)]) |
||||
|
for rec in work_order_ids: |
||||
|
rec.action_cancel() |
||||
|
|
||||
|
def _action_cancel(self): |
||||
|
"""Overriding the cancel method""" |
||||
|
documents_by_production = {} |
||||
|
for production in self: |
||||
|
documents = defaultdict(list) |
||||
|
for move_raw_id in self.move_raw_ids.filtered( |
||||
|
lambda m: m.state not in ('done', 'cancel')): |
||||
|
iterate_key = self._get_document_iterate_key(move_raw_id) |
||||
|
if iterate_key: |
||||
|
document = self.env[ |
||||
|
'stock.picking']._log_activity_get_documents( |
||||
|
{move_raw_id: (move_raw_id.product_uom_qty, 0)}, |
||||
|
iterate_key, 'UP') |
||||
|
for key, value in document.items(): |
||||
|
documents[key] += [value] |
||||
|
if documents: |
||||
|
documents_by_production[production] = documents |
||||
|
# log an activity on Parent MO if child MO is cancelled. |
||||
|
finish_moves = production.move_finished_ids.filtered( |
||||
|
lambda x: x.state not in ('done', 'cancel')) |
||||
|
if finish_moves: |
||||
|
production._log_downside_manufactured_quantity( |
||||
|
{finish_move: (production.product_uom_qty, 0.0) for |
||||
|
finish_move in finish_moves}, cancel=True) |
||||
|
|
||||
|
self.workorder_ids.filtered( |
||||
|
lambda x: x.state not in ['cancel']).action_cancel() |
||||
|
finish_moves = self.move_finished_ids.filtered( |
||||
|
lambda x: x.state not in ('done', 'cancel')) |
||||
|
raw_moves = self.move_raw_ids.filtered( |
||||
|
lambda x: x.state not in ('done', 'cancel')) |
||||
|
(finish_moves | raw_moves)._action_cancel() |
||||
|
picking_ids = self.picking_ids.filtered( |
||||
|
lambda x: x.state not in ('cancel')) |
||||
|
picking_ids.action_cancel() |
||||
|
|
||||
|
for production, documents in documents_by_production.items(): |
||||
|
filtered_documents = {} |
||||
|
for (parent, responsible), rendering_context in documents.items(): |
||||
|
if not parent or parent._name == 'stock.picking' and parent.state == 'cancel' or parent == production: |
||||
|
continue |
||||
|
filtered_documents[(parent, responsible)] = rendering_context |
||||
|
production._log_manufacture_exception(filtered_documents, |
||||
|
cancel=True) |
||||
|
|
||||
|
# In case of a flexible BOM, we don't know from the state of the moves if the MO should |
||||
|
# remain in progress or done. Indeed, if all moves are done/cancel but the quantity produced |
||||
|
# is lower than expected, it might mean: |
||||
|
# - we have used all components but we still want to produce the quantity expected |
||||
|
# - we have used all components and we won't be able to produce the last units |
||||
|
# |
||||
|
# However, if the user clicks on 'Cancel', it is expected that the MO is either done or |
||||
|
# canceled. If the MO is still in progress at this point, it means that the move raws |
||||
|
# are either all done or a mix of done / canceled => the MO should be done. |
||||
|
self.filtered(lambda p: p.state not in ['done', |
||||
|
'cancel'] and p.bom_id.consumption == 'flexible').write( |
||||
|
{'state': 'done'}) |
||||
|
return True |
@ -0,0 +1,36 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################### |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Anzil K A (odoo@cybrosys.com) |
||||
|
# |
||||
|
# This program is free software: you can modify |
||||
|
# it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE (LGPL) as |
||||
|
# published by the Free Software Foundation, either version 3 of the |
||||
|
# License, or (at your option) any later version. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU LESSER GENERAL PUBLIC LICENSE for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################### |
||||
|
from odoo import api, fields, models |
||||
|
|
||||
|
|
||||
|
class ResConfigSettings(models.TransientModel): |
||||
|
_inherit = 'res.config.settings' |
||||
|
|
||||
|
is_cancel_inventory_moves = fields.Boolean(string="Cancel Inventory Moves", |
||||
|
help="Whether to cancel the " |
||||
|
"inventory moves", |
||||
|
config_parameter="cancel_mo" |
||||
|
".is_cancel_inventory_moves") |
||||
|
is_cancel_workorder = fields.Boolean(string="Cancel WorkOrder", |
||||
|
help="Whether to cancel the work order", |
||||
|
config_parameter="cancel_mo" |
||||
|
".is_cancel_workorder") |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 210 KiB |
After Width: | Height: | Size: 209 KiB |
After Width: | Height: | Size: 109 KiB |
After Width: | Height: | Size: 495 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 624 B |
After Width: | Height: | Size: 136 KiB |
After Width: | Height: | Size: 214 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 310 B |
After Width: | Height: | Size: 929 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 542 B |
After Width: | Height: | Size: 576 B |
After Width: | Height: | Size: 733 B |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 738 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 911 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 600 B |
After Width: | Height: | Size: 673 B |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 926 B |
After Width: | Height: | Size: 9.0 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 878 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 653 B |
After Width: | Height: | Size: 800 B |
After Width: | Height: | Size: 905 B |
After Width: | Height: | Size: 189 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 839 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 427 B |
After Width: | Height: | Size: 627 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 988 B |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 875 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 80 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 589 B |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 565 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 967 B |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 43 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 38 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 767 KiB |
After Width: | Height: | Size: 138 KiB |
After Width: | Height: | Size: 760 KiB |
After Width: | Height: | Size: 92 KiB |
After Width: | Height: | Size: 697 KiB |