from odoo import api, fields, models, _
import logging
_logger = logging.getLogger(__name__)



class SOS_Indent_Production_Plan(models.Model):
    _name = 'sos_indent_production_plan'
    _description = 'FG Production Plan'
    _rec_name = 'plan_ref_no'
    

    plan_ref_no = fields.Char(
         required=True, string='Plan ID'
    )
    line_ids = fields.One2many('sos_indent_production_plan_line', 'plan_id', string='Lines', ondelete='cascade')
    



class SOS_Indent_Production_Plan_Line(models.Model):
    _name = 'sos_indent_production_plan_line'
    _description = 'FG Production Plan line items'

    fg_name = fields.Many2one('sos_fg',string="FG Name")
    qp_no = fields.Integer(string="QP No")
    plan_id = fields.Many2one('sos_fg_plan', string='FG Plan', ondelete='cascade')
    required_qty = fields.Integer(string='Required Qty')
    target_date = fields.Date(string='Target Date')

    planned_week_1 = fields.Integer(string='Planned')
    actual_week_1 = fields.Integer(string='Actual')
    qc_week_1 = fields.Integer(string='QC Tested')

    planned_week_2 = fields.Integer(string='Planned')
    actual_week_2 = fields.Integer(string='Actual')
    qc_week_2 = fields.Integer(string='QC Tested')

    planned_week_3 = fields.Integer(string='Planned')
    actual_week_3 = fields.Integer(string='Actual')
    qc_week_3 = fields.Integer(string='QC Tested')

    planned_week_4 = fields.Integer(string='Planned')
    actual_week_4 = fields.Integer(string='Actual')
    qc_week_4 = fields.Integer(string='QC Tested')

    planned_week_5 = fields.Integer(string='Planned')
    actual_week_5 = fields.Integer(string='Actual')
    qc_week_5 = fields.Integer(string='QC Tested')

    status = fields.Selection([
        ('in_progress', 'In Progress'),
        ('completed', 'Completed'),
        ('held', 'Held'),
        ('cancelled', 'Cancelled')
    ], string='Status')
