Skip to content

Instantly share code, notes, and snippets.

@tejastank
Last active December 7, 2025 22:29
Show Gist options
  • Select an option

  • Save tejastank/3eecb59c8ff04b85829bd8d4b14b5b26 to your computer and use it in GitHub Desktop.

Select an option

Save tejastank/3eecb59c8ff04b85829bd8d4b14b5b26 to your computer and use it in GitHub Desktop.
[email protected] , Fix ODOO License 15,16,17,18,19, due to ODOO support failed temporary quick fix ,
# -*- coding: utf-8 -*-
# [email protected]
# ODOO Enterprise Edition
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import datetime
import logging
import requests
import werkzeug.urls
from ast import literal_eval
from odoo import api, release, SUPERUSER_ID
from odoo.exceptions import UserError
from odoo.models import AbstractModel
from odoo.tools.translate import _
from odoo.tools import config, misc, ustr
_logger = logging.getLogger(__name__)
class PublisherWarrantyContract(AbstractModel):
_name = "publisher_warranty.contract"
_description = 'Publisher Warranty Contract'
@api.model
def _get_message(self):
Users = self.env['res.users']
IrParamSudo = self.env['ir.config_parameter'].sudo()
dbuuid = IrParamSudo.get_param('database.uuid')
db_create_date = IrParamSudo.get_param('database.create_date')
limit_date = datetime.datetime.now()
limit_date = limit_date - datetime.timedelta(15)
limit_date_str = limit_date.strftime(misc.DEFAULT_SERVER_DATETIME_FORMAT)
nbr_users = Users.search_count([('active', '=', True)])
nbr_active_users = Users.search_count([("login_date", ">=", limit_date_str), ('active', '=', True)])
nbr_share_users = 0
nbr_active_share_users = 0
if "share" in Users._fields:
nbr_share_users = Users.search_count([("share", "=", True), ('active', '=', True)])
nbr_active_share_users = Users.search_count([("share", "=", True), ("login_date", ">=", limit_date_str), ('active', '=', True)])
user = self.env.user
domain = [('application', '=', True), ('state', 'in', ['installed', 'to upgrade', 'to remove'])]
apps = self.env['ir.module.module'].sudo().search_read(domain, ['name'])
enterprise_code = IrParamSudo.get_param('database.enterprise_code')
web_base_url = IrParamSudo.get_param('web.base.url')
msg = {
"dbuuid": dbuuid,
"nbr_users": nbr_users,
"nbr_active_users": nbr_active_users,
"nbr_share_users": nbr_share_users,
"nbr_active_share_users": nbr_active_share_users,
"dbname": self._cr.dbname,
"db_create_date": db_create_date,
"version": release.version,
"language": user.lang,
"web_base_url": web_base_url,
"apps": [app['name'] for app in apps],
"enterprise_code": enterprise_code,
}
if user.partner_id.company_id:
company_id = user.partner_id.company_id
msg.update(company_id.read(["name", "email", "phone"])[0])
return msg
@api.model
def _get_sys_logs(self):
"""
Utility method to send a publisher warranty get logs messages.
"""
msg = self._get_message()
arguments = {'arg0': ustr(msg), "action": "update"}
#url = config.get("publisher_warranty_url")
#r = requests.post(url, data=arguments, timeout=30)
#r.raise_for_status()
return literal_eval('')
def update_notification(self, cron_mode=True):
# """
# Send a message to Odoo's publisher warranty server to check the
# validity of the contracts, get notifications, etc...
# @param cron_mode: If true, catch all exceptions (appropriate for usage in a cron).
# @type cron_mode: boolean
# """
# try:
# try:
# result = self._get_sys_logs()
# except Exception:
# if cron_mode: # we don't want to see any stack trace in cron
# return False
# _logger.debug("Exception while sending a get logs messages", exc_info=1)
# raise UserError(_("Error during communication with the publisher warranty server."))
# # old behavior based on res.log; now on mail.message, that is not necessarily installed
# user = self.env['res.users'].sudo().browse(SUPERUSER_ID)
# poster = self.sudo().env.ref('mail.channel_all_employees')
# for message in result["messages"]:
# try:
# poster.message_post(body=message, subtype_xmlid='mail.mt_comment', partner_ids=[user.partner_id.id])
# except Exception:
# pass
# if result.get('enterprise_info'):
# # Update expiration date
# set_param = self.env['ir.config_parameter'].sudo().set_param
## set_param('database.expiration_date', result['enterprise_info'].get('expiration_date'))
## set_param('database.expiration_reason', result['enterprise_info'].get('expiration_reason', 'trial'))
## set_param('database.enterprise_code', result['enterprise_info'].get('enterprise_code'))
## set_param('database.already_linked_subscription_url', result['enterprise_info'].get('database_already_linked_subscription_url'))
## set_param('database.already_linked_email', result['enterprise_info'].get('database_already_linked_email'))
## set_param('database.already_linked_send_mail_url', result['enterprise_info'].get('database_already_linked_send_mail_url'))
# except Exception:
# if cron_mode:
# return False # we don't want to see any stack trace in cron
# else:
# raise
return True
@spocasangre
Copy link

Hi, in case there is no record 'database.enterprise_code' in the table 'ir.config_parameter' what should i do? and in order to execute this code i would have to create a module and uncomment the code from line 76 to 79 and comment line 80? Also uncomment from line 87 to 120 and comment line 121?

