Merge lp:~openerp-dev/openobject-server/niv-dev-server into lp:openobject-server

Proposed by Nicolas Vanhoren (OpenERP)
Status: Merged
Merged at revision: 3081
Proposed branch: lp:~openerp-dev/openobject-server/niv-dev-server
Merge into: lp:openobject-server
Diff against target: 1327 lines (+649/-457)
20 files modified
.bzrignore (+3/-0)
bin/addons/base/__init__.py (+1/-1)
bin/addons/base/__openerp__.py (+2/-1)
bin/addons/base/ir/__init__.py (+1/-0)
bin/addons/base/ir/ir_config_parameter.py (+101/-0)
bin/addons/base/ir/ir_cron.py (+2/-1)
bin/addons/base/maintenance/__init__.py (+0/-25)
bin/addons/base/maintenance/maintenance.py (+0/-206)
bin/addons/base/maintenance/maintenance_security.xml (+0/-6)
bin/addons/base/maintenance/maintenance_view.xml (+0/-131)
bin/addons/base/publisher_warranty/__init__.py (+25/-0)
bin/addons/base/publisher_warranty/publisher_warranty.py (+320/-0)
bin/addons/base/publisher_warranty/publisher_warranty_data.xml (+20/-0)
bin/addons/base/publisher_warranty/publisher_warranty_view.xml (+146/-0)
bin/addons/base/res/res_log.py (+6/-7)
bin/addons/base/res/res_log_view.xml (+2/-0)
bin/addons/base/security/ir.model.access.csv (+3/-2)
bin/netsvc.py (+1/-0)
bin/tools/config.py (+16/-8)
bin/tools/maintenance.py (+0/-69)
To merge this branch: bzr merge lp:~openerp-dev/openobject-server/niv-dev-server
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+41563@code.launchpad.net

Description of the change

Complete refactoring of the old maintenance sub-module in base

To post a comment you must log in.
3034. By Olivier Dony (Odoo)

[IMP] ir.model.data,res.log: allow marking res.log entries as read upon creation via context + do it during module install to avoid useless log spam

3035. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

3036. By OpenERP GTK R&D Team

[MERGE] read_group: now returns count information for the groups

3037. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

3038. By gpa(OpenERP)

[MERGE] ir.ui.menu,rng: support for embedded web icons for menuitems

3039. By Xavier (Open ERP)

[ADD] a few demo widgets

3040. By Xavier (Open ERP)

[IMP] have res.widget.wizard return its initial act_window itself to avoid hardcoding it in the client

3041. By Xavier (Open ERP)

[ADD] base: method to fetch an act_window from its xml_id on ir.actions.act_window

Also used it to replace the corresponding code in ir.attachment and res.widget.wizard

3042. By P. Christeas, O. Dony

[MERGE] many improvements regarding translations, logging, reports, http, speed, ...

3043. By qdp (OpenERP)

[MERGE] merged the report server branch

3044. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

3045. By Olivier Laurent (Open ERP)

[FIX] po file parser: database creation crashes if res_id is an empty string

3046. By Xavier (Open ERP)

[ADD] base: web_icon for administration and sales applications

3047. By Xavier (Open ERP)

[IMP] fix colspan on left-hand column of install wizards

3048. By Olivier Dony (Odoo)

[MERGE] font loading issues fixed + performance improvements at module install/load

3049. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

3050. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

3051. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

3052. By Olivier Dony (Odoo)

[MERGE] orm.read_group: partial support for orderby (m2o only so far)

3053. By Francois Degrave

[MERGE] base/rng: missing day_length added to gantt element

3054. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

3055. By Olivier Dony (Odoo)

[MERGE+FIX] fixes for translations,sequence,copy,error messages - some patches courtesy of Margarita Manterola and Don Kirkby

3056. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

3057. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

3058. By Olivier Laurent (Open ERP)

[FIX] base: res.widget.user: (transparently) prevent adding the same widget to the same user twice

3059. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

3060. By Olivier Dony (Odoo)

[FIX] base,yaml: fixed !assert with "count" attribute in yaml tests + enabled more tests in base

3061. By Olivier Dony (Odoo)

[MERGE] fix for bug 626806 by xrg - i.e. [(x2m,in,[])] should match nothing

3062. By Olivier Dony (Odoo)

[ADD] base: yaml tests for basic domain expressions (including some for bug 626806), mostly courtesy of xrg

3063. By Olivier Dony (Odoo)

[ADD] base: support alphabet-specific languages as in Rosetta + enabled Serbian@Latin

3064. By Olivier Dony (Odoo)

[I18N] base: updated PO template after latest cleanup

3065. By Christophe Simonis (OpenERP)

[FIX] base: check external dependencies at module update

3066. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

3067. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

3068. By Olivier Dony (Odoo)

[MERGE] fix for search view bug 681479 + improved support for images in RML, both courtesy of P. Christeas

3069. By Olivier Dony (Odoo)

[FIX] report.trml2pdf: fix path to locate <images> in RML

3070. By Olivier Dony (Odoo)

[FIX] orm.read_group: support ordering by any field (not just m2o ones)

3071. By Olivier Dony (Odoo)

[FIX] ir_values: revert GTK-specific hack for search_view_id after GTK client was fixed

3072. By Olivier Dony (Odoo)

[FIX] base: missing import _() in base_module_upgrade

3073. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

3074. By Olivier Dony (Odoo)

[FIX] reports: support for multi-company headers (pending improvements after v6.0)

3075. By Olivier Dony (Odoo)

[FIX] tools.misc: correct argument to subprocess.Popen (via xrg, analysis/patch courtesy of Michael Telahun Makonnen)

3076. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

3077. By Xavier (Open ERP)

[REM] @default attribute: not handled by the GTK client and not specified anywhere or by anyone

3078. By Olivier Dony (Odoo)

[FIX] osv.obj_list is broken via RPC and should not be available anymore

3079. By Olivier Dony (Odoo)

[IMP] license: renamed general license file, and included note about other applicable licenses

3080. By Olivier Dony (Odoo)

[FIX] base,release: updated some remaining source files to AGPLv3 license

3081. By Nicolas Vanhoren (OpenERP)

