Slink/sos_inventory/wizard/missing_component_wizard.py

28 lines
1.2 KiB
Python
Executable File

from odoo import models, fields, api
class MissingComponentWizard(models.TransientModel):
_name = 'missing_component_wizard'
_description = 'Wizard for Handling Missing Components'
missing_component_line_ids = fields.One2many(
'missing_component_line', 'wizard_id', string="Missing Components"
)
sos_sfg_id = fields.Many2one('sos_sfg_bom', string="Related SFG Record")
def confirm_selections(self):
sfg_record = self.sos_sfg_id.id
sfg_bom_line_model = self.env['sos_sfg_bom_line']
for line in self.missing_component_line_ids:
sfg_bom_line_model.create({'bom_id': sfg_record,
'primary_component_id':line.alternative_component_id.id,
'quantity':line.missing_component_quantity
})
class MissingComponentLine(models.TransientModel):
_name = 'missing_component_line'
_description = 'Line for each missing component'
wizard_id = fields.Many2one('missing_component_wizard', string="Wizard")
missing_component_name = fields.Char("Missing Component", readonly=True)
missing_component_quantity=fields.Float(string="Qty", default=1)
alternative_component_id = fields.Many2one('sos_material', string="Select Alternative")