@tejastank
Copy link
Author

/etc/hosts

edit
127.0.0.1 odoo.com
127.0.0.1 ipa.odoo.com
127.0.0.1 *.odoo.com

in case you wated to bypass communication with odoo

@spocasangre code is king.

@anhvutuan
Copy link

I'm a newbie. please, can you help me how to run this? @tejastank @spocasangre

@BohdanK-W32
Copy link

BohdanK-W32 commented Nov 19, 2024

Hi there, what about odoo 18?

I'm having errors with this one

File "/opt/odoo/odoo.enterprise.license.py", line 21, in <module>
    class PublisherWarrantyContract(AbstractModel):
  File "/opt/odoo/odoo/models.py", line 241, in __new__
    assert module.startswith('odoo.addons.'), \
AssertionError: Invalid import of __main__.PublisherWarrantyContract, it should start with 'odoo.addons'.

@stefano055415
Copy link

Hi @tejastank
with version 17.0-20240522 I have the same error

File "/opt/odoo/odoo.enterprise.license.py", line 21, in
class PublisherWarrantyContract(AbstractModel):
File "/opt/odoo/odoo/models.py", line 241, in new
assert module.startswith('odoo.addons.'),
AssertionError: Invalid import of main.PublisherWarrantyContract, it should start with 'odoo.addons'.

@Seedgta1
Copy link

For 18?

@tejastank
Copy link
Author

Remove PublisherWarrantyContract related all code or comment all of them or make their return what you expected to.

@moshin34
Copy link

@tejastank will this work to use 18 enterprise edition, in a testing environment?

@dtmcollado
Copy link

Hello, sorry for my bad English. Where can I download the modules unofficially "enterprise version". thank you so much

@samehfradees
Copy link

sorry for dispute you, can you please add steps to understand how to use it

@tqqkhang2006
Copy link

How do I use this file odoo.enterprise.license.issue.py ? I'm using Odoo version 18.

@samehfradees
Copy link

samehfradees commented Jun 10, 2025 via email

@tqqkhang2006
Copy link

@tejastank
How do I use this odoo.enterprise.license.issue.py file? I am using Odoo version 18. Please guide me step by step on how to use your odoo.enterprise.license.issue.py file.

@tejastank
Copy link
Author

me: [email protected], Sorry I am tidy busy with routines.

Yes 18 version as well can be manage.

@jandreesen84-collab
Copy link

@tqqkhang2006 if you have enterprise code i can help you

@vitragmehta
Copy link

@tqqkhang2006 if you have enterprise code i can help you

Hello, i have the code and will be happy to understand how to use this code; can you help?

@tdcomcl
Copy link

tdcomcl commented Sep 26, 2025

Hello, I'm using all of you in odoo 19 ee and apparently everything is super good!!
Captura de pantalla 2025-09-25 a la(s) 21 53 26

@tdcomcl
Copy link

tdcomcl commented Sep 26, 2025

excellent job to the developer!

@vitragmehta
Copy link

@tqqkhang2006 if you have enterprise code i can help you

i have the code, can you help?

@tdcomcl
Copy link

tdcomcl commented Sep 26, 2025

I don't understand you well, do you want my help?

@vitragmehta
Copy link

vitragmehta commented Sep 30, 2025

I don't understand you well, do you want my help?

yes please, can you share some instructions on how to use this on odoo18 or odoo19

@vitragmehta
Copy link

is there a way to migrate the database without sending to odoo?

@tdcomcl
Copy link

tdcomcl commented Oct 6, 2025

is there a way to migrate the database without sending to odoo?

I don't understand you well, do you want my help?

yes please, can you share some instructions on how to use this on odoo18 or odoo19

It's all in the published code, by the owner of the repo

@Klimaflo-op
Copy link

hi, i am new to this, how do i run the code? i have trial enterprise ver 19 on windows machine

@sdedurana
Copy link

Hello, I'm using all of you in odoo 19 ee and apparently everything is super good!! Captura de pantalla 2025-09-25 a la(s) 21 53 26

hello! How do you run? i get same error:

File "/opt/odoo/odoo/odoo.enterprise.license.issue.py", line 23, in
class PublisherWarrantyContract(AbstractModel):
File "/opt/odoo/odoo/odoo/models.py", line 209, in new
assert module.startswith('odoo.addons.'),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Invalid import of main.PublisherWarrantyContract, it should start with 'odoo.addons'.

@MohandArezki
Copy link

hello, please how can i execut this script ?

@moises2k-lang
Copy link

hello, can anybody help me get the full code of odoo 19 enterprise? can anybody help?

@moises2k-lang
Copy link

Hello, I'm using all of you in odoo 19 ee and apparently everything is super good!! Captura de pantalla 2025-09-25 a la(s) 21 53 26

hello!! can you share download link of odoo 19 ee?

@sdedurana
Copy link

hi, i am new to this, how do i run the code? i have trial enterprise ver 19 on

how do you run this code?

@wshamasneh
Copy link

Hello, I'm using all of you in odoo 19 ee and apparently everything is super good!! Captura de pantalla 2025-09-25 a la(s) 21 53 26
Could you please share some instructions on how to run the provided code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment