合并企业版代码(未测试,先提交到测试分支)

This commit is contained in:
qihao.gong@jikimo.com
2023-04-14 17:42:23 +08:00
parent 7a7b3d7126
commit d28525526a
1300 changed files with 513579 additions and 5426 deletions

View File

@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import ir_http
from . import ir_ui_menu
from . import res_partner

View File

@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import json
from odoo import models
from odoo.http import request
class Http(models.AbstractModel):
_inherit = 'ir.http'
def webclient_rendering_context(self):
""" Overrides community to prevent unnecessary load_menus request """
return {
'session_info': self.session_info(),
}
def session_info(self):
ICP = request.env['ir.config_parameter'].sudo()
User = request.env['res.users']
if User.has_group('base.group_system'):
warn_enterprise = 'admin'
elif User.has_group('base.group_user'):
warn_enterprise = 'user'
else:
warn_enterprise = False
result = super(Http, self).session_info()
result['support_url'] = "https://www.odoo.com/help"
if warn_enterprise:
result['warning'] = warn_enterprise
result['expiration_date'] = ICP.get_param('database.expiration_date')
result['expiration_reason'] = ICP.get_param('database.expiration_reason')
return result

View File

@@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import re
from odoo import models
class IrUiMenu(models.Model):
_inherit = "ir.ui.menu"
def load_web_menus(self, debug):
menus = super(IrUiMenu, self).load_web_menus(debug)
for menu in menus.values():
# web icons for app root menus
if menu['id'] == menu['appID']:
webIcon = menu.get('webIcon', '')
webIconlist = webIcon and webIcon.split(',')
iconClass = color = backgroundColor = None
if webIconlist:
if len(webIconlist) >= 2:
iconClass, color = webIconlist[:2]
if len(webIconlist) == 3:
backgroundColor = webIconlist[2]
if menu.get('webIconData'):
imgtype = menu['webIconData'][0] == 80 and 'svg+xml' or 'png'
menu['webIconData'] = re.sub(r'\s/g', "", ('data:image/%s;base64,%s' % (imgtype, menu['webIconData'].decode('utf-8'))))
elif backgroundColor is not None: # Could split in three parts?
menu['webIcon'] = ",".join([iconClass or "", color or "", backgroundColor])
else:
menu['webIconData'] = '/web_enterprise/static/img/default_icon_app.png'
return menus

View File

@@ -0,0 +1,79 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import logging
from base64 import b64decode
from odoo import models
_logger = logging.getLogger(__name__)
try:
import vobject
except ImportError:
_logger.warning("`vobject` Python module not found, vcard file generation disabled. Consider installing this module if you want to generate vcard files")
vobject = None
class ResPartner(models.Model):
_inherit = 'res.partner'
def _build_vcard(self):
""" Build the partner's vCard.
:returns a vobject.vCard object
"""
if not vobject:
return False
vcard = vobject.vCard()
# Name
n = vcard.add('n')
n.value = vobject.vcard.Name(family=self.name)
if self.title:
n.value.prefix = self.title.name
# Formatted Name
fn = vcard.add('fn')
fn.value = self.name
# Address
adr = vcard.add('adr')
adr.value = vobject.vcard.Address(street=self.street or '', city=self.city or '', code=self.zip or '')
if self.state_id:
adr.value.region = self.state_id.name
if self.country_id:
adr.value.country = self.country_id.name
# Email
if self.email:
email = vcard.add('email')
email.value = self.email
email.type_param = 'INTERNET'
# Telephone numbers
if self.phone:
tel = vcard.add('tel')
tel.type_param = 'work'
tel.value = self.phone
if self.mobile:
tel = vcard.add('tel')
tel.type_param = 'cell'
tel.value = self.mobile
# URL
if self.website:
url = vcard.add('url')
url.value = self.website
# Organisation
if self.commercial_company_name:
org = vcard.add('org')
org.value = [self.commercial_company_name]
if self.function:
function = vcard.add('title')
function.value = self.function
# Photo
photo = vcard.add('photo')
photo.value = b64decode(self.avatar_512)
photo.encoding_param = 'B'
photo.type_param = 'JPG'
return vcard
def _get_vcard_file(self):
vcard = self._build_vcard()
if vcard:
return vcard.serialize().encode('utf-8')
return False