summaryrefslogtreecommitdiff
path: root/addons/mrp/wizard/mrp_production_backorder.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/mrp/wizard/mrp_production_backorder.py
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/mrp/wizard/mrp_production_backorder.py')
-rw-r--r--addons/mrp/wizard/mrp_production_backorder.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/addons/mrp/wizard/mrp_production_backorder.py b/addons/mrp/wizard/mrp_production_backorder.py
new file mode 100644
index 00000000..681b3fff
--- /dev/null
+++ b/addons/mrp/wizard/mrp_production_backorder.py
@@ -0,0 +1,38 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import api, fields, models
+
+
+class MrpProductionBackorderLine(models.TransientModel):
+ _name = 'mrp.production.backorder.line'
+ _description = "Backorder Confirmation Line"
+
+ mrp_production_backorder_id = fields.Many2one('mrp.production.backorder', 'MO Backorder', required=True, ondelete="cascade")
+ mrp_production_id = fields.Many2one('mrp.production', 'Manufacturing Order', required=True, ondelete="cascade", readonly=True)
+ to_backorder = fields.Boolean('To Backorder')
+
+
+class MrpProductionBackorder(models.TransientModel):
+ _name = 'mrp.production.backorder'
+ _description = "Wizard to mark as done or create back order"
+
+ mrp_production_ids = fields.Many2many('mrp.production')
+
+ mrp_production_backorder_line_ids = fields.One2many(
+ 'mrp.production.backorder.line',
+ 'mrp_production_backorder_id',
+ string="Backorder Confirmation Lines")
+ show_backorder_lines = fields.Boolean("Show backorder lines", compute="_compute_show_backorder_lines")
+
+ @api.depends('mrp_production_backorder_line_ids')
+ def _compute_show_backorder_lines(self):
+ for wizard in self:
+ wizard.show_backorder_lines = len(wizard.mrp_production_backorder_line_ids) > 1
+
+ def action_close_mo(self):
+ return self.mrp_production_ids.with_context(skip_backorder=True).button_mark_done()
+
+ def action_backorder(self):
+ mo_ids_to_backorder = self.mrp_production_backorder_line_ids.filtered(lambda l: l.to_backorder).mrp_production_id.ids
+ return self.mrp_production_ids.with_context(skip_backorder=True, mo_ids_to_backorder=mo_ids_to_backorder).button_mark_done()