130 lines
4.7 KiB
Python
130 lines
4.7 KiB
Python
# -*- encoding: utf-8 -*-
|
|
##############################################################################
|
|
#
|
|
# OpenERP, Open Source Management Solution
|
|
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
|
# $Id$
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
##############################################################################
|
|
|
|
from openerp.osv import fields, osv
|
|
from openerp import api
|
|
from openerp.tools.translate import _
|
|
from openerp import SUPERUSER_ID
|
|
from openerp import tools
|
|
from lxml import etree
|
|
|
|
DISABLED_MENUS = [
|
|
]
|
|
|
|
class ir_ui_menu(osv.osv):
|
|
_inherit = 'ir.ui.menu'
|
|
|
|
@tools.ormcache(skiparg=2)
|
|
def get_disabled_menu_ids(self, cr, uid, context=None):
|
|
data_obj = self.pool.get('ir.model.data')
|
|
|
|
menu_ids = []
|
|
for menu in DISABLED_MENUS:
|
|
module,xml_id = menu.split('.')
|
|
menu = data_obj.get_object(cr, uid, module, xml_id)
|
|
if menu:
|
|
menu_ids.append(menu.id)
|
|
return menu_ids
|
|
|
|
def _filter_visible_menus(self, cr, uid, ids, context=None):
|
|
if uid != 1:
|
|
disabled_ids = self.get_disabled_menu_ids(cr, uid)
|
|
|
|
ids = [id for id in ids if id not in disabled_ids]
|
|
|
|
ids = super(ir_ui_menu, self)._filter_visible_menus(cr, uid, ids, context)
|
|
return ids
|
|
|
|
class res_partner(osv.osv):
|
|
_inherit = 'res.partner'
|
|
|
|
@api.model
|
|
def fields_view_get_address(self, arch):
|
|
""" verhindert das Überschreiben von address_format """
|
|
return arch
|
|
|
|
class product_product(osv.osv):
|
|
_inherit = 'product.product'
|
|
|
|
def name_get(self, cr, user, ids, context=None):
|
|
if context is None:
|
|
context = {}
|
|
c = context.copy()
|
|
c.update({'display_default_code': False})
|
|
return super(product_product, self).name_get(cr, user, ids, context=c)
|
|
|
|
class mail_notification(osv.Model):
|
|
_inherit = 'mail.notification'
|
|
|
|
# override original function
|
|
def get_signature_footer(self, cr, uid, user_id, res_model=None, res_id=None, context=None, user_signature=True):
|
|
""" Format a standard footer for notification emails (such as pushed messages
|
|
notification or invite emails).
|
|
Format:
|
|
<p>--<br />
|
|
Administrator
|
|
</p>
|
|
<div>
|
|
<small>Sent from <a ...>Your Company</a> using <a ...>OpenERP</a>.</small>
|
|
</div>
|
|
"""
|
|
footer = ""
|
|
if not user_id:
|
|
return footer
|
|
|
|
# add user signature
|
|
user = self.pool.get("res.users").browse(cr, SUPERUSER_ID, [user_id], context=context)[0]
|
|
if user_signature:
|
|
if user.signature:
|
|
signature = user.signature
|
|
else:
|
|
signature = "--<br />%s" % user.name
|
|
footer = tools.append_content_to_html(footer, signature, plaintext=False)
|
|
|
|
# add company signature
|
|
# if user.company_id.website:
|
|
# website_url = ('http://%s' % user.company_id.website) if not user.company_id.website.lower().startswith(('http:', 'https:')) \
|
|
# else user.company_id.website
|
|
# company = "<a style='color:inherit' href='%s'>%s</a>" % (website_url, user.company_id.name)
|
|
# else:
|
|
# company = user.company_id.name
|
|
# sent_by = _('Sent by %(company)s using %(odoo)s')
|
|
#
|
|
# signature_company = '<br /><small>%s</small>' % (sent_by % {
|
|
# 'company': company,
|
|
# 'odoo': "<a style='color:inherit' href='https://www.odoo.com/'>Odoo</a>"
|
|
# })
|
|
# footer = tools.append_content_to_html(footer, signature_company, plaintext=False, container_tag='div')
|
|
|
|
return footer
|
|
|
|
# class product_product(osv.osv):
|
|
# _inherit = 'product.product'
|
|
#
|
|
# def name_get(self, cr, user, ids, context=None):
|
|
# if context is None:
|
|
# context = {}
|
|
# c = context.copy()
|
|
# c.update({'display_default_code': False})
|
|
# return super(product_product, self).name_get(cr, user, ids, context=c)
|
|
|