@ -0,0 +1,50 @@ |
|||
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.svg |
|||
:target: https://www.gnu.org/licenses/agpl-3.0-standalone.html |
|||
:alt: License: AGPL-3 |
|||
|
|||
Cancel Manufacturing Order |
|||
========================== |
|||
* Allows users to cancel done manufacturing order.Added a button "CANCEL" for |
|||
cancelling the manufacturing order. |
|||
|
|||
Configuration |
|||
============= |
|||
* No additional configurations needed |
|||
|
|||
License |
|||
------- |
|||
GNU Affero General Public License v3.0 (AGPL v3) |
|||
(https://www.gnu.org/licenses/agpl-3.0-standalone.html) |
|||
|
|||
Company |
|||
------- |
|||
* `Cybrosys Techno Solutions <https://cybrosys.com/>`__ |
|||
|
|||
Credits |
|||
------- |
|||
Developer: (V17) - Nivedhya T, |
|||
(V18) Busthana Shirin, |
|||
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 https://www.cybrosys.com |
|||
|
|||
Further information |
|||
=================== |
|||
HTML Description: `<static/description/index.html>`__ |
|||
@ -0,0 +1,22 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
|||
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
|||
# |
|||
# You can modify it under the terms of the GNU AFFERO |
|||
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
|||
# |
|||
# 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|||
# (AGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
from . import models |
|||
@ -0,0 +1,46 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
|||
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
|||
# |
|||
# You can modify it under the terms of the GNU AFFERO |
|||
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
|||
# |
|||
# 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|||
# (AGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
{ |
|||
'name': 'Cancel Manufacturing Order', |
|||
'version': '18.0.1.0.0', |
|||
'category': 'Manufacturing', |
|||
'summary': 'Allows users to cancel manufacturing order by clicking ' |
|||
'the button "CANCEL"', |
|||
'description': 'Allow users to cancel manufacturing orders' |
|||
'by clicking on "CANCEL" button. Also able to cancel ' |
|||
'multiple manufacturing orders from tree view by clicking ' |
|||
'on the Cancel Manufacturing Order" from Action menu', |
|||
'author': 'Cybrosys Techno Solutions', |
|||
'maintainer': 'Cybrosys Techno Solutions', |
|||
'company': 'Cybrosys Techno Solutions', |
|||
'website': 'https://www.cybrosys.com', |
|||
'depends': ['base', 'mrp'], |
|||
'data': [ |
|||
'security/cancel_mrp_order_groups.xml', |
|||
'views/mrp_production_views.xml', |
|||
], |
|||
'images': ['static/description/banner.jpg'], |
|||
'license': 'AGPL-3', |
|||
'installable': True, |
|||
'auto_install': False, |
|||
'application': False, |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
## Module <cancel_mrp_order> |
|||
|
|||
#### 27.05.2025 |
|||
#### Version 18.0.1.0.0 |
|||
#### ADD |
|||
|
|||
- Initial Commit for Cancel Manufacturing Order |
|||
@ -0,0 +1,22 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
|||
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
|||
# |
|||
# You can modify it under the terms of the GNU AFFERO |
|||
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
|||
# |
|||
# 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|||
# (AGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
from . import mrp_production |
|||
@ -0,0 +1,134 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
|||
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
|||
# |
|||
# You can modify it under the terms of the GNU AFFERO |
|||
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
|||
# |
|||
# 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|||
# (AGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
from odoo import models, _ |
|||
from odoo.exceptions import UserError |
|||
from odoo.tools import float_round |
|||
from collections import defaultdict |
|||
|
|||
|
|||
class MrpProduction(models.Model): |
|||
"""Inherit manufacturing order to add some function """ |
|||
_inherit = 'mrp.production' |
|||
|
|||
def checking_access(self, rec): |
|||
"""Warning for cancel button in action""" |
|||
if self.state == 'done': |
|||
rec.action_cancel_manufacturing_order() |
|||
else: |
|||
raise UserError(_( |
|||
"You cannot cancel an order that is not in Done state!")) |
|||
|
|||
def _create_move_from_existing_move(self, move, factor, location_id, |
|||
location_dest_id): |
|||
"""Create a stock move while creating a manufacturing order""" |
|||
return self.env['stock.move'].create({ |
|||
'name': move.name, |
|||
'date': move.create_date, |
|||
'product_id': move.product_id.id, |
|||
'product_uom_qty': move.product_uom_qty * factor, |
|||
'product_uom': move.product_uom.id, |
|||
'procure_method': 'make_to_stock', |
|||
'location_dest_id': location_dest_id.id, |
|||
'location_id': location_id.id, |
|||
'warehouse_id': location_dest_id.warehouse_id.id, |
|||
'company_id': move.company_id.id, |
|||
}) |
|||
|
|||
def action_cancel_manufacturing_order(self): |
|||
"""To cancel manufacturing order while clicking the button cancel """ |
|||
consume_moves = self.env['stock.move'] |
|||
produce_moves = self.env['stock.move'] |
|||
factor = self.product_qty / self.product_uom_id._compute_quantity( |
|||
self.product_qty, self.product_uom_id) |
|||
finished_moves = self.move_finished_ids.filtered(lambda l: l.state == 'done') |
|||
raw_moves = self.move_raw_ids.filtered(lambda l: l.state == 'done') |
|||
for finished_move in finished_moves: |
|||
consume_moves += self._create_move_from_existing_move(finished_move, factor, finished_move.location_dest_id, |
|||
finished_move.location_id) |
|||
for raw_move in raw_moves: |
|||
produce_moves += self._create_move_from_existing_move(raw_move, factor, raw_move.location_dest_id, |
|||
self.location_dest_id) |
|||
if consume_moves: |
|||
consume_moves._action_confirm() |
|||
if produce_moves: |
|||
produce_moves._action_confirm() |
|||
finished_moves = consume_moves.filtered(lambda m: m.product_id == self.product_id) |
|||
consume_moves -= finished_moves |
|||
for finished_move in finished_moves: |
|||
if finished_move.has_tracking != 'none': |
|||
self.env['stock.move.line'].create({ |
|||
'move_id': finished_move.id, |
|||
'quantity': finished_move.product_uom_qty, |
|||
'product_id': finished_move.product_id.id, |
|||
'product_uom_id': finished_move.product_uom.id, |
|||
'location_id': finished_move.location_id.id, |
|||
'location_dest_id': finished_move.location_dest_id.id, |
|||
}) |
|||
else: |
|||
finished_move.quantity = finished_move.product_uom_qty |
|||
qty_already_used = defaultdict(float) |
|||
for move in produce_moves | consume_moves: |
|||
if move.has_tracking != 'none': |
|||
original_move = move in produce_moves and self.move_raw_ids or self.move_finished_ids |
|||
moves_lines = original_move.filtered(lambda m: m.product_id == move.product_id).mapped('move_line_ids') |
|||
for move_line in moves_lines: |
|||
taken_quantity = min(move.product_uom_qty,move_line.quantity - qty_already_used[move_line]) |
|||
if taken_quantity: |
|||
self.env['stock.move.line'].create({ |
|||
'move_id': move.id, |
|||
'lot_id': move_line.lot_id.id, |
|||
'quantity': taken_quantity, |
|||
'product_id': move.product_id.id, |
|||
'product_uom_id': move_line.product_uom_id.id, |
|||
'location_id': move.location_id.id, |
|||
'location_dest_id': move.location_dest_id.id, |
|||
}) |
|||
move.product_uom_qty -= taken_quantity |
|||
qty_already_used[move_line] += taken_quantity |
|||
else: |
|||
move.quantity = float_round( |
|||
move.product_uom_qty, |
|||
precision_rounding=move.product_uom.rounding) |
|||
stock_quant = self.env['stock.quant'].search([ |
|||
('product_id', '=', move.product_id.id), |
|||
('location_id', 'in', [self.location_src_id.id]) |
|||
]) |
|||
for quant in stock_quant: |
|||
quant.sudo().write({'quantity': quant.quantity + move.product_qty}) |
|||
|
|||
for line in finished_moves: |
|||
stock_quant = self.env['stock.quant'].search([ |
|||
('product_id', '=', line.product_id.id), |
|||
('location_id', 'in', [self.location_dest_id.id]) |
|||
]) |
|||
for quant in stock_quant: |
|||
quant.sudo().write({'quantity': quant.quantity - line.product_qty}) |
|||
finished_moves.write({'state': 'done'}) |
|||
consume_moves.write({'state': 'done'}) |
|||
produce_moves.write({'state': 'done'}) |
|||
produced_move_line_ids = produce_moves.mapped('move_line_ids').filtered(lambda ml: ml.quantity > 0) |
|||
consume_moves.mapped('move_line_ids').write({'produce_line_ids': [(6, 0, produced_move_line_ids.ids)]}) |
|||
raw_moves.sudo().write({'state': 'cancel'}) |
|||
raw_moves.mapped('move_line_ids').sudo().write({'state': 'cancel'}) |
|||
if self.sudo().mapped('workorder_ids'): |
|||
self.sudo().mapped('workorder_ids').write({'state': 'cancel'}) |
|||
self.write({'state': 'cancel'}) |
|||
@ -0,0 +1,8 @@ |
|||
<?xml version="1.0" encoding="utf-8" ?> |
|||
<odoo> |
|||
<!-- Group for cancel the manufacturing order--> |
|||
<record id="cancel_mrp_order_group_cancel_manufacturing_order" |
|||
model="res.groups"> |
|||
<field name="name">Cancel Manufacturing Orders</field> |
|||
</record> |
|||
</odoo> |
|||
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 628 KiB |
|
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: 330 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: 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 |
|
After Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 146 KiB |
|
After Width: | Height: | Size: 123 KiB |
|
After Width: | Height: | Size: 125 KiB |
|
After Width: | Height: | Size: 135 KiB |
|
After Width: | Height: | Size: 140 KiB |
|
After Width: | Height: | Size: 117 KiB |
|
After Width: | Height: | Size: 117 KiB |
|
After Width: | Height: | Size: 140 KiB |
|
After Width: | Height: | Size: 142 KiB |
|
After Width: | Height: | Size: 118 KiB |
|
After Width: | Height: | Size: 128 KiB |
|
After Width: | Height: | Size: 370 KiB |
|
After Width: | Height: | Size: 141 KiB |
|
After Width: | Height: | Size: 106 KiB |
|
After Width: | Height: | Size: 194 KiB |
|
After Width: | Height: | Size: 157 KiB |
|
After Width: | Height: | Size: 159 KiB |
|
After Width: | Height: | Size: 131 KiB |
|
After Width: | Height: | Size: 130 KiB |