[NOOP] remove trailing space of bin/addons/base/publisher_warranty/publisher_warranty.py
bzr revid: chs@openerp.com-20101214101747-dx9ntnr9op37on1y
This commit is contained in:
parent
6ac4e8a908
commit
b38e97ee4b
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 OpenERP S.A. (<http://www.openerp.com>).
|
||||
#
|
||||
|
@ -15,7 +15,7 @@
|
|||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
"""
|
||||
|
@ -55,31 +55,31 @@ class publisher_warranty_contract(osv.osv):
|
|||
def _get_valid_contracts(self, cr, uid):
|
||||
"""
|
||||
Return the list of the valid contracts encoded in the system.
|
||||
|
||||
|
||||
@return: A list of contracts
|
||||
@rtype: list of publisher_warranty.contract browse records
|
||||
"""
|
||||
return [contract for contract in self.browse(cr, uid, self.search(cr, uid, []))
|
||||
if contract.state == 'valid']
|
||||
|
||||
|
||||
def status(self, cr, uid):
|
||||
""" Method called by the client to check availability of publisher warranty contract. """
|
||||
|
||||
|
||||
contracts = self._get_valid_contracts(cr, uid)
|
||||
return {
|
||||
'status': "full" if contracts else "none" ,
|
||||
'uncovered_modules': list(),
|
||||
}
|
||||
|
||||
|
||||
def send(self, cr, uid, tb, explanations, remarks=None, issue_name=None):
|
||||
""" Method called by the client to send a problem to the publisher warranty server. """
|
||||
|
||||
|
||||
if not remarks:
|
||||
remarks = ""
|
||||
|
||||
valid_contracts = self._get_valid_contracts(cr, uid)
|
||||
valid_contract = valid_contracts[0]
|
||||
|
||||
|
||||
try:
|
||||
origin = 'client'
|
||||
dbuuid = self.pool.get('ir.config_parameter').get_param(cr, uid, 'database.uuid')
|
||||
|
@ -87,7 +87,7 @@ class publisher_warranty_contract(osv.osv):
|
|||
user = self.pool.get("res.users").browse(cr, uid, uid)
|
||||
user_name = user.name
|
||||
email = user.email
|
||||
|
||||
|
||||
msg = {'contract_name': valid_contract.name,
|
||||
'tb': tb,
|
||||
'explanations': explanations,
|
||||
|
@ -100,8 +100,8 @@ class publisher_warranty_contract(osv.osv):
|
|||
'email': email,
|
||||
'user_name': user_name,
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
add_arg = {"timeout":30} if sys.version_info >= (2,6) else {}
|
||||
uo = urllib2.urlopen(config.get("publisher_warranty_url"),
|
||||
urllib.urlencode({'arg0': msg, "action": "send",}),**add_arg)
|
||||
|
@ -109,23 +109,23 @@ class publisher_warranty_contract(osv.osv):
|
|||
submit_result = uo.read()
|
||||
finally:
|
||||
uo.close()
|
||||
|
||||
|
||||
result = safe_eval(submit_result)
|
||||
|
||||
|
||||
crm_case_id = result
|
||||
|
||||
|
||||
if not crm_case_id:
|
||||
return False
|
||||
|
||||
|
||||
except osv.except_osv:
|
||||
raise
|
||||
except Exception:
|
||||
_logger.warning("Error sending problem report", exc_info=1)
|
||||
raise osv.except_osv("Connection error", "An error occured during the connection " +
|
||||
"with the publisher warranty server.")
|
||||
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def check_validity(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
Check the validity of a publisher warranty contract. This method just call get_logs() but checks
|
||||
|
@ -135,21 +135,21 @@ class publisher_warranty_contract(osv.osv):
|
|||
contract = self.browse(cr, uid, contract_id)
|
||||
state = contract.state
|
||||
validated = state != "unvalidated"
|
||||
|
||||
|
||||
self.get_logs(cr, uid, ids, cron_mode=False, context=context)
|
||||
|
||||
|
||||
contract = self.browse(cr, uid, contract_id)
|
||||
validated2 = contract.state != "unvalidated"
|
||||
if not validated and not validated2:
|
||||
raise osv.except_osv(_("Contract validation error"),
|
||||
_("Please check your publisher warranty contract name and validity."))
|
||||
return True
|
||||
|
||||
|
||||
def get_logs(self, cr, uid, ids, cron_mode=True, context=None):
|
||||
"""
|
||||
Send a message to OpenERP'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
|
||||
"""
|
||||
|
@ -158,7 +158,7 @@ class publisher_warranty_contract(osv.osv):
|
|||
result = get_sys_logs(cr, uid)
|
||||
except Exception:
|
||||
if cron_mode: # we don't want to see any stack trace in cron
|
||||
return False
|
||||
return False
|
||||
_logger.debug("Exception while sending a get logs messages", exc_info=1)
|
||||
raise osv.except_osv(_("Error"), _("Error during communication with the publisher warranty server."))
|
||||
|
||||
|
@ -173,7 +173,7 @@ class publisher_warranty_contract(osv.osv):
|
|||
"date_stop": date_to,
|
||||
"state": state,
|
||||
})
|
||||
|
||||
|
||||
limit_date = (datetime.datetime.now() - _PREVIOUS_LOG_CHECK).strftime(misc.DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
for message in result["messages"]:
|
||||
ids = self.pool.get("res.log").search(cr, uid, [("res_model", "=", "publisher_warranty.contract"),
|
||||
|
@ -196,7 +196,7 @@ class publisher_warranty_contract(osv.osv):
|
|||
else:
|
||||
raise
|
||||
return True
|
||||
|
||||
|
||||
def get_last_user_messages(self, cr, uid, limit, context=None):
|
||||
"""
|
||||
Get the messages to be written in the web client.
|
||||
|
@ -208,15 +208,15 @@ class publisher_warranty_contract(osv.osv):
|
|||
if not ids:
|
||||
return []
|
||||
messages = [(x.id, x.name) for x in self.pool.get('res.log').browse(cr, uid, ids)]
|
||||
|
||||
|
||||
return messages
|
||||
|
||||
|
||||
def del_user_message(self, cr, uid, id, context=None):
|
||||
"""
|
||||
Delete a message.
|
||||
"""
|
||||
self.pool.get('res.log').unlink(cr, uid, [id])
|
||||
|
||||
|
||||
return True
|
||||
|
||||
_columns = {
|
||||
|
@ -227,11 +227,11 @@ class publisher_warranty_contract(osv.osv):
|
|||
, ('terminated', 'Terminated'), ('canceled', 'Canceled')], string="State", readonly=True),
|
||||
'kind' : fields.char('Kind', size=64, readonly=True),
|
||||
}
|
||||
|
||||
|
||||
_defaults = {
|
||||
'state': 'unvalidated',
|
||||
}
|
||||
|
||||
|
||||
_sql_constraints = [
|
||||
('uniq_name', 'unique(name)', "Your publisher warranty contract is already subscribed in the system !")
|
||||
]
|
||||
|
@ -240,16 +240,16 @@ publisher_warranty_contract()
|
|||
|
||||
class maintenance_contract(osv.osv_memory):
|
||||
""" Old osv we only keep for compatibility with the clients. """
|
||||
|
||||
|
||||
_name = "maintenance.contract"
|
||||
|
||||
|
||||
def status(self, cr, uid):
|
||||
return self.pool.get("publisher_warranty.contract").status(cr, uid)
|
||||
|
||||
|
||||
def send(self, cr, uid, tb, explanations, remarks=None, issue_name=None):
|
||||
return self.pool.get("publisher_warranty.contract").send(cr, uid, tb,
|
||||
explanations, remarks, issue_name)
|
||||
|
||||
|
||||
maintenance_contract()
|
||||
|
||||
class publisher_warranty_contract_wizard(osv.osv_memory):
|
||||
|
@ -263,7 +263,7 @@ class publisher_warranty_contract_wizard(osv.osv_memory):
|
|||
'name' : fields.char('Serial Key', size=256, required=True ),
|
||||
'state' : fields.selection([("draft", "Draft"), ("finished", "Finished")])
|
||||
}
|
||||
|
||||
|
||||
_defaults = {
|
||||
"state": "draft",
|
||||
}
|
||||
|
@ -274,21 +274,21 @@ class publisher_warranty_contract_wizard(osv.osv_memory):
|
|||
|
||||
wiz = self.browse(cr, uid, ids[0])
|
||||
c_name = wiz.name
|
||||
|
||||
|
||||
contract_osv = self.pool.get("publisher_warranty.contract")
|
||||
contracts = contract_osv.search(cr, uid, [("name","=",c_name)])
|
||||
if contracts:
|
||||
raise osv.except_osv(_("Error"), _("That contract is already registered in the system."))
|
||||
|
||||
|
||||
contract_id = contract_osv.create(cr, uid, {
|
||||
"name": c_name,
|
||||
"state": "unvalidated",
|
||||
})
|
||||
|
||||
|
||||
contract_osv.check_validity(cr, uid, [contract_id])
|
||||
|
||||
|
||||
self.write(cr, uid, ids, {"state": "finished"})
|
||||
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
@ -299,7 +299,7 @@ def get_sys_logs(cr, uid):
|
|||
Utility method to send a publisher warranty get logs messages.
|
||||
"""
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
|
||||
|
||||
dbuuid = pool.get('ir.config_parameter').get_param(cr, uid, 'database.uuid')
|
||||
db_create_date = pool.get('ir.config_parameter').get_param(cr, uid, 'database.create_date')
|
||||
nbr_users = pool.get("res.users").search(cr, uid, [], count=True)
|
||||
|
@ -315,7 +315,7 @@ def get_sys_logs(cr, uid):
|
|||
"contracts": [c.name for c in contracts],
|
||||
"language": user.context_lang,
|
||||
}
|
||||
|
||||
|
||||
add_arg = {"timeout":30} if sys.version_info >= (2,6) else {}
|
||||
uo = urllib2.urlopen(config.get("publisher_warranty_url"),
|
||||
urllib.urlencode({'arg0': msg, "action": "update",}), **add_arg)
|
||||
|
@ -323,9 +323,9 @@ def get_sys_logs(cr, uid):
|
|||
submit_result = uo.read()
|
||||
finally:
|
||||
uo.close()
|
||||
|
||||
|
||||
result = safe_eval(submit_result)
|
||||
|
||||
|
||||
return result
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
Loading…
Reference in New Issue