diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..1df9925 --- /dev/null +++ b/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2024-Today: Odoo Community Iran +# @author: Odoo Community Iran (https://odoo-community.ir/ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models \ No newline at end of file diff --git a/__manifest__.py b/__manifest__.py new file mode 100644 index 0000000..e9488fd --- /dev/null +++ b/__manifest__.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2024-Today: Odoo Community Iran +# @author: Odoo Community Iran (https://odoo-community.ir/ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + 'name': "Disable Enterprise", + 'summary': """Disable Enterprise Code""", + 'description': """Disable Enterprise Code""", + 'author': "Odoo Community Iran", + 'website': "https://odoo-community.ir/", + 'category': 'Technical', + 'version': '1.0', + "license": "AGPL-3", + 'depends': ['base', 'mail', 'web_enterprise'], + 'data': [ + 'data/update_notification.xml', + 'data/service_cron.xml', + + ], + 'assets': { + 'web.assets_backend': [ + 'disable_enterprise/static/src/webclient/**/*.xml', + ], + }, + "installable": True, +} diff --git a/publisher_warranty.py b/publisher_warranty.py new file mode 100644 index 0000000..7ae1950 --- /dev/null +++ b/publisher_warranty.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2024-Today: Odoo Community Iran +# @author: Odoo Community Iran (https://odoo-community.ir/ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from datetime import datetime +import logging + +from odoo.models import AbstractModel +from odoo.tools.translate import _ + +_logger = logging.getLogger(__name__) + +def add_years(today, years): + """Return a date that's `years` years after the date (or datetime) + object `today`. Return the same calendar date (month and day) in the + destination year, if it exists, otherwise use the following day + (thus changing February 29 to March 1). + + """ + try: + return today.replace(year = today.year + years) + except ValueError: + return today + (datetime.date(today.year + years, 1, 1) - datetime.date(today.year, 1, 1)) + +class PublisherWarrantyContract(AbstractModel): + _inherit = "publisher_warranty.contract" + + + def _get_message(self): + res = super(PublisherWarrantyContract, self)._get_message() + return {} + + def update_notification(self, cron_mode=True): + """ + This func was running from expiration_panel.js and change expiration_date & expiration_reason + Now override : expiration_date += 1 & expiration_reason=fawan + """ + res = super(PublisherWarrantyContract, self).update_notification(cron_mode) + expiration_date = add_years(datetime.now(),1) + expiration_reason = 'nothing' + try: + set_param = self.env['ir.config_parameter'].sudo().set_param + set_param('database.expiration_date', expiration_date) + set_param('database.expiration_reason', expiration_reason) + set_param('database.enterprise_code', "ABC") + _logger.info('Disable Enterprise by Date: %s, reason: %s', expiration_date, expiration_reason) + except Exception: + _logger.debug("Exception while change expiration_date", exc_info=1) + + return res \ No newline at end of file diff --git a/service_cron.xml b/service_cron.xml new file mode 100644 index 0000000..c01f70e --- /dev/null +++ b/service_cron.xml @@ -0,0 +1,22 @@ + + + + + Publisher: disable Update Notification + + code + model.update_notification() + + 1 + weeks + + + 1000 + + + + diff --git a/update_notification.xml b/update_notification.xml new file mode 100644 index 0000000..1249043 --- /dev/null +++ b/update_notification.xml @@ -0,0 +1,14 @@ + + + + + + + \ No newline at end of file