from odoo import models, fields, api
import time,logging

class SOS_Service_Call_Log_Report(models.Model):
    _name = 'sos_service_call_log_report'
    _description = 'Service Call Log Report'
    _rec_name = 'ref_no'
    _order = 'id desc'

    ref_no=fields.Char(string="Reference No",readonly= True, required= True,default=lambda self: self._generate_id())
    customer_name   = fields.Many2one('sos_inventory_customers', string="Customer Name", required=True)
    contact_person = fields.Char(string="Contact Person")
    location       = fields.Char(string="Location")
    mobile_no      = fields.Char(string="Mobile Number")
    email          = fields.Char(string="Email")
    product_name   = fields.Char(string="Product Name")
    product_code   = fields.Char(string="Product Code")
    product_type   = fields.Char(string="Product Type")
    others         = fields.Char(string="Others")
    date           = fields.Datetime(string="Date")
    issue_details  = fields.Text(string="Issue details")
    person_assigned_for_issue = fields.Char(string="Person assigned for the issue")
    action_taken              = fields.Text(string="Action taken or required action to be taken")
    Date_of_action_Completed  = fields.Datetime(string="Date of action completed")
    status = fields.Selection([('open', 'Open'),('close', 'Closed')], default='open' , string="Status")

    def _generate_id(self):
        sequence_util = self.env['sos_common_scripts']
        return sequence_util.generate_sequence('sos_service_call_log_report','SCLR', 'ref_no')