Upload files to "/"
Deploy Odoo / deploy (push) Successful in 14s

This commit is contained in:
2026-08-13 11:32:25 +00:00
parent af37b6ced5
commit 17a3464fa2
5 changed files with 118 additions and 0 deletions
+6
View File
@@ -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
+26
View File
@@ -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,
}
+50
View File
@@ -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
+22
View File
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="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).
-->
<odoo>
<record id="ir_cron_module_disable_update_notification" model="ir.cron">
<field name="name">Publisher: disable Update Notification</field>
<field name="model_id" ref="model_publisher_warranty_contract"/>
<field name="state">code</field>
<field name="code">model.update_notification()</field>
<field name="user_id" ref="base.user_root" />
<field name="interval_number">1</field>
<field name="interval_type">weeks</field>
<field name="active" eval="True"/>
<field name="nextcall" eval="(DateTime.now() + timedelta(days=7)).strftime('%Y-%m-%d %H:%M:%S')" />
<field name="priority">1000</field>
</record>
</odoo>
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="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).
-->
<odoo>
<data noupdate="1">
<function
model="publisher_warranty.contract"
name="update_notification"
eval="['None']"/>
</data>
</odoo>