# -*- coding: utf-8 -*-
# Disable all publisher warranty / subscription checks for local development

import logging
from odoo import api, models

_logger = logging.getLogger(__name__)


class PublisherWarrantyContractDisabled(models.AbstractModel):
    _inherit = "publisher_warranty.contract"

    @api.model
    def _get_sys_logs(self):
        """
        DISABLED: Do not contact Odoo servers.
        Returns fake successful response.
        """
        _logger.info("Publisher warranty check DISABLED - not contacting Odoo servers")
        return {
            "messages": [],
            "enterprise_info": {
                "expiration_date": "2099-12-31 23:59:59",
                "expiration_reason": "renewal",
                "enterprise_code": self.env['ir.config_parameter'].sudo().get_param('database.enterprise_code', ''),
            }
        }

    def update_notification(self, cron_mode=True):
        """
        DISABLED: Do not send any data to Odoo servers.
        Just update local parameters with permanent values.
        """
        _logger.info("Publisher warranty update_notification DISABLED - no server contact")
        
        # Set permanent valid subscription parameters
        set_param = self.env['ir.config_parameter'].sudo().set_param
        set_param('database.expiration_date', '2099-12-31 23:59:59')
        set_param('database.expiration_reason', 'renewal')
        
        # Clear any "already linked" parameters
        set_param('database.already_linked_subscription_url', False)
        set_param('database.already_linked_email', False)
        set_param('database.already_linked_send_mail_url', False)
        
        return True