[MERGE] refactor maintenance.contract into publisher_warranty.contract + add system logs scheduler

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2009-12-02 10:01:14 +0000
+++ .bzrignore 2010-12-08 16:09:30 +0000
@@ -18,3 +18,6 @@
18build/18build/
19bin/yolk19bin/yolk
20bin/pil*.py20bin/pil*.py
21.project
22.pydevproject
23.settings
2124
=== modified file 'bin/addons/base/__init__.py'
--- bin/addons/base/__init__.py 2009-10-20 10:52:23 +0000
+++ bin/addons/base/__init__.py 2010-12-08 16:09:30 +0000
@@ -22,7 +22,7 @@
22import ir22import ir
23import module23import module
24import res24import res
25import maintenance25import publisher_warranty
2626
27# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:27# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
2828
2929
=== modified file 'bin/addons/base/__openerp__.py'
--- bin/addons/base/__openerp__.py 2010-12-03 14:20:35 +0000
+++ bin/addons/base/__openerp__.py 2010-12-08 16:09:30 +0000
@@ -71,11 +71,12 @@
7171
72 'res/ir_property_view.xml',72 'res/ir_property_view.xml',
73 'security/base_security.xml',73 'security/base_security.xml',
74 'maintenance/maintenance_view.xml',74 'publisher_warranty/publisher_warranty_view.xml',
7575
76 'security/ir.model.access.csv',76 'security/ir.model.access.csv',
77 'res/res_widget_view.xml',77 'res/res_widget_view.xml',
78 'res/res_widget_data.xml',78 'res/res_widget_data.xml',
79 'publisher_warranty/publisher_warranty_data.xml',
79 ],80 ],
80 'demo_xml': [81 'demo_xml': [
81 'base_demo.xml',82 'base_demo.xml',
8283
=== modified file 'bin/addons/base/ir/__init__.py'
--- bin/addons/base/ir/__init__.py 2010-11-10 15:04:48 +0000
+++ bin/addons/base/ir/__init__.py 2010-12-08 16:09:30 +0000
@@ -34,6 +34,7 @@
34import workflow34import workflow
35import ir_rule35import ir_rule
36import wizard36import wizard
37import ir_config_parameter
37import osv_memory_autovacuum38import osv_memory_autovacuum
3839
39# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:40# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
4041
=== added file 'bin/addons/base/ir/ir_config_parameter.py'
--- bin/addons/base/ir/ir_config_parameter.py 1970-01-01 00:00:00 +0000
+++ bin/addons/base/ir/ir_config_parameter.py 2010-12-08 16:09:30 +0000
@@ -0,0 +1,101 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21"""
22A module to store some configuration parameters relative to a whole database.
23"""
24
25from osv import osv,fields
26import uuid
27import datetime
28from tools import misc
29
30"""
31A dictionary holding some configuration parameters to be initialized when the database is created.
32"""
33_default_parameters = {
34 "database.uuid": lambda: str(uuid.uuid1()),
35 "database.create_date": lambda: datetime.datetime.now().strftime(misc.DEFAULT_SERVER_DATETIME_FORMAT),
36}
37
38class ir_config_parameter(osv.osv):
39 """ An osv to old configuration parameters for a given database.
40
41 To be short, it's just a global dictionary of strings stored in a table. """
42
43 _name = 'ir.config_parameter'
44
45 _columns = {
46 # The key of the configuration parameter.
47 'key': fields.char('Key', size=256, required=True, select=1),
48 # The value of the configuration parameter.
49 'value': fields.text('Value', required=True),
50 }
51
52 _sql_constraints = [
53 ('key_uniq', 'unique (key)', 'Key must be unique.')
54 ]
55
56 def init(self, cr):
57 """
58 Initializes the parameters listed in _default_parameters.
59 """
60 for key, func in _default_parameters.iteritems():
61 ids = self.search(cr, 1, [('key','=',key)])
62 if not ids:
63 self.set_param(cr, 1, key, func())
64
65 def get_param(self, cr, uid, key, context=None):
66 """ Get the value of a parameter.
67
68 @param key: The key of the parameter.
69 @type key: string
70 @return: The value of the parameter, False if it does not exist.
71 @rtype: string
72 """
73 ids = self.search(cr, uid, [('key','=',key)], context=context)
74 if not ids:
75 return False
76 param = self.browse(cr, uid, ids[0], context=context)
77 value = param.value
78 return value
79
80 def set_param(self, cr, uid, key, value, context=None):
81 """ Set the value of a parameter.
82
83 @param key: The key of the parameter.
84 @type key: string
85 @param value: The value of the parameter.
86 @type value: string
87 @return: Return the previous value of the parameter of False if it did
88 not existed.
89 @rtype: string
90 """
91 ids = self.search(cr, uid, [('key','=',key)], context=context)
92 if ids:
93 param = self.browse(cr, uid, ids[0], context=context)
94 old = param.value
95 self.write(cr, uid, ids, {'value': value}, context=context)
96 return old
97 else:
98 self.create(cr, uid, {'key': key, 'value': value}, context=context)
99 return False
100
101ir_config_parameter()
0102
=== modified file 'bin/addons/base/ir/ir_cron.py'
--- bin/addons/base/ir/ir_cron.py 2010-12-08 14:17:07 +0000
+++ bin/addons/base/ir/ir_cron.py 2010-12-08 16:09:30 +0000
@@ -144,7 +144,8 @@
144144
145 def restart(self, dbname):145 def restart(self, dbname):
146 self.cancel(dbname)146 self.cancel(dbname)
147 self._poolJobs(dbname)147 # Reschedule cron processing job asap, but not in the current thread
148 self.setAlarm(self._poolJobs, time.time(), dbname, dbname)
148149
149 def create(self, cr, uid, vals, context=None):150 def create(self, cr, uid, vals, context=None):
150 res = super(ir_cron, self).create(cr, uid, vals, context=context)151 res = super(ir_cron, self).create(cr, uid, vals, context=context)
151152
=== removed directory 'bin/addons/base/maintenance'
=== removed file 'bin/addons/base/maintenance/__init__.py'
--- bin/addons/base/maintenance/__init__.py 2009-10-20 10:52:23 +0000
+++ bin/addons/base/maintenance/__init__.py 1970-01-01 00:00:00 +0000
@@ -1,25 +0,0 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import maintenance
23
24# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
25
260
=== removed file 'bin/addons/base/maintenance/maintenance.py'
--- bin/addons/base/maintenance/maintenance.py 2009-10-20 10:52:23 +0000
+++ bin/addons/base/maintenance/maintenance.py 1970-01-01 00:00:00 +0000
@@ -1,206 +0,0 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from osv import osv, fields
23import pooler
24import time
25import netsvc
26
27from tools.misc import debug
28from tools.misc import ustr
29from tools.translate import _
30import tools.maintenance as tm
31
32class maintenance_contract_module(osv.osv):
33 _name ="maintenance.contract.module"
34 _description = "maintenance contract modules"
35 _columns = {
36 'name' : fields.char('Name', size=128, required=True),
37 'version': fields.char('Version', size=64,),
38 }
39
40maintenance_contract_module()
41
42class maintenance_contract(osv.osv):
43 _name = "maintenance.contract"
44 _description = "Maintenance Contract"
45
46 def _get_valid_contracts(self, cr, uid):
47 return [contract for contract in self.browse(cr, uid, self.search(cr, uid, [])) if contract.state == 'valid']
48
49 def status(self, cr, uid):
50 covered_modules, uncovered_modules = set(), set()
51
52 status = 'none'
53 for contract in self._get_valid_contracts(cr, uid):
54 covered_modules.update([m.name for m in contract.module_ids])
55
56 if covered_modules:
57 modobj = self.pool.get('ir.module.module')
58 modids = modobj.search(cr, uid, [('state', '=', 'installed')])
59 uncovered_modules = set(m.name for m in modobj.browse(cr, uid, modids)) - covered_modules
60 status = ['full', 'partial'][len(uncovered_modules) > 0]
61
62 return {
63 'status': status,
64 'uncovered_modules': list(uncovered_modules),
65 }
66
67 def send(self, cr, uid, tb, explanations, remarks=None):
68 status = self.status(cr, uid)
69 if status['status'] != 'full':
70 raise osv.except_osv(_('Error'), _("Your can't submit bug reports due to uncovered modules: %s") % (', '.join(status['uncovered_modules']),))
71
72 dbmsg = _('This error occurs on database %s') % (cr.dbname,)
73 if not remarks:
74 remarks = dbmsg
75 else:
76 remarks += '\n\n-----\n' + dbmsg
77
78 valid_contracts = self._get_valid_contracts(cr, uid)
79
80 crm_case_id = None
81 rc = None
82 try:
83 for contract in valid_contracts:
84 rc = tm.remote_contract(contract.name, contract.password)
85 if rc.id:
86 break
87 rc = None
88
89 if not rc:
90 raise osv.except_osv(_('Error'), _('Unable to find a valid contract'))
91
92 origin = 'client'
93 crm_case_id = rc.submit(rc.id, tb, explanations, remarks or '', origin)
94
95 except tm.RemoteContractException, rce:
96 netsvc.Logger().notifyChannel('maintenance', netsvc.LOG_INFO, rce)
97 except osv.except_osv:
98 raise
99 except:
100 pass
101
102 cid = rc and rc.name or valid_contracts[0].name
103 try:
104 # as backup, put it also in another database...
105 import urllib
106 args = urllib.urlencode({
107 'contract_id': cid,
108 'crm_case_id': crm_case_id or 0,
109 'explanation': explanations,
110 'remark': remarks or '',
111 'tb': tb,
112 })
113 uo = urllib.urlopen('http://www.openerp.com/scripts/maintenance.php', args)
114 submit_result = uo.read()
115 debug(submit_result)
116 uo.close()
117 except:
118 if not crm_case_id:
119 # TODO schedule a retry (ir.cron)
120 return False
121 return True
122
123 def _valid_get(self, cr, uid, ids, field_name, arg, context=None):
124 res = {}
125 for contract in self.browse(cr, uid, ids, context=context):
126 res[contract.id] = ("unvalid", "valid")[contract.date_stop >= time.strftime('%Y-%m-%d')]
127 return res
128
129 _columns = {
130 'name' : fields.char('Contract ID', size=256, required=True, readonly=True),
131 'password' : fields.char('Password', size=64, invisible=True, required=True, readonly=True),
132 'date_start' : fields.date('Starting Date', readonly=True),
133 'date_stop' : fields.date('Ending Date', readonly=True),
134 'module_ids' : fields.many2many('maintenance.contract.module', 'maintenance_contract_module_rel', 'contract_id', 'module_id', 'Covered Modules', readonly=True),
135 'state' : fields.function(_valid_get, method=True, string="State", type="selection", selection=[('valid', 'Valid'),('unvalid', 'Unvalid')], readonly=True),
136 'kind' : fields.selection([('full', 'Full'),('partial', 'Partial')], 'Kind', required=True, readonly=True),
137 }
138 _defaults = {
139 'password' : lambda obj,cr,uid,context={} : '',
140 }
141 _sql_constraints = [
142 ('uniq_name', 'unique(name)', "Your maintenance contract is already subscribed in the system !")
143 ]
144
145maintenance_contract()
146
147
148class maintenance_contract_wizard(osv.osv_memory):
149 _name = 'maintenance.contract.wizard'
150
151 _columns = {
152 'name' : fields.char('Contract ID', size=256, required=True ),
153 'password' : fields.char('Password', size=64, required=True),
154 'state' : fields.selection([('draft', 'Draft'),('validated', 'Validated'),('unvalidated', 'Unvalidated')], 'States'),
155 }
156
157 _defaults = {
158 'state' : lambda *a: 'draft',
159 }
160
161 def action_validate(self, cr, uid, ids, context=None):
162 if not ids:
163 return False
164
165 module_proxy = self.pool.get('ir.module.module')
166 module_ids = module_proxy.search(cr, uid, [('state', '=', 'installed')])
167 modules = module_proxy.read(cr, uid, module_ids, ['name', 'installed_version'])
168
169 contract = self.read(cr, uid, ids, ['name', 'password'])[0]
170
171 try:
172 contract_info = tm.remote_contract(contract['name'], contract['password'], modules)
173 except tm.RemoteContractException, rce:
174 raise osv.except_osv(_('Error'), ustr(rce))
175
176 is_ok = contract_info['status'] in ('partial', 'full')
177 if is_ok:
178 module_ids = []
179 if contract_info['modules_with_contract']:
180 for name, version in contract_info['modules_with_contract']:
181 contract_module = self.pool.get('maintenance.contract.module')
182 res = contract_module.search(cr, uid, [('name', '=', name),('version', '=', version)])
183 if not res:
184 id = contract_module.create(cr, uid, { 'name' : name, 'version' : version } )
185 else:
186 id = res[0]
187 module_ids.append(id)
188
189 self.pool.get('maintenance.contract').create(
190 cr,
191 uid, {
192 'name' : contract['name'],
193 'password' : contract['password'],
194 'date_start' : contract_info['date_from'],
195 'date_stop' : contract_info['date_to'],
196 'kind' : contract_info['status'],
197 'module_ids' : [(6,0,module_ids)],
198 }
199 )
200
201 return self.write(cr, uid, ids, {'state' : ('unvalidated', 'validated')[is_ok] }, context=context)
202
203maintenance_contract_wizard()
204
205# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
206
2070
=== removed file 'bin/addons/base/maintenance/maintenance_security.xml'
--- bin/addons/base/maintenance/maintenance_security.xml 2010-06-12 16:21:33 +0000
+++ bin/addons/base/maintenance/maintenance_security.xml 1970-01-01 00:00:00 +0000
@@ -1,6 +0,0 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3<data noupdate="0">
4
5</data>
6</openerp>
70
=== removed file 'bin/addons/base/maintenance/maintenance_view.xml'
--- bin/addons/base/maintenance/maintenance_view.xml 2010-10-15 06:54:45 +0000
+++ bin/addons/base/maintenance/maintenance_view.xml 1970-01-01 00:00:00 +0000
@@ -1,131 +0,0 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4
5 <record id="maintenance_contract_tree_view" model="ir.ui.view">
6 <field name="name">maintenance.contract.tree</field>
7 <field name="model">maintenance.contract</field>
8 <field name="type">tree</field>
9 <field name="arch" type="xml">
10 <tree string="Maintenance Contract">
11 <field name="name"/>
12 <field name="date_start"/>
13 <field name="date_stop"/>
14 <field name="state" />
15 </tree>
16 </field>
17 </record>
18
19 <record id="maintenance_contract_form_view" model="ir.ui.view">
20 <field name="name">maintenance.contract.form</field>
21 <field name="model">maintenance.contract</field>
22 <field name="type">form</field>
23 <field name="arch" type="xml">
24 <form string="Maintenance Contract">
25 <group col="6" colspan="4">
26 <field name="name"/>
27 <field name="date_start"/>
28 <field name="date_stop"/>
29 </group>
30 <separator string="Covered Modules" colspan="4"/>
31 <field name="module_ids" nolabel="1" colspan="4">
32 <tree string="Covered Modules">
33 <field name="name" />
34 <field name="version" />
35 </tree>
36 </field>
37 <field name="state" colspan="4"/>
38 </form>
39 </field>
40 </record>
41
42 <record id="maintenance_contract_search_view" model="ir.ui.view">
43 <field name="name">maintenance.contract.search</field>
44 <field name="model">maintenance.contract</field>
45 <field name="type">search</field>
46 <field name="arch" type="xml">
47 <search string="Maintenance Contract">
48 <field name="name"/>
49 <field name="date_start"/>
50 <field name="date_stop"/>
51 </search>
52 </field>
53 </record>
54
55 <record id="maintenance_contract_view_calendar" model="ir.ui.view">
56 <field name="name">maintenance.contract.calendar</field>
57 <field name="model">maintenance.contract</field>
58 <field name="type">calendar</field>
59 <field name="arch" type="xml">
60 <calendar string="Maintenance Contract" date_start="date_start" color="state">
61 <field name="name"/>
62 <field name="state"/>
63 </calendar>
64 </field>
65 </record>
66
67 <record id="action_maintenance_contract_form" model="ir.actions.act_window">
68 <field name="name">Maintenance Contracts</field>
69 <field name="type">ir.actions.act_window</field>
70 <field name="res_model">maintenance.contract</field>
71 <field name="view_type">form</field>
72 <field name="view_mode">tree,form,calendar</field>
73 <field name="search_view_id" ref="maintenance_contract_search_view"/>
74 </record>
75
76 <menuitem
77 name="Maintenance"
78 id="maintenance"
79 parent="base.menu_administration" groups="base.group_extended"/>
80
81 <menuitem
82 action="action_maintenance_contract_form"
83 id="menu_maintenance_contract"
84 parent="maintenance"/>
85
86 <record id="maintenance_contract_add_wizard" model="ir.ui.view">
87 <field name="name">maintenance.contract.add.wizard</field>
88 <field name="model">maintenance.contract.wizard</field>
89 <field name="type">form</field>
90 <field name="arch" type="xml">
91 <form string="Add Maintenance Contract" col="2">
92 <group col="1">
93 <separator string="Add Maintenance Contract" />
94 <group states="draft">
95 <field name="name" width="250" />
96 <newline />
97 <field name="password" password="True" />
98 <field name="state" invisible="1" />
99 </group>
100 <group states="validated">
101 <label string="Maintenance contract added !"/>
102 </group>
103 <group states="unvalidated">
104 <label string="Could you check your contract information ?" />
105 </group>
106 </group>
107 <group colspan="4">
108 <button type="object" string="_Cancel" icon="gtk-cancel" special="cancel" states="draft"/>
109 <button type="object" string="_Validate" icon="gtk-apply" name="action_validate" states="draft"/>
110 <button type="object" string="_Close" icon="gtk-close" special="cancel" states="validated,unvalidated"/>
111 </group>
112 </form>
113 </field>
114 </record>
115
116 <record id="action_maintenance_contract_add_wizard" model="ir.actions.act_window">
117 <field name="name">Add Maintenance Contract</field>
118 <field name="type">ir.actions.act_window</field>
119 <field name="res_model">maintenance.contract.wizard</field>
120 <field name="view_type">form</field>
121 <field name="view_mode">form</field>
122 <field name="target">new</field>
123 </record>
124
125 <menuitem
126 action="action_maintenance_contract_add_wizard"
127 id="menu_maintenance_contract_add"
128 parent="maintenance" />
129
130 </data>
131</openerp>
1320
=== added directory 'bin/addons/base/publisher_warranty'
=== added file 'bin/addons/base/publisher_warranty/__init__.py'
--- bin/addons/base/publisher_warranty/__init__.py 1970-01-01 00:00:00 +0000
+++ bin/addons/base/publisher_warranty/__init__.py 2010-12-08 16:09:30 +0000
@@ -0,0 +1,25 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import publisher_warranty
23
24# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
25
026
=== added file 'bin/addons/base/publisher_warranty/publisher_warranty.py'
--- bin/addons/base/publisher_warranty/publisher_warranty.py 1970-01-01 00:00:00 +0000
+++ bin/addons/base/publisher_warranty/publisher_warranty.py 2010-12-08 16:09:30 +0000
@@ -0,0 +1,320 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21"""
22Module to handle publisher warranty contracts as well as notifications from
23OpenERP.
24"""
25
26from osv import osv, fields
27import logging
28from tools.translate import _
29import urllib
30import urllib2
31from tools.safe_eval import safe_eval
32import pooler
33from tools.config import config
34import release
35import datetime
36from tools import misc
37import sys
38
39_logger = logging.getLogger(__name__)
40
41"""
42Time interval that will be used to determine up to which date we will
43check the logs to see if a message we just received was already logged.
44@type: datetime.timedelta
45"""
46_PREVIOUS_LOG_CHECK = datetime.timedelta(days=365)
47
48class publisher_warranty_contract(osv.osv):
49 """
50 Osv representing a publisher warranty contract.
51 """
52 _name = "publisher_warranty.contract"
53
54 def _get_valid_contracts(self, cr, uid):
55 """
56 Return the list of the valid contracts encoded in the system.
57
58 @return: A list of contracts
59 @rtype: list of publisher_warranty.contract browse records
60 """
61 return [contract for contract in self.browse(cr, uid, self.search(cr, uid, []))
62 if contract.state == 'valid']
63
64 def status(self, cr, uid):
65 """ Method called by the client to check availability of publisher warranty contract. """
66
67 contracts = self._get_valid_contracts(cr, uid)
68 return {
69 'status': "full" if contracts else "none" ,
70 'uncovered_modules': list(),
71 }
72
73 def send(self, cr, uid, tb, explanations, remarks=None):
74 """ Method called by the client to send a problem to the publisher warranty server. """
75
76 if not remarks:
77 remarks = ""
78
79 valid_contracts = self._get_valid_contracts(cr, uid)
80 valid_contract = valid_contracts[0]
81
82 try:
83 origin = 'client'
84 dbuuid = self.pool.get('ir.config_parameter').get_param(cr, uid, 'database.uuid')
85 db_create_date = self.pool.get('ir.config_parameter').get_param(cr, uid, 'database.create_date')
86
87 msg = {'contract_name': valid_contract.name,
88 'tb': tb,
89 'explanations': explanations,
90 'remarks': remarks,
91 'origin': origin,
92 'dbname': cr.dbname,
93 'dbuuid': dbuuid,
94 'db_create_date': db_create_date}
95
96
97 add_arg = {"timeout":30} if sys.version_info >= (2,6) else {}
98 uo = urllib2.urlopen(config.get("publisher_warranty_url"),
99 urllib.urlencode({'arg0': msg, "action": "send",}),**add_arg)
100 try:
101 submit_result = uo.read()
102 finally:
103 uo.close()
104
105 result = safe_eval(submit_result)
106
107 crm_case_id = result
108
109 if not crm_case_id:
110 return False
111
112 except osv.except_osv:
113 raise
114 except:
115 _logger.warning("Error sending problem report", exc_info=1)
116 raise osv.except_osv("Connection error", "An error occured during the connection " +
117 "with the publisher warranty server.")
118
119 return True
120
121 def check_validity(self, cr, uid, ids, context={}):
122 """
123 Check the validity of a publisher warranty contract. This method just call get_logs() but checks
124 some more things, so it can be called from a user interface.
125 """
126 contract_id = ids[0]
127 contract = self.browse(cr, uid, contract_id)
128 state = contract.state
129 validated = state != "unvalidated"
130
131 self.get_logs(cr, uid, ids, cron_mode=False, context=context)
132
133 contract = self.browse(cr, uid, contract_id)
134 validated2 = contract.state != "unvalidated"
135 if not validated and not validated2:
136 raise osv.except_osv(_("Contract validation error"),
137 _("Please check your publisher warranty contract name and validity."))
138
139 def get_logs(self, cr, uid, ids, cron_mode=True, context={}):
140 """
141 Send a message to OpenERP's publisher warranty server to check the validity of
142 the contracts, get notifications, etc...
143
144 @param cron_mode: If true, catch all exceptions (appropriate for usage in a cron).
145 @type cron_mode: boolean
146 """
147 try:
148 try:
149 result = get_sys_logs(cr, uid)
150 except:
151 _logger.debug("Exception while sending a get logs messages", exc_info=1)
152 raise osv.except_osv(_("Error"), _("Error during communication with the publisher warranty server."))
153
154 contracts = result["contracts"]
155 for contract in contracts:
156 c_id = self.search(cr, uid, [("name","=",contract)])[0]
157 date_from = contracts[contract][0]
158 date_to = contracts[contract][1]
159 state = contracts[contract][2]
160 self.write(cr, uid, c_id, {
161 "date_start": date_from,
162 "date_stop": date_to,
163 "state": state,
164 })
165
166 limit_date = (datetime.datetime.now() - _PREVIOUS_LOG_CHECK).strftime(misc.DEFAULT_SERVER_DATETIME_FORMAT)
167 for message in result["messages"]:
168 ids = self.pool.get("res.log").search(cr, uid, [("res_model", "=", "publisher_warranty.contract"),
169 ("create_date", ">=", limit_date),
170 ("name", "=", message)])
171 if ids:
172 continue
173 self.pool.get('res.log').create(cr, uid,
174 {
175 'name': message,
176 'res_model': "publisher_warranty.contract",
177 "read": True,
178 "user_id": False,
179 },
180 context=context
181 )
182 except:
183 if cron_mode:
184 return False # we don't want to see any stack trace in cron
185 else:
186 raise
187 return True
188
189 def get_last_user_messages(self, cr, uid, limit, context={}):
190 """
191 Get the messages to be written in the web client.
192 @return: A list of html messages with ids, can be False or empty.
193 @rtype: list of tuples(int,string)
194 """
195 ids = self.pool.get('res.log').search(cr, uid, [("res_model", "=", "publisher_warranty.contract")]
196 , order="create_date desc", limit=limit)
197 if not ids:
198 return []
199 messages = [(x.id, x.name) for x in self.pool.get('res.log').browse(cr, uid, ids)]
200
201 return messages
202
203 def del_user_message(self, cr, uid, id, context={}):
204 """
205 Delete a message.
206 """
207 self.pool.get('res.log').unlink(cr, uid, [id])
208
209 return True
210
211 _columns = {
212 'name' : fields.char('Serial Key', size=384, required=True),
213 'date_start' : fields.date('Starting Date', readonly=True),
214 'date_stop' : fields.date('Ending Date', readonly=True),
215 'state' : fields.selection([('unvalidated', 'Unvalidated'), ('valid', 'Valid')
216 , ('terminated', 'Terminated'), ('canceled', 'Canceled')], string="State", readonly=True),
217 'kind' : fields.char('Kind', size=64, readonly=True),
218 }
219
220 _defaults = {
221 'state': 'unvalidated',
222 }
223
224 _sql_constraints = [
225 ('uniq_name', 'unique(name)', "Your publisher warranty contract is already subscribed in the system !")
226 ]
227
228publisher_warranty_contract()
229
230class maintenance_contract(osv.osv_memory):
231 """ Old osv we only keep for compatibility with the clients. """
232
233 _name = "maintenance.contract"
234
235 def status(self, cr, uid):
236 return self.pool.get("publisher_warranty.contract").status(cr, uid)
237
238 def send(self, cr, uid, tb, explanations, remarks=None):
239 return self.pool.get("publisher_warranty.contract").send(cr, uid, tb, explanations, remarks)
240
241maintenance_contract()
242
243class publisher_warranty_contract_wizard(osv.osv_memory):
244 """
245 A wizard osv to help people entering a publisher warranty contract.
246 """
247 _name = 'publisher_warranty.contract.wizard'
248 _inherit = "ir.wizard.screen"
249
250 _columns = {
251 'name' : fields.char('Serial Key', size=256, required=True ),
252 'state' : fields.selection([("draft", "Draft"), ("finished", "Finished")])
253 }
254
255 _defaults = {
256 "state": "draft",
257 }
258
259 def action_validate(self, cr, uid, ids, context=None):
260 if not ids:
261 return False
262
263 wiz = self.browse(cr, uid, ids[0])
264 c_name = wiz.name
265
266 contract_osv = self.pool.get("publisher_warranty.contract")
267 contracts = contract_osv.search(cr, uid, [("name","=",c_name)])
268 if contracts:
269 raise osv.except_osv(_("Error"), _("That contract is already registered in the system."))
270
271 contract_id = contract_osv.create(cr, uid, {
272 "name": c_name,
273 "state": "unvalidated",
274 })
275
276 contract_osv.check_validity(cr, uid, [contract_id])
277
278 self.write(cr, uid, ids, {"state": "finished"})
279
280 return True
281
282
283publisher_warranty_contract_wizard()
284
285def get_sys_logs(cr, uid):
286 """
287 Utility method to send a publisher warranty get logs messages.
288 """
289 pool = pooler.get_pool(cr.dbname)
290
291 dbuuid = pool.get('ir.config_parameter').get_param(cr, uid, 'database.uuid')
292 db_create_date = pool.get('ir.config_parameter').get_param(cr, uid, 'database.create_date')
293 nbr_users = pool.get("res.users").search(cr, uid, [], count=True)
294 contractosv = pool.get('publisher_warranty.contract')
295 contracts = contractosv.browse(cr, uid, contractosv.search(cr, uid, []))
296 user = pool.get("res.users").browse(cr, uid, uid)
297 msg = {
298 "dbuuid": dbuuid,
299 "nbr_users": nbr_users,
300 "dbname": cr.dbname,
301 "db_create_date": db_create_date,
302 "version": release.version,
303 "contracts": [c.name for c in contracts],
304 "language": user.context_lang,
305 }
306
307 add_arg = {"timeout":30} if sys.version_info >= (2,6) else {}
308 uo = urllib2.urlopen(config.get("publisher_warranty_url"),
309 urllib.urlencode({'arg0': msg, "action": "update",}), **add_arg)
310 try:
311 submit_result = uo.read()
312 finally:
313 uo.close()
314
315 result = safe_eval(submit_result)
316
317 return result
318
319# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
320
0321
=== added file 'bin/addons/base/publisher_warranty/publisher_warranty_data.xml'
--- bin/addons/base/publisher_warranty/publisher_warranty_data.xml 1970-01-01 00:00:00 +0000
+++ bin/addons/base/publisher_warranty/publisher_warranty_data.xml 2010-12-08 16:09:30 +0000
@@ -0,0 +1,20 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<openerp>
3 <data>
4
5 <record id="ir_cron_ping_scheduler" model="ir.cron">
6 <field name="name">Update System Logs</field>
7 <field eval="True" name="active" />
8 <field name="user_id" ref="base.user_root" />
9 <field name="interval_number">1</field>
10 <field name="interval_type">weeks</field>
11 <field name="numbercall">-1</field>
12 <field eval="False" name="doall" />
13 <field eval="'publisher_warranty.contract'" name="model" />
14 <field eval="'get_logs'" name="function" />
15 <field eval="'(None,)'" name="args" />
16 <field name="priority">1000</field>
17 </record>
18
19 </data>
20</openerp>
0\ No newline at end of file21\ No newline at end of file
122
=== added file 'bin/addons/base/publisher_warranty/publisher_warranty_view.xml'
--- bin/addons/base/publisher_warranty/publisher_warranty_view.xml 1970-01-01 00:00:00 +0000
+++ bin/addons/base/publisher_warranty/publisher_warranty_view.xml 2010-12-08 16:09:30 +0000
@@ -0,0 +1,146 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4
5 <record id="publisher_warranty_contract_tree_view" model="ir.ui.view">
6 <field name="name">publisher_warranty.contract.tree</field>
7 <field name="model">publisher_warranty.contract</field>
8 <field name="type">tree</field>
9 <field name="arch" type="xml">
10 <tree string="Publisher Warranty Contracts">
11 <field name="name"/>
12 <field name="date_start"/>
13 <field name="date_stop"/>
14 <field name="state" />
15 </tree>
16 </field>
17 </record>
18
19 <record id="publisher_warranty_contract_form_view" model="ir.ui.view">
20 <field name="name">publisher_warranty.contract.form</field>
21 <field name="model">publisher_warranty.contract</field>
22 <field name="type">form</field>
23 <field name="arch" type="xml">
24 <form string="Publisher Warranty Contract">
25 <group col="2" colspan="4">
26 <group col="2">
27 <field name="name"/>
28 </group>
29 <group col="2">
30 <field name="date_start"/>
31 <field name="date_stop"/>
32 </group>
33 <group col="2">
34 <field name="state"/>
35 <field name="kind"/>
36 </group>
37 <group col="2">
38 <button name="check_validity" string="Validate" type="object"
39 attrs="{'invisible':[('state','in',['valid', 'terminated', 'canceled'])]}"/>
40 <button name="check_validity" string="Refresh Validation Dates" type="object"
41 attrs="{'invisible':[('state','in',['unvalidated'])]}"/>
42 </group>
43 </group>
44 </form>
45 </field>
46 </record>
47
48 <record id="publisher_warranty_contract_search_view" model="ir.ui.view">
49 <field name="name">publisher_warranty.contract.search</field>
50 <field name="model">publisher_warranty.contract</field>
51 <field name="type">search</field>
52 <field name="arch" type="xml">
53 <search string="Publisher Warranty Contract">
54 <field name="name"/>
55 <field name="date_start"/>
56 <field name="date_stop"/>
57 </search>
58 </field>
59 </record>
60
61 <record id="publisher_warranty_contract_view_calendar" model="ir.ui.view">
62 <field name="name">publisher_warranty.contract.calendar</field>
63 <field name="model">publisher_warranty.contract</field>
64 <field name="type">calendar</field>
65 <field name="arch" type="xml">
66 <calendar string="Maintenance Contract" date_start="date_start" color="state">
67 <field name="name"/>
68 <field name="state"/>
69 </calendar>
70 </field>
71 </record>
72
73 <record id="action_publisher_warranty_contract_form" model="ir.actions.act_window">
74 <field name="name">Contracts</field>
75 <field name="type">ir.actions.act_window</field>
76 <field name="res_model">publisher_warranty.contract</field>
77 <field name="view_type">form</field>
78 <field name="view_mode">tree,form,calendar</field>
79 <field name="search_view_id" ref="publisher_warranty_contract_search_view"/>
80 </record>
81
82 <menuitem name="Publisher Warranty" id="publisher_warranty"
83 parent="base.menu_administration" groups="base.group_extended"/>
84
85 <menuitem action="action_publisher_warranty_contract_form" id="menu_publisher_warranty_contract"
86 parent="publisher_warranty" sequence="2"/>
87
88
89 <record id="publisher_warranty_contract_add_wizard" model="ir.ui.view">
90 <field name="name">publisher_warranty.contract.add.wizard</field>
91 <field name="model">publisher_warranty.contract.wizard</field>
92 <field name="type">form</field>
93 <field name="arch" type="xml">
94 <form string="Register a Contract">
95 <group col="8">
96 <group colspan="3" col="1">
97 <field name="config_logo" widget="image" width="220" height="130" nolabel="1" colspan="1"/>
98 <newline/>
99 <label width="220" string="This wizard helps you register a publisher warranty contract in your OpenERP system. After the contract has been registered, you will be able to send issues directly to OpenERP."/>
100 <label width="220"/>
101 <label width="220" string=""/>
102 <field name="state" invisible="1"/>
103 </group>
104 <separator orientation="vertical" rowspan="5"/>
105 <group colspan="4">
106 <separator string="Register a Contract" colspan="4"/>
107 <group states="draft" col="4">
108 <label string="Please enter the serial key provided in your contract document:" colspan="4"/>
109 <field name="name" colspan="4"/>
110 </group>
111 <group states="finished" col="4">
112 <label string="Publisher warranty contract successfully registered!" colspan="4"/>
113 </group>
114 </group>
115 <group colspan="8" col="8" states="draft">
116 <separator string="" colspan="8"/>
117 <label colspan="6" width="220"/>
118 <button special="cancel" string="Cancel" icon="gtk-cancel"/>
119 <button name="action_validate" string="Register" type="object" icon="gtk-apply"/>
120 </group>
121 <group colspan="8" col="8" states="finished">
122 <separator string="" colspan="8"/>
123 <label colspan="6" width="220"/>
124 <button special="cancel" string="Close" icon="gtk-ok"/>
125 </group>
126 </group>
127 </form>
128 </field>
129 </record>
130
131 <record id="action_publisher_warranty_contract_add_wizard" model="ir.actions.act_window">
132 <field name="name">Register a Contract</field>
133 <field name="type">ir.actions.act_window</field>
134 <field name="res_model">publisher_warranty.contract.wizard</field>
135 <field name="view_type">form</field>
136 <field name="view_mode">form</field>
137 <field name="target">new</field>
138 </record>
139
140 <menuitem
141 action="action_publisher_warranty_contract_add_wizard"
142 id="menu_publisher_warranty_contract_add"
143 parent="publisher_warranty" sequence="1"/>
144
145 </data>
146</openerp>
0147
=== modified file 'bin/addons/base/res/res_log.py'
--- bin/addons/base/res/res_log.py 2010-11-23 16:05:06 +0000
+++ bin/addons/base/res/res_log.py 2010-12-08 16:09:30 +0000
@@ -20,24 +20,23 @@
20##############################################################################20##############################################################################
2121
22from osv import fields, osv22from osv import fields, osv
23import tools
2423
25class res_log(osv.osv):24class res_log(osv.osv):
26 _name = 'res.log'25 _name = 'res.log'
27 _columns = {26 _columns = {
28 'name': fields.char('Message', size=128, help='The logging message.', required=True),27 'name': fields.char('Message', size=250, help='The logging message.', required=True, select=1),
29 'user_id': fields.many2one('res.users','User', required=True),28 'user_id': fields.many2one('res.users','User'),
30 'res_model': fields.char('Object', size=128),29 'res_model': fields.char('Object', size=128, select=1),
31 'context': fields.char('Context', size=250),30 'context': fields.char('Context', size=250),
32 'res_id': fields.integer('Object ID'),31 'res_id': fields.integer('Object ID'),
33 'secondary': fields.boolean('Secondary Log', help='Do not display this log if it belongs to the same object the user is working on'),32 'secondary': fields.boolean('Secondary Log', help='Do not display this log if it belongs to the same object the user is working on'),
34 'create_date': fields.datetime('Created Date', readonly=True),33 'create_date': fields.datetime('Created Date', readonly=True, select=1),
35 'read': fields.boolean('Read', help="If this log item has been read, get() should not send it to the client")34 'read': fields.boolean('Read', help="If this log item has been read, get() should not send it to the client"),
36 }35 }
37 _defaults = {36 _defaults = {
38 'user_id': lambda self,cr,uid,ctx: uid,37 'user_id': lambda self,cr,uid,ctx: uid,
39 'context': "{}",38 'context': "{}",
40 'read': False39 'read': False,
41 }40 }
42 _order='create_date desc'41 _order='create_date desc'
4342
4443
=== modified file 'bin/addons/base/res/res_log_view.xml'
--- bin/addons/base/res/res_log_view.xml 2010-10-17 21:47:55 +0000
+++ bin/addons/base/res/res_log_view.xml 2010-12-08 16:09:30 +0000
@@ -11,6 +11,8 @@
11 <filter icon="terp-stock_align_left_24" string="Unread" domain="[('read','&lt;&gt;',True)]" name="unread"/>11 <filter icon="terp-stock_align_left_24" string="Unread" domain="[('read','&lt;&gt;',True)]" name="unread"/>
12 <separator orientation="vertical"/>12 <separator orientation="vertical"/>
13 <filter icon="terp-stock_align_left_24" string="My Logs" domain="[('user_id','=',uid)]" name="my"/>13 <filter icon="terp-stock_align_left_24" string="My Logs" domain="[('user_id','=',uid)]" name="my"/>
14 <filter icon="terp-stock_align_left_24" string="System Logs"
15 domain="[('res_model','=','publisher_warranty.contract')]" name="sys"/>
14 <separator orientation="vertical"/>16 <separator orientation="vertical"/>
15 <field name="name"/>17 <field name="name"/>
16 <field name="user_id"/>18 <field name="user_id"/>
1719
=== modified file 'bin/addons/base/security/ir.model.access.csv'
--- bin/addons/base/security/ir.model.access.csv 2010-10-17 21:30:11 +0000
+++ bin/addons/base/security/ir.model.access.csv 2010-12-08 16:09:30 +0000
@@ -112,8 +112,8 @@
112"access_res_payterm_group_system","res_payterm_group_system","model_res_payterm","group_system",1,1,1,1112"access_res_payterm_group_system","res_payterm_group_system","model_res_payterm","group_system",1,1,1,1
113"access_res_bank_group_partner_manager","res_bank_group_partner_manager","model_res_bank","group_partner_manager",1,1,1,1113"access_res_bank_group_partner_manager","res_bank_group_partner_manager","model_res_bank","group_partner_manager",1,1,1,1
114"access_res_bank_user","res_bank user","model_res_bank","group_user",1,0,0,0114"access_res_bank_user","res_bank user","model_res_bank","group_user",1,0,0,0
115"access_maintenance_group_user","maintenance_contract group_user","model_maintenance_contract","group_system",1,1,1,1115"access_publisher_warranty_group_user","publisher_warranty_contract group_user","model_publisher_warranty_contract","group_system",1,1,1,1
116"access_maintenance_contract_module","maintenance.contract.module","model_maintenance_contract_module","group_system",1,1,1,1116"access_publisher_warranty_all","publisher_warranty_contract all","model_publisher_warranty_contract",,1,0,0,0
117"access_multi_company_default user","multi_company_default all","model_multi_company_default",,1,0,0,0117"access_multi_company_default user","multi_company_default all","model_multi_company_default",,1,0,0,0
118"access_multi_company_default manager","multi_company_default Manager","model_multi_company_default","group_erp_manager",1,1,1,1118"access_multi_company_default manager","multi_company_default Manager","model_multi_company_default","group_erp_manager",1,1,1,1
119"access_ir_filter all","ir_filters all","model_ir_filters",,1,0,0,0119"access_ir_filter all","ir_filters all","model_ir_filters",,1,0,0,0
@@ -123,3 +123,4 @@
123"access_res_widget","res.widget","model_res_widget","group_erp_manager",1,1,1,1123"access_res_widget","res.widget","model_res_widget","group_erp_manager",1,1,1,1
124"access_res_widget_user","res.widget.user","model_res_widget",,1,0,0,0124"access_res_widget_user","res.widget.user","model_res_widget",,1,0,0,0
125"access_res_log_all","res.log","model_res_log",,1,1,1,1125"access_res_log_all","res.log","model_res_log",,1,1,1,1
126"access_ir_config_parameter","ir_config_parameter","model_ir_config_parameter",,1,0,0,0
126127
=== modified file 'bin/netsvc.py'
--- bin/netsvc.py 2010-11-26 13:02:25 +0000
+++ bin/netsvc.py 2010-12-08 16:09:30 +0000
@@ -490,6 +490,7 @@
490 self.log('result', result, channel=logging.DEBUG_RPC_ANSWER, depth=(logger.isEnabledFor(logging.DEBUG_SQL) and 5 or 3))490 self.log('result', result, channel=logging.DEBUG_RPC_ANSWER, depth=(logger.isEnabledFor(logging.DEBUG_SQL) and 5 or 3))
491 return result491 return result
492 except Exception, e:492 except Exception, e:
493 logging.getLogger(__name__).exception("Dispatcher error")
493 self.log('exception', tools.exception_to_unicode(e))494 self.log('exception', tools.exception_to_unicode(e))
494 tb = getattr(e, 'traceback', sys.exc_info())495 tb = getattr(e, 'traceback', sys.exc_info())
495 tb_s = "".join(traceback.format_exception(*tb))496 tb_s = "".join(traceback.format_exception(*tb))
496497
=== modified file 'bin/tools/config.py'
--- bin/tools/config.py 2010-11-17 12:39:28 +0000
+++ bin/tools/config.py 2010-12-08 16:09:30 +0000
@@ -31,8 +31,8 @@
31 try:31 try:
32 from OpenSSL import SSL32 from OpenSSL import SSL
33 import socket33 import socket
3434
35 return hasattr(socket, 'ssl')35 return hasattr(socket, 'ssl') and hasattr(SSL, "Connection")
36 except:36 except:
37 return False37 return False
3838
@@ -91,7 +91,10 @@
91 'static_http_url_prefix': None,91 'static_http_url_prefix': None,
92 'secure_cert_file': 'server.cert',92 'secure_cert_file': 'server.cert',
93 'secure_pkey_file': 'server.pkey',93 'secure_pkey_file': 'server.pkey',
94 'publisher_warranty_url': 'http://www.openerp.com/publisher-warranty',
94 }95 }
96
97 self.blacklist_for_save = set(["publisher_warranty_url"])
9598
96 self.misc = {}99 self.misc = {}
97 self.config_file = fname100 self.config_file = fname
@@ -224,7 +227,7 @@
224 parser.add_option_group(security)227 parser.add_option_group(security)
225228
226 def parse_config(self):229 def parse_config(self):
227 (opt, args) = self.parser.parse_args()230 opt = self.parser.parse_args()[0]
228231
229 def die(cond, msg):232 def die(cond, msg):
230 if cond:233 if cond:
@@ -317,7 +320,7 @@
317 # If an explicit TZ was provided in the config, make sure it is known320 # If an explicit TZ was provided in the config, make sure it is known
318 try:321 try:
319 import pytz322 import pytz
320 tz = pytz.timezone(self.options['timezone'])323 pytz.timezone(self.options['timezone'])
321 except pytz.UnknownTimeZoneError:324 except pytz.UnknownTimeZoneError:
322 die(True, "The specified timezone (%s) is invalid" % self.options['timezone'])325 die(True, "The specified timezone (%s) is invalid" % self.options['timezone'])
323 except:326 except:
@@ -374,7 +377,10 @@
374 fp.close()377 fp.close()
375378
376 if is_win32:379 if is_win32:
377 import _winreg380 try:
381 import _winreg
382 except ImportError:
383 _winreg = None
378 x=_winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)384 x=_winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
379 y = _winreg.OpenKey(x, r"SYSTEM\CurrentControlSet\Control\Session Manager\Environment", 0,_winreg.KEY_ALL_ACCESS)385 y = _winreg.OpenKey(x, r"SYSTEM\CurrentControlSet\Control\Session Manager\Environment", 0,_winreg.KEY_ALL_ACCESS)
380 _winreg.SetValueEx(y,"PGPASSFILE", 0, _winreg.REG_EXPAND_SZ, filename )386 _winreg.SetValueEx(y,"PGPASSFILE", 0, _winreg.REG_EXPAND_SZ, filename )
@@ -436,16 +442,18 @@
436 p = ConfigParser.ConfigParser()442 p = ConfigParser.ConfigParser()
437 loglevelnames = dict(zip(self._LOGLEVELS.values(), self._LOGLEVELS.keys()))443 loglevelnames = dict(zip(self._LOGLEVELS.values(), self._LOGLEVELS.keys()))
438 p.add_section('options')444 p.add_section('options')
439 for opt in self.options.keys():445 for opt in sorted(self.options.keys()):
440 if opt in ('version', 'language', 'translate_out', 'translate_in', 'init', 'update'):446 if opt in ('version', 'language', 'translate_out', 'translate_in', 'init', 'update'):
441 continue447 continue
448 if opt in self.blacklist_for_save:
449 continue
442 if opt in ('log_level', 'assert_exit_level'):450 if opt in ('log_level', 'assert_exit_level'):
443 p.set('options', opt, loglevelnames.get(self.options[opt], self.options[opt]))451 p.set('options', opt, loglevelnames.get(self.options[opt], self.options[opt]))
444 else:452 else:
445 p.set('options', opt, self.options[opt])453 p.set('options', opt, self.options[opt])
446454
447 for sec in self.misc.keys():455 for sec in sorted(self.misc.keys()):
448 for opt in self.misc[sec].keys():456 for opt in sorted(self.misc[sec].keys()):
449 p.set(sec,opt,self.misc[sec][opt])457 p.set(sec,opt,self.misc[sec][opt])
450458
451 # try to create the directories and write the file459 # try to create the directories and write the file
452460
=== removed file 'bin/tools/maintenance.py'
--- bin/tools/maintenance.py 2009-10-20 10:52:23 +0000
+++ bin/tools/maintenance.py 1970-01-01 00:00:00 +0000
@@ -1,69 +0,0 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import xmlrpclib
23
24class RemoteContractException(Exception): pass
25
26class remote_contract(object):
27 def __init__(self, contract_id, contract_password, modules=None):
28 self.__server = 'http://tiny.my.odoo.com:8069/xmlrpc/'
29 self.__db = "tiny_belgium"
30 self.__password = "maintenance"
31 self.__login = "maintenance"
32
33 rpc = xmlrpclib.ServerProxy(self.__server + 'common')
34 try:
35 self.__userid = rpc.login(self.__db, self.__login, self.__password)
36 except:
37 raise RemoteContractException("Unable to contact the migration server")
38
39 if not self.__userid:
40 raise RemoteContractException("Unable to contact the migration server")
41
42 self.__rpc = xmlrpclib.ServerProxy(self.__server + 'object')
43
44
45 contract = {
46 'name': contract_id,
47 'password': contract_password,
48 }
49 if modules is None:
50 modules = []
51
52 info = self.check_contract(modules, contract)
53 for n in info:
54 setattr(self, n, info[n])
55
56 self.name = contract_id
57 self.contract_id = self.name
58 self.password = contract_password
59
60 def __getattr__(self, fun):
61 def remote_call(*args, **kwargs):
62 return self.__rpc.execute(self.__db, self.__userid, self.__password, 'maintenance.maintenance', fun, *args, **kwargs)
63 return remote_call
64
65 def __getitem__(self, item):
66 return getattr(self, item)
67
68# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
69