[MERGE] merge with latest stable
[odoo/odoo.git] / addons / web_livechat / publisher_warranty.py
old mode 100755 (executable)
new mode 100644 (file)
index b4825fe..ab83bc5
@@ -2,7 +2,7 @@
 ##############################################################################
 #
 #    OpenERP, Open Source Management Solution
-#    Copyright (C) 2010 OpenERP s.a. (<http://openerp.com>).
+#    Copyright (C) 2010-2011 OpenERP s.a. (<http://openerp.com>).
 #
 #    This program is free software: you can redistribute it and/or modify
 #    it under the terms of the GNU Affero General Public License as
 from osv import osv
 from tools import cache
 
+def _gen_cache_clear(method):
+    def func(self, cr, *args, **kwargs):
+        s = super(publisher_warranty_contract, self)
+        r = getattr(s, method)(cr, *args, **kwargs)
+        self.is_livechat_enable.clear_cache(cr.dbname)
+        return r
+    return func
+
 class publisher_warranty_contract(osv.osv):
     _inherit = 'publisher_warranty.contract'
 
+    create = _gen_cache_clear('create')
+    write = _gen_cache_clear('write')
+    unlink = _gen_cache_clear('unlink')
+
     @cache(skiparg=3, timeout=300)
     def is_livechat_enable(self, cr, uid):
-        domain = [('state', '=', 'valid'), ('kind', '=', 'support')]
+        domain = [('state', '=', 'valid'), ('check_support', '=', True)]
         return self.search_count(cr, uid, domain) != 0
 
     @cache(skiparg=3)
     def get_default_livechat_text(self, cr, uid):
-        return '<a href="http://www.openerp.com/services/subscribe-onsite" target="_blank"><img src="/web_livechat/static/images/busy.png"/>Online Support</a>'
+        return '<a href="http://www.openerp.com/support-or-publisher-warranty-contract" target="_blank"><img src="/web_livechat/static/images/busy.png"/>Support</a>'
 
 publisher_warranty_contract()