Merge lp:~openerp-dev/openobject-server/niv-dev-server into lp:openobject-server
- niv-dev-server
- Merge into trunk
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
OpenERP Core Team | Pending | ||
Review via email: mp+41563@code.launchpad.net |
Commit message
Description of the change
Complete refactoring of the old maintenance sub-module in base
- 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
1 | === modified file '.bzrignore' | |||
2 | --- .bzrignore 2009-12-02 10:01:14 +0000 | |||
3 | +++ .bzrignore 2010-12-08 16:09:30 +0000 | |||
4 | @@ -18,3 +18,6 @@ | |||
5 | 18 | build/ | 18 | build/ |
6 | 19 | bin/yolk | 19 | bin/yolk |
7 | 20 | bin/pil*.py | 20 | bin/pil*.py |
8 | 21 | .project | ||
9 | 22 | .pydevproject | ||
10 | 23 | .settings | ||
11 | 21 | 24 | ||
12 | === modified file 'bin/addons/base/__init__.py' | |||
13 | --- bin/addons/base/__init__.py 2009-10-20 10:52:23 +0000 | |||
14 | +++ bin/addons/base/__init__.py 2010-12-08 16:09:30 +0000 | |||
15 | @@ -22,7 +22,7 @@ | |||
16 | 22 | import ir | 22 | import ir |
17 | 23 | import module | 23 | import module |
18 | 24 | import res | 24 | import res |
20 | 25 | import maintenance | 25 | import publisher_warranty |
21 | 26 | 26 | ||
22 | 27 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | 27 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
23 | 28 | 28 | ||
24 | 29 | 29 | ||
25 | === modified file 'bin/addons/base/__openerp__.py' | |||
26 | --- bin/addons/base/__openerp__.py 2010-12-03 14:20:35 +0000 | |||
27 | +++ bin/addons/base/__openerp__.py 2010-12-08 16:09:30 +0000 | |||
28 | @@ -71,11 +71,12 @@ | |||
29 | 71 | 71 | ||
30 | 72 | 'res/ir_property_view.xml', | 72 | 'res/ir_property_view.xml', |
31 | 73 | 'security/base_security.xml', | 73 | 'security/base_security.xml', |
33 | 74 | 'maintenance/maintenance_view.xml', | 74 | 'publisher_warranty/publisher_warranty_view.xml', |
34 | 75 | 75 | ||
35 | 76 | 'security/ir.model.access.csv', | 76 | 'security/ir.model.access.csv', |
36 | 77 | 'res/res_widget_view.xml', | 77 | 'res/res_widget_view.xml', |
37 | 78 | 'res/res_widget_data.xml', | 78 | 'res/res_widget_data.xml', |
38 | 79 | 'publisher_warranty/publisher_warranty_data.xml', | ||
39 | 79 | ], | 80 | ], |
40 | 80 | 'demo_xml': [ | 81 | 'demo_xml': [ |
41 | 81 | 'base_demo.xml', | 82 | 'base_demo.xml', |
42 | 82 | 83 | ||
43 | === modified file 'bin/addons/base/ir/__init__.py' | |||
44 | --- bin/addons/base/ir/__init__.py 2010-11-10 15:04:48 +0000 | |||
45 | +++ bin/addons/base/ir/__init__.py 2010-12-08 16:09:30 +0000 | |||
46 | @@ -34,6 +34,7 @@ | |||
47 | 34 | import workflow | 34 | import workflow |
48 | 35 | import ir_rule | 35 | import ir_rule |
49 | 36 | import wizard | 36 | import wizard |
50 | 37 | import ir_config_parameter | ||
51 | 37 | import osv_memory_autovacuum | 38 | import osv_memory_autovacuum |
52 | 38 | 39 | ||
53 | 39 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | 40 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
54 | 40 | 41 | ||
55 | === added file 'bin/addons/base/ir/ir_config_parameter.py' | |||
56 | --- bin/addons/base/ir/ir_config_parameter.py 1970-01-01 00:00:00 +0000 | |||
57 | +++ bin/addons/base/ir/ir_config_parameter.py 2010-12-08 16:09:30 +0000 | |||
58 | @@ -0,0 +1,101 @@ | |||
59 | 1 | # -*- coding: utf-8 -*- | ||
60 | 2 | ############################################################################## | ||
61 | 3 | # | ||
62 | 4 | # OpenERP, Open Source Management Solution | ||
63 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
64 | 6 | # | ||
65 | 7 | # This program is free software: you can redistribute it and/or modify | ||
66 | 8 | # it under the terms of the GNU Affero General Public License as | ||
67 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
68 | 10 | # License, or (at your option) any later version. | ||
69 | 11 | # | ||
70 | 12 | # This program is distributed in the hope that it will be useful, | ||
71 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
72 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
73 | 15 | # GNU Affero General Public License for more details. | ||
74 | 16 | # | ||
75 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
76 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
77 | 19 | # | ||
78 | 20 | ############################################################################## | ||
79 | 21 | """ | ||
80 | 22 | A module to store some configuration parameters relative to a whole database. | ||
81 | 23 | """ | ||
82 | 24 | |||
83 | 25 | from osv import osv,fields | ||
84 | 26 | import uuid | ||
85 | 27 | import datetime | ||
86 | 28 | from tools import misc | ||
87 | 29 | |||
88 | 30 | """ | ||
89 | 31 | A dictionary holding some configuration parameters to be initialized when the database is created. | ||
90 | 32 | """ | ||
91 | 33 | _default_parameters = { | ||
92 | 34 | "database.uuid": lambda: str(uuid.uuid1()), | ||
93 | 35 | "database.create_date": lambda: datetime.datetime.now().strftime(misc.DEFAULT_SERVER_DATETIME_FORMAT), | ||
94 | 36 | } | ||
95 | 37 | |||
96 | 38 | class ir_config_parameter(osv.osv): | ||
97 | 39 | """ An osv to old configuration parameters for a given database. | ||
98 | 40 | |||
99 | 41 | To be short, it's just a global dictionary of strings stored in a table. """ | ||
100 | 42 | |||
101 | 43 | _name = 'ir.config_parameter' | ||
102 | 44 | |||
103 | 45 | _columns = { | ||
104 | 46 | # The key of the configuration parameter. | ||
105 | 47 | 'key': fields.char('Key', size=256, required=True, select=1), | ||
106 | 48 | # The value of the configuration parameter. | ||
107 | 49 | 'value': fields.text('Value', required=True), | ||
108 | 50 | } | ||
109 | 51 | |||
110 | 52 | _sql_constraints = [ | ||
111 | 53 | ('key_uniq', 'unique (key)', 'Key must be unique.') | ||
112 | 54 | ] | ||
113 | 55 | |||
114 | 56 | def init(self, cr): | ||
115 | 57 | """ | ||
116 | 58 | Initializes the parameters listed in _default_parameters. | ||
117 | 59 | """ | ||
118 | 60 | for key, func in _default_parameters.iteritems(): | ||
119 | 61 | ids = self.search(cr, 1, [('key','=',key)]) | ||
120 | 62 | if not ids: | ||
121 | 63 | self.set_param(cr, 1, key, func()) | ||
122 | 64 | |||
123 | 65 | def get_param(self, cr, uid, key, context=None): | ||
124 | 66 | """ Get the value of a parameter. | ||
125 | 67 | |||
126 | 68 | @param key: The key of the parameter. | ||
127 | 69 | @type key: string | ||
128 | 70 | @return: The value of the parameter, False if it does not exist. | ||
129 | 71 | @rtype: string | ||
130 | 72 | """ | ||
131 | 73 | ids = self.search(cr, uid, [('key','=',key)], context=context) | ||
132 | 74 | if not ids: | ||
133 | 75 | return False | ||
134 | 76 | param = self.browse(cr, uid, ids[0], context=context) | ||
135 | 77 | value = param.value | ||
136 | 78 | return value | ||
137 | 79 | |||
138 | 80 | def set_param(self, cr, uid, key, value, context=None): | ||
139 | 81 | """ Set the value of a parameter. | ||
140 | 82 | |||
141 | 83 | @param key: The key of the parameter. | ||
142 | 84 | @type key: string | ||
143 | 85 | @param value: The value of the parameter. | ||
144 | 86 | @type value: string | ||
145 | 87 | @return: Return the previous value of the parameter of False if it did | ||
146 | 88 | not existed. | ||
147 | 89 | @rtype: string | ||
148 | 90 | """ | ||
149 | 91 | ids = self.search(cr, uid, [('key','=',key)], context=context) | ||
150 | 92 | if ids: | ||
151 | 93 | param = self.browse(cr, uid, ids[0], context=context) | ||
152 | 94 | old = param.value | ||
153 | 95 | self.write(cr, uid, ids, {'value': value}, context=context) | ||
154 | 96 | return old | ||
155 | 97 | else: | ||
156 | 98 | self.create(cr, uid, {'key': key, 'value': value}, context=context) | ||
157 | 99 | return False | ||
158 | 100 | |||
159 | 101 | ir_config_parameter() | ||
160 | 0 | 102 | ||
161 | === modified file 'bin/addons/base/ir/ir_cron.py' | |||
162 | --- bin/addons/base/ir/ir_cron.py 2010-12-08 14:17:07 +0000 | |||
163 | +++ bin/addons/base/ir/ir_cron.py 2010-12-08 16:09:30 +0000 | |||
164 | @@ -144,7 +144,8 @@ | |||
165 | 144 | 144 | ||
166 | 145 | def restart(self, dbname): | 145 | def restart(self, dbname): |
167 | 146 | self.cancel(dbname) | 146 | self.cancel(dbname) |
169 | 147 | self._poolJobs(dbname) | 147 | # Reschedule cron processing job asap, but not in the current thread |
170 | 148 | self.setAlarm(self._poolJobs, time.time(), dbname, dbname) | ||
171 | 148 | 149 | ||
172 | 149 | def create(self, cr, uid, vals, context=None): | 150 | def create(self, cr, uid, vals, context=None): |
173 | 150 | res = super(ir_cron, self).create(cr, uid, vals, context=context) | 151 | res = super(ir_cron, self).create(cr, uid, vals, context=context) |
174 | 151 | 152 | ||
175 | === removed directory 'bin/addons/base/maintenance' | |||
176 | === removed file 'bin/addons/base/maintenance/__init__.py' | |||
177 | --- bin/addons/base/maintenance/__init__.py 2009-10-20 10:52:23 +0000 | |||
178 | +++ bin/addons/base/maintenance/__init__.py 1970-01-01 00:00:00 +0000 | |||
179 | @@ -1,25 +0,0 @@ | |||
180 | 1 | # -*- coding: utf-8 -*- | ||
181 | 2 | ############################################################################## | ||
182 | 3 | # | ||
183 | 4 | # OpenERP, Open Source Management Solution | ||
184 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
185 | 6 | # | ||
186 | 7 | # This program is free software: you can redistribute it and/or modify | ||
187 | 8 | # it under the terms of the GNU Affero General Public License as | ||
188 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
189 | 10 | # License, or (at your option) any later version. | ||
190 | 11 | # | ||
191 | 12 | # This program is distributed in the hope that it will be useful, | ||
192 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
193 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
194 | 15 | # GNU Affero General Public License for more details. | ||
195 | 16 | # | ||
196 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
197 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
198 | 19 | # | ||
199 | 20 | ############################################################################## | ||
200 | 21 | |||
201 | 22 | import maintenance | ||
202 | 23 | |||
203 | 24 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
204 | 25 | |||
205 | 26 | 0 | ||
206 | === removed file 'bin/addons/base/maintenance/maintenance.py' | |||
207 | --- bin/addons/base/maintenance/maintenance.py 2009-10-20 10:52:23 +0000 | |||
208 | +++ bin/addons/base/maintenance/maintenance.py 1970-01-01 00:00:00 +0000 | |||
209 | @@ -1,206 +0,0 @@ | |||
210 | 1 | # -*- coding: utf-8 -*- | ||
211 | 2 | ############################################################################## | ||
212 | 3 | # | ||
213 | 4 | # OpenERP, Open Source Management Solution | ||
214 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
215 | 6 | # | ||
216 | 7 | # This program is free software: you can redistribute it and/or modify | ||
217 | 8 | # it under the terms of the GNU Affero General Public License as | ||
218 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
219 | 10 | # License, or (at your option) any later version. | ||
220 | 11 | # | ||
221 | 12 | # This program is distributed in the hope that it will be useful, | ||
222 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
223 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
224 | 15 | # GNU Affero General Public License for more details. | ||
225 | 16 | # | ||
226 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
227 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
228 | 19 | # | ||
229 | 20 | ############################################################################## | ||
230 | 21 | |||
231 | 22 | from osv import osv, fields | ||
232 | 23 | import pooler | ||
233 | 24 | import time | ||
234 | 25 | import netsvc | ||
235 | 26 | |||
236 | 27 | from tools.misc import debug | ||
237 | 28 | from tools.misc import ustr | ||
238 | 29 | from tools.translate import _ | ||
239 | 30 | import tools.maintenance as tm | ||
240 | 31 | |||
241 | 32 | class maintenance_contract_module(osv.osv): | ||
242 | 33 | _name ="maintenance.contract.module" | ||
243 | 34 | _description = "maintenance contract modules" | ||
244 | 35 | _columns = { | ||
245 | 36 | 'name' : fields.char('Name', size=128, required=True), | ||
246 | 37 | 'version': fields.char('Version', size=64,), | ||
247 | 38 | } | ||
248 | 39 | |||
249 | 40 | maintenance_contract_module() | ||
250 | 41 | |||
251 | 42 | class maintenance_contract(osv.osv): | ||
252 | 43 | _name = "maintenance.contract" | ||
253 | 44 | _description = "Maintenance Contract" | ||
254 | 45 | |||
255 | 46 | def _get_valid_contracts(self, cr, uid): | ||
256 | 47 | return [contract for contract in self.browse(cr, uid, self.search(cr, uid, [])) if contract.state == 'valid'] | ||
257 | 48 | |||
258 | 49 | def status(self, cr, uid): | ||
259 | 50 | covered_modules, uncovered_modules = set(), set() | ||
260 | 51 | |||
261 | 52 | status = 'none' | ||
262 | 53 | for contract in self._get_valid_contracts(cr, uid): | ||
263 | 54 | covered_modules.update([m.name for m in contract.module_ids]) | ||
264 | 55 | |||
265 | 56 | if covered_modules: | ||
266 | 57 | modobj = self.pool.get('ir.module.module') | ||
267 | 58 | modids = modobj.search(cr, uid, [('state', '=', 'installed')]) | ||
268 | 59 | uncovered_modules = set(m.name for m in modobj.browse(cr, uid, modids)) - covered_modules | ||
269 | 60 | status = ['full', 'partial'][len(uncovered_modules) > 0] | ||
270 | 61 | |||
271 | 62 | return { | ||
272 | 63 | 'status': status, | ||
273 | 64 | 'uncovered_modules': list(uncovered_modules), | ||
274 | 65 | } | ||
275 | 66 | |||
276 | 67 | def send(self, cr, uid, tb, explanations, remarks=None): | ||
277 | 68 | status = self.status(cr, uid) | ||
278 | 69 | if status['status'] != 'full': | ||
279 | 70 | raise osv.except_osv(_('Error'), _("Your can't submit bug reports due to uncovered modules: %s") % (', '.join(status['uncovered_modules']),)) | ||
280 | 71 | |||
281 | 72 | dbmsg = _('This error occurs on database %s') % (cr.dbname,) | ||
282 | 73 | if not remarks: | ||
283 | 74 | remarks = dbmsg | ||
284 | 75 | else: | ||
285 | 76 | remarks += '\n\n-----\n' + dbmsg | ||
286 | 77 | |||
287 | 78 | valid_contracts = self._get_valid_contracts(cr, uid) | ||
288 | 79 | |||
289 | 80 | crm_case_id = None | ||
290 | 81 | rc = None | ||
291 | 82 | try: | ||
292 | 83 | for contract in valid_contracts: | ||
293 | 84 | rc = tm.remote_contract(contract.name, contract.password) | ||
294 | 85 | if rc.id: | ||
295 | 86 | break | ||
296 | 87 | rc = None | ||
297 | 88 | |||
298 | 89 | if not rc: | ||
299 | 90 | raise osv.except_osv(_('Error'), _('Unable to find a valid contract')) | ||
300 | 91 | |||
301 | 92 | origin = 'client' | ||
302 | 93 | crm_case_id = rc.submit(rc.id, tb, explanations, remarks or '', origin) | ||
303 | 94 | |||
304 | 95 | except tm.RemoteContractException, rce: | ||
305 | 96 | netsvc.Logger().notifyChannel('maintenance', netsvc.LOG_INFO, rce) | ||
306 | 97 | except osv.except_osv: | ||
307 | 98 | raise | ||
308 | 99 | except: | ||
309 | 100 | pass | ||
310 | 101 | |||
311 | 102 | cid = rc and rc.name or valid_contracts[0].name | ||
312 | 103 | try: | ||
313 | 104 | # as backup, put it also in another database... | ||
314 | 105 | import urllib | ||
315 | 106 | args = urllib.urlencode({ | ||
316 | 107 | 'contract_id': cid, | ||
317 | 108 | 'crm_case_id': crm_case_id or 0, | ||
318 | 109 | 'explanation': explanations, | ||
319 | 110 | 'remark': remarks or '', | ||
320 | 111 | 'tb': tb, | ||
321 | 112 | }) | ||
322 | 113 | uo = urllib.urlopen('http://www.openerp.com/scripts/maintenance.php', args) | ||
323 | 114 | submit_result = uo.read() | ||
324 | 115 | debug(submit_result) | ||
325 | 116 | uo.close() | ||
326 | 117 | except: | ||
327 | 118 | if not crm_case_id: | ||
328 | 119 | # TODO schedule a retry (ir.cron) | ||
329 | 120 | return False | ||
330 | 121 | return True | ||
331 | 122 | |||
332 | 123 | def _valid_get(self, cr, uid, ids, field_name, arg, context=None): | ||
333 | 124 | res = {} | ||
334 | 125 | for contract in self.browse(cr, uid, ids, context=context): | ||
335 | 126 | res[contract.id] = ("unvalid", "valid")[contract.date_stop >= time.strftime('%Y-%m-%d')] | ||
336 | 127 | return res | ||
337 | 128 | |||
338 | 129 | _columns = { | ||
339 | 130 | 'name' : fields.char('Contract ID', size=256, required=True, readonly=True), | ||
340 | 131 | 'password' : fields.char('Password', size=64, invisible=True, required=True, readonly=True), | ||
341 | 132 | 'date_start' : fields.date('Starting Date', readonly=True), | ||
342 | 133 | 'date_stop' : fields.date('Ending Date', readonly=True), | ||
343 | 134 | 'module_ids' : fields.many2many('maintenance.contract.module', 'maintenance_contract_module_rel', 'contract_id', 'module_id', 'Covered Modules', readonly=True), | ||
344 | 135 | 'state' : fields.function(_valid_get, method=True, string="State", type="selection", selection=[('valid', 'Valid'),('unvalid', 'Unvalid')], readonly=True), | ||
345 | 136 | 'kind' : fields.selection([('full', 'Full'),('partial', 'Partial')], 'Kind', required=True, readonly=True), | ||
346 | 137 | } | ||
347 | 138 | _defaults = { | ||
348 | 139 | 'password' : lambda obj,cr,uid,context={} : '', | ||
349 | 140 | } | ||
350 | 141 | _sql_constraints = [ | ||
351 | 142 | ('uniq_name', 'unique(name)', "Your maintenance contract is already subscribed in the system !") | ||
352 | 143 | ] | ||
353 | 144 | |||
354 | 145 | maintenance_contract() | ||
355 | 146 | |||
356 | 147 | |||
357 | 148 | class maintenance_contract_wizard(osv.osv_memory): | ||
358 | 149 | _name = 'maintenance.contract.wizard' | ||
359 | 150 | |||
360 | 151 | _columns = { | ||
361 | 152 | 'name' : fields.char('Contract ID', size=256, required=True ), | ||
362 | 153 | 'password' : fields.char('Password', size=64, required=True), | ||
363 | 154 | 'state' : fields.selection([('draft', 'Draft'),('validated', 'Validated'),('unvalidated', 'Unvalidated')], 'States'), | ||
364 | 155 | } | ||
365 | 156 | |||
366 | 157 | _defaults = { | ||
367 | 158 | 'state' : lambda *a: 'draft', | ||
368 | 159 | } | ||
369 | 160 | |||
370 | 161 | def action_validate(self, cr, uid, ids, context=None): | ||
371 | 162 | if not ids: | ||
372 | 163 | return False | ||
373 | 164 | |||
374 | 165 | module_proxy = self.pool.get('ir.module.module') | ||
375 | 166 | module_ids = module_proxy.search(cr, uid, [('state', '=', 'installed')]) | ||
376 | 167 | modules = module_proxy.read(cr, uid, module_ids, ['name', 'installed_version']) | ||
377 | 168 | |||
378 | 169 | contract = self.read(cr, uid, ids, ['name', 'password'])[0] | ||
379 | 170 | |||
380 | 171 | try: | ||
381 | 172 | contract_info = tm.remote_contract(contract['name'], contract['password'], modules) | ||
382 | 173 | except tm.RemoteContractException, rce: | ||
383 | 174 | raise osv.except_osv(_('Error'), ustr(rce)) | ||
384 | 175 | |||
385 | 176 | is_ok = contract_info['status'] in ('partial', 'full') | ||
386 | 177 | if is_ok: | ||
387 | 178 | module_ids = [] | ||
388 | 179 | if contract_info['modules_with_contract']: | ||
389 | 180 | for name, version in contract_info['modules_with_contract']: | ||
390 | 181 | contract_module = self.pool.get('maintenance.contract.module') | ||
391 | 182 | res = contract_module.search(cr, uid, [('name', '=', name),('version', '=', version)]) | ||
392 | 183 | if not res: | ||
393 | 184 | id = contract_module.create(cr, uid, { 'name' : name, 'version' : version } ) | ||
394 | 185 | else: | ||
395 | 186 | id = res[0] | ||
396 | 187 | module_ids.append(id) | ||
397 | 188 | |||
398 | 189 | self.pool.get('maintenance.contract').create( | ||
399 | 190 | cr, | ||
400 | 191 | uid, { | ||
401 | 192 | 'name' : contract['name'], | ||
402 | 193 | 'password' : contract['password'], | ||
403 | 194 | 'date_start' : contract_info['date_from'], | ||
404 | 195 | 'date_stop' : contract_info['date_to'], | ||
405 | 196 | 'kind' : contract_info['status'], | ||
406 | 197 | 'module_ids' : [(6,0,module_ids)], | ||
407 | 198 | } | ||
408 | 199 | ) | ||
409 | 200 | |||
410 | 201 | return self.write(cr, uid, ids, {'state' : ('unvalidated', 'validated')[is_ok] }, context=context) | ||
411 | 202 | |||
412 | 203 | maintenance_contract_wizard() | ||
413 | 204 | |||
414 | 205 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
415 | 206 | |||
416 | 207 | 0 | ||
417 | === removed file 'bin/addons/base/maintenance/maintenance_security.xml' | |||
418 | --- bin/addons/base/maintenance/maintenance_security.xml 2010-06-12 16:21:33 +0000 | |||
419 | +++ bin/addons/base/maintenance/maintenance_security.xml 1970-01-01 00:00:00 +0000 | |||
420 | @@ -1,6 +0,0 @@ | |||
421 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
422 | 2 | <openerp> | ||
423 | 3 | <data noupdate="0"> | ||
424 | 4 | |||
425 | 5 | </data> | ||
426 | 6 | </openerp> | ||
427 | 7 | 0 | ||
428 | === removed file 'bin/addons/base/maintenance/maintenance_view.xml' | |||
429 | --- bin/addons/base/maintenance/maintenance_view.xml 2010-10-15 06:54:45 +0000 | |||
430 | +++ bin/addons/base/maintenance/maintenance_view.xml 1970-01-01 00:00:00 +0000 | |||
431 | @@ -1,131 +0,0 @@ | |||
432 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
433 | 2 | <openerp> | ||
434 | 3 | <data> | ||
435 | 4 | |||
436 | 5 | <record id="maintenance_contract_tree_view" model="ir.ui.view"> | ||
437 | 6 | <field name="name">maintenance.contract.tree</field> | ||
438 | 7 | <field name="model">maintenance.contract</field> | ||
439 | 8 | <field name="type">tree</field> | ||
440 | 9 | <field name="arch" type="xml"> | ||
441 | 10 | <tree string="Maintenance Contract"> | ||
442 | 11 | <field name="name"/> | ||
443 | 12 | <field name="date_start"/> | ||
444 | 13 | <field name="date_stop"/> | ||
445 | 14 | <field name="state" /> | ||
446 | 15 | </tree> | ||
447 | 16 | </field> | ||
448 | 17 | </record> | ||
449 | 18 | |||
450 | 19 | <record id="maintenance_contract_form_view" model="ir.ui.view"> | ||
451 | 20 | <field name="name">maintenance.contract.form</field> | ||
452 | 21 | <field name="model">maintenance.contract</field> | ||
453 | 22 | <field name="type">form</field> | ||
454 | 23 | <field name="arch" type="xml"> | ||
455 | 24 | <form string="Maintenance Contract"> | ||
456 | 25 | <group col="6" colspan="4"> | ||
457 | 26 | <field name="name"/> | ||
458 | 27 | <field name="date_start"/> | ||
459 | 28 | <field name="date_stop"/> | ||
460 | 29 | </group> | ||
461 | 30 | <separator string="Covered Modules" colspan="4"/> | ||
462 | 31 | <field name="module_ids" nolabel="1" colspan="4"> | ||
463 | 32 | <tree string="Covered Modules"> | ||
464 | 33 | <field name="name" /> | ||
465 | 34 | <field name="version" /> | ||
466 | 35 | </tree> | ||
467 | 36 | </field> | ||
468 | 37 | <field name="state" colspan="4"/> | ||
469 | 38 | </form> | ||
470 | 39 | </field> | ||
471 | 40 | </record> | ||
472 | 41 | |||
473 | 42 | <record id="maintenance_contract_search_view" model="ir.ui.view"> | ||
474 | 43 | <field name="name">maintenance.contract.search</field> | ||
475 | 44 | <field name="model">maintenance.contract</field> | ||
476 | 45 | <field name="type">search</field> | ||
477 | 46 | <field name="arch" type="xml"> | ||
478 | 47 | <search string="Maintenance Contract"> | ||
479 | 48 | <field name="name"/> | ||
480 | 49 | <field name="date_start"/> | ||
481 | 50 | <field name="date_stop"/> | ||
482 | 51 | </search> | ||
483 | 52 | </field> | ||
484 | 53 | </record> | ||
485 | 54 | |||
486 | 55 | <record id="maintenance_contract_view_calendar" model="ir.ui.view"> | ||
487 | 56 | <field name="name">maintenance.contract.calendar</field> | ||
488 | 57 | <field name="model">maintenance.contract</field> | ||
489 | 58 | <field name="type">calendar</field> | ||
490 | 59 | <field name="arch" type="xml"> | ||
491 | 60 | <calendar string="Maintenance Contract" date_start="date_start" color="state"> | ||
492 | 61 | <field name="name"/> | ||
493 | 62 | <field name="state"/> | ||
494 | 63 | </calendar> | ||
495 | 64 | </field> | ||
496 | 65 | </record> | ||
497 | 66 | |||
498 | 67 | <record id="action_maintenance_contract_form" model="ir.actions.act_window"> | ||
499 | 68 | <field name="name">Maintenance Contracts</field> | ||
500 | 69 | <field name="type">ir.actions.act_window</field> | ||
501 | 70 | <field name="res_model">maintenance.contract</field> | ||
502 | 71 | <field name="view_type">form</field> | ||
503 | 72 | <field name="view_mode">tree,form,calendar</field> | ||
504 | 73 | <field name="search_view_id" ref="maintenance_contract_search_view"/> | ||
505 | 74 | </record> | ||
506 | 75 | |||
507 | 76 | <menuitem | ||
508 | 77 | name="Maintenance" | ||
509 | 78 | id="maintenance" | ||
510 | 79 | parent="base.menu_administration" groups="base.group_extended"/> | ||
511 | 80 | |||
512 | 81 | <menuitem | ||
513 | 82 | action="action_maintenance_contract_form" | ||
514 | 83 | id="menu_maintenance_contract" | ||
515 | 84 | parent="maintenance"/> | ||
516 | 85 | |||
517 | 86 | <record id="maintenance_contract_add_wizard" model="ir.ui.view"> | ||
518 | 87 | <field name="name">maintenance.contract.add.wizard</field> | ||
519 | 88 | <field name="model">maintenance.contract.wizard</field> | ||
520 | 89 | <field name="type">form</field> | ||
521 | 90 | <field name="arch" type="xml"> | ||
522 | 91 | <form string="Add Maintenance Contract" col="2"> | ||
523 | 92 | <group col="1"> | ||
524 | 93 | <separator string="Add Maintenance Contract" /> | ||
525 | 94 | <group states="draft"> | ||
526 | 95 | <field name="name" width="250" /> | ||
527 | 96 | <newline /> | ||
528 | 97 | <field name="password" password="True" /> | ||
529 | 98 | <field name="state" invisible="1" /> | ||
530 | 99 | </group> | ||
531 | 100 | <group states="validated"> | ||
532 | 101 | <label string="Maintenance contract added !"/> | ||
533 | 102 | </group> | ||
534 | 103 | <group states="unvalidated"> | ||
535 | 104 | <label string="Could you check your contract information ?" /> | ||
536 | 105 | </group> | ||
537 | 106 | </group> | ||
538 | 107 | <group colspan="4"> | ||
539 | 108 | <button type="object" string="_Cancel" icon="gtk-cancel" special="cancel" states="draft"/> | ||
540 | 109 | <button type="object" string="_Validate" icon="gtk-apply" name="action_validate" states="draft"/> | ||
541 | 110 | <button type="object" string="_Close" icon="gtk-close" special="cancel" states="validated,unvalidated"/> | ||
542 | 111 | </group> | ||
543 | 112 | </form> | ||
544 | 113 | </field> | ||
545 | 114 | </record> | ||
546 | 115 | |||
547 | 116 | <record id="action_maintenance_contract_add_wizard" model="ir.actions.act_window"> | ||
548 | 117 | <field name="name">Add Maintenance Contract</field> | ||
549 | 118 | <field name="type">ir.actions.act_window</field> | ||
550 | 119 | <field name="res_model">maintenance.contract.wizard</field> | ||
551 | 120 | <field name="view_type">form</field> | ||
552 | 121 | <field name="view_mode">form</field> | ||
553 | 122 | <field name="target">new</field> | ||
554 | 123 | </record> | ||
555 | 124 | |||
556 | 125 | <menuitem | ||
557 | 126 | action="action_maintenance_contract_add_wizard" | ||
558 | 127 | id="menu_maintenance_contract_add" | ||
559 | 128 | parent="maintenance" /> | ||
560 | 129 | |||
561 | 130 | </data> | ||
562 | 131 | </openerp> | ||
563 | 132 | 0 | ||
564 | === added directory 'bin/addons/base/publisher_warranty' | |||
565 | === added file 'bin/addons/base/publisher_warranty/__init__.py' | |||
566 | --- bin/addons/base/publisher_warranty/__init__.py 1970-01-01 00:00:00 +0000 | |||
567 | +++ bin/addons/base/publisher_warranty/__init__.py 2010-12-08 16:09:30 +0000 | |||
568 | @@ -0,0 +1,25 @@ | |||
569 | 1 | # -*- coding: utf-8 -*- | ||
570 | 2 | ############################################################################## | ||
571 | 3 | # | ||
572 | 4 | # OpenERP, Open Source Management Solution | ||
573 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
574 | 6 | # | ||
575 | 7 | # This program is free software: you can redistribute it and/or modify | ||
576 | 8 | # it under the terms of the GNU Affero General Public License as | ||
577 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
578 | 10 | # License, or (at your option) any later version. | ||
579 | 11 | # | ||
580 | 12 | # This program is distributed in the hope that it will be useful, | ||
581 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
582 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
583 | 15 | # GNU Affero General Public License for more details. | ||
584 | 16 | # | ||
585 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
586 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
587 | 19 | # | ||
588 | 20 | ############################################################################## | ||
589 | 21 | |||
590 | 22 | import publisher_warranty | ||
591 | 23 | |||
592 | 24 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
593 | 25 | |||
594 | 0 | 26 | ||
595 | === added file 'bin/addons/base/publisher_warranty/publisher_warranty.py' | |||
596 | --- bin/addons/base/publisher_warranty/publisher_warranty.py 1970-01-01 00:00:00 +0000 | |||
597 | +++ bin/addons/base/publisher_warranty/publisher_warranty.py 2010-12-08 16:09:30 +0000 | |||
598 | @@ -0,0 +1,320 @@ | |||
599 | 1 | # -*- coding: utf-8 -*- | ||
600 | 2 | ############################################################################## | ||
601 | 3 | # | ||
602 | 4 | # OpenERP, Open Source Management Solution | ||
603 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
604 | 6 | # | ||
605 | 7 | # This program is free software: you can redistribute it and/or modify | ||
606 | 8 | # it under the terms of the GNU Affero General Public License as | ||
607 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
608 | 10 | # License, or (at your option) any later version. | ||
609 | 11 | # | ||
610 | 12 | # This program is distributed in the hope that it will be useful, | ||
611 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
612 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
613 | 15 | # GNU Affero General Public License for more details. | ||
614 | 16 | # | ||
615 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
616 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
617 | 19 | # | ||
618 | 20 | ############################################################################## | ||
619 | 21 | """ | ||
620 | 22 | Module to handle publisher warranty contracts as well as notifications from | ||
621 | 23 | OpenERP. | ||
622 | 24 | """ | ||
623 | 25 | |||
624 | 26 | from osv import osv, fields | ||
625 | 27 | import logging | ||
626 | 28 | from tools.translate import _ | ||
627 | 29 | import urllib | ||
628 | 30 | import urllib2 | ||
629 | 31 | from tools.safe_eval import safe_eval | ||
630 | 32 | import pooler | ||
631 | 33 | from tools.config import config | ||
632 | 34 | import release | ||
633 | 35 | import datetime | ||
634 | 36 | from tools import misc | ||
635 | 37 | import sys | ||
636 | 38 | |||
637 | 39 | _logger = logging.getLogger(__name__) | ||
638 | 40 | |||
639 | 41 | """ | ||
640 | 42 | Time interval that will be used to determine up to which date we will | ||
641 | 43 | check the logs to see if a message we just received was already logged. | ||
642 | 44 | @type: datetime.timedelta | ||
643 | 45 | """ | ||
644 | 46 | _PREVIOUS_LOG_CHECK = datetime.timedelta(days=365) | ||
645 | 47 | |||
646 | 48 | class publisher_warranty_contract(osv.osv): | ||
647 | 49 | """ | ||
648 | 50 | Osv representing a publisher warranty contract. | ||
649 | 51 | """ | ||
650 | 52 | _name = "publisher_warranty.contract" | ||
651 | 53 | |||
652 | 54 | def _get_valid_contracts(self, cr, uid): | ||
653 | 55 | """ | ||
654 | 56 | Return the list of the valid contracts encoded in the system. | ||
655 | 57 | |||
656 | 58 | @return: A list of contracts | ||
657 | 59 | @rtype: list of publisher_warranty.contract browse records | ||
658 | 60 | """ | ||
659 | 61 | return [contract for contract in self.browse(cr, uid, self.search(cr, uid, [])) | ||
660 | 62 | if contract.state == 'valid'] | ||
661 | 63 | |||
662 | 64 | def status(self, cr, uid): | ||
663 | 65 | """ Method called by the client to check availability of publisher warranty contract. """ | ||
664 | 66 | |||
665 | 67 | contracts = self._get_valid_contracts(cr, uid) | ||
666 | 68 | return { | ||
667 | 69 | 'status': "full" if contracts else "none" , | ||
668 | 70 | 'uncovered_modules': list(), | ||
669 | 71 | } | ||
670 | 72 | |||
671 | 73 | def send(self, cr, uid, tb, explanations, remarks=None): | ||
672 | 74 | """ Method called by the client to send a problem to the publisher warranty server. """ | ||
673 | 75 | |||
674 | 76 | if not remarks: | ||
675 | 77 | remarks = "" | ||
676 | 78 | |||
677 | 79 | valid_contracts = self._get_valid_contracts(cr, uid) | ||
678 | 80 | valid_contract = valid_contracts[0] | ||
679 | 81 | |||
680 | 82 | try: | ||
681 | 83 | origin = 'client' | ||
682 | 84 | dbuuid = self.pool.get('ir.config_parameter').get_param(cr, uid, 'database.uuid') | ||
683 | 85 | db_create_date = self.pool.get('ir.config_parameter').get_param(cr, uid, 'database.create_date') | ||
684 | 86 | |||
685 | 87 | msg = {'contract_name': valid_contract.name, | ||
686 | 88 | 'tb': tb, | ||
687 | 89 | 'explanations': explanations, | ||
688 | 90 | 'remarks': remarks, | ||
689 | 91 | 'origin': origin, | ||
690 | 92 | 'dbname': cr.dbname, | ||
691 | 93 | 'dbuuid': dbuuid, | ||
692 | 94 | 'db_create_date': db_create_date} | ||
693 | 95 | |||
694 | 96 | |||
695 | 97 | add_arg = {"timeout":30} if sys.version_info >= (2,6) else {} | ||
696 | 98 | uo = urllib2.urlopen(config.get("publisher_warranty_url"), | ||
697 | 99 | urllib.urlencode({'arg0': msg, "action": "send",}),**add_arg) | ||
698 | 100 | try: | ||
699 | 101 | submit_result = uo.read() | ||
700 | 102 | finally: | ||
701 | 103 | uo.close() | ||
702 | 104 | |||
703 | 105 | result = safe_eval(submit_result) | ||
704 | 106 | |||
705 | 107 | crm_case_id = result | ||
706 | 108 | |||
707 | 109 | if not crm_case_id: | ||
708 | 110 | return False | ||
709 | 111 | |||
710 | 112 | except osv.except_osv: | ||
711 | 113 | raise | ||
712 | 114 | except: | ||
713 | 115 | _logger.warning("Error sending problem report", exc_info=1) | ||
714 | 116 | raise osv.except_osv("Connection error", "An error occured during the connection " + | ||
715 | 117 | "with the publisher warranty server.") | ||
716 | 118 | |||
717 | 119 | return True | ||
718 | 120 | |||
719 | 121 | def check_validity(self, cr, uid, ids, context={}): | ||
720 | 122 | """ | ||
721 | 123 | Check the validity of a publisher warranty contract. This method just call get_logs() but checks | ||
722 | 124 | some more things, so it can be called from a user interface. | ||
723 | 125 | """ | ||
724 | 126 | contract_id = ids[0] | ||
725 | 127 | contract = self.browse(cr, uid, contract_id) | ||
726 | 128 | state = contract.state | ||
727 | 129 | validated = state != "unvalidated" | ||
728 | 130 | |||
729 | 131 | self.get_logs(cr, uid, ids, cron_mode=False, context=context) | ||
730 | 132 | |||
731 | 133 | contract = self.browse(cr, uid, contract_id) | ||
732 | 134 | validated2 = contract.state != "unvalidated" | ||
733 | 135 | if not validated and not validated2: | ||
734 | 136 | raise osv.except_osv(_("Contract validation error"), | ||
735 | 137 | _("Please check your publisher warranty contract name and validity.")) | ||
736 | 138 | |||
737 | 139 | def get_logs(self, cr, uid, ids, cron_mode=True, context={}): | ||
738 | 140 | """ | ||
739 | 141 | Send a message to OpenERP's publisher warranty server to check the validity of | ||
740 | 142 | the contracts, get notifications, etc... | ||
741 | 143 | |||
742 | 144 | @param cron_mode: If true, catch all exceptions (appropriate for usage in a cron). | ||
743 | 145 | @type cron_mode: boolean | ||
744 | 146 | """ | ||
745 | 147 | try: | ||
746 | 148 | try: | ||
747 | 149 | result = get_sys_logs(cr, uid) | ||
748 | 150 | except: | ||
749 | 151 | _logger.debug("Exception while sending a get logs messages", exc_info=1) | ||
750 | 152 | raise osv.except_osv(_("Error"), _("Error during communication with the publisher warranty server.")) | ||
751 | 153 | |||
752 | 154 | contracts = result["contracts"] | ||
753 | 155 | for contract in contracts: | ||
754 | 156 | c_id = self.search(cr, uid, [("name","=",contract)])[0] | ||
755 | 157 | date_from = contracts[contract][0] | ||
756 | 158 | date_to = contracts[contract][1] | ||
757 | 159 | state = contracts[contract][2] | ||
758 | 160 | self.write(cr, uid, c_id, { | ||
759 | 161 | "date_start": date_from, | ||
760 | 162 | "date_stop": date_to, | ||
761 | 163 | "state": state, | ||
762 | 164 | }) | ||
763 | 165 | |||
764 | 166 | limit_date = (datetime.datetime.now() - _PREVIOUS_LOG_CHECK).strftime(misc.DEFAULT_SERVER_DATETIME_FORMAT) | ||
765 | 167 | for message in result["messages"]: | ||
766 | 168 | ids = self.pool.get("res.log").search(cr, uid, [("res_model", "=", "publisher_warranty.contract"), | ||
767 | 169 | ("create_date", ">=", limit_date), | ||
768 | 170 | ("name", "=", message)]) | ||
769 | 171 | if ids: | ||
770 | 172 | continue | ||
771 | 173 | self.pool.get('res.log').create(cr, uid, | ||
772 | 174 | { | ||
773 | 175 | 'name': message, | ||
774 | 176 | 'res_model': "publisher_warranty.contract", | ||
775 | 177 | "read": True, | ||
776 | 178 | "user_id": False, | ||
777 | 179 | }, | ||
778 | 180 | context=context | ||
779 | 181 | ) | ||
780 | 182 | except: | ||
781 | 183 | if cron_mode: | ||
782 | 184 | return False # we don't want to see any stack trace in cron | ||
783 | 185 | else: | ||
784 | 186 | raise | ||
785 | 187 | return True | ||
786 | 188 | |||
787 | 189 | def get_last_user_messages(self, cr, uid, limit, context={}): | ||
788 | 190 | """ | ||
789 | 191 | Get the messages to be written in the web client. | ||
790 | 192 | @return: A list of html messages with ids, can be False or empty. | ||
791 | 193 | @rtype: list of tuples(int,string) | ||
792 | 194 | """ | ||
793 | 195 | ids = self.pool.get('res.log').search(cr, uid, [("res_model", "=", "publisher_warranty.contract")] | ||
794 | 196 | , order="create_date desc", limit=limit) | ||
795 | 197 | if not ids: | ||
796 | 198 | return [] | ||
797 | 199 | messages = [(x.id, x.name) for x in self.pool.get('res.log').browse(cr, uid, ids)] | ||
798 | 200 | |||
799 | 201 | return messages | ||
800 | 202 | |||
801 | 203 | def del_user_message(self, cr, uid, id, context={}): | ||
802 | 204 | """ | ||
803 | 205 | Delete a message. | ||
804 | 206 | """ | ||
805 | 207 | self.pool.get('res.log').unlink(cr, uid, [id]) | ||
806 | 208 | |||
807 | 209 | return True | ||
808 | 210 | |||
809 | 211 | _columns = { | ||
810 | 212 | 'name' : fields.char('Serial Key', size=384, required=True), | ||
811 | 213 | 'date_start' : fields.date('Starting Date', readonly=True), | ||
812 | 214 | 'date_stop' : fields.date('Ending Date', readonly=True), | ||
813 | 215 | 'state' : fields.selection([('unvalidated', 'Unvalidated'), ('valid', 'Valid') | ||
814 | 216 | , ('terminated', 'Terminated'), ('canceled', 'Canceled')], string="State", readonly=True), | ||
815 | 217 | 'kind' : fields.char('Kind', size=64, readonly=True), | ||
816 | 218 | } | ||
817 | 219 | |||
818 | 220 | _defaults = { | ||
819 | 221 | 'state': 'unvalidated', | ||
820 | 222 | } | ||
821 | 223 | |||
822 | 224 | _sql_constraints = [ | ||
823 | 225 | ('uniq_name', 'unique(name)', "Your publisher warranty contract is already subscribed in the system !") | ||
824 | 226 | ] | ||
825 | 227 | |||
826 | 228 | publisher_warranty_contract() | ||
827 | 229 | |||
828 | 230 | class maintenance_contract(osv.osv_memory): | ||
829 | 231 | """ Old osv we only keep for compatibility with the clients. """ | ||
830 | 232 | |||
831 | 233 | _name = "maintenance.contract" | ||
832 | 234 | |||
833 | 235 | def status(self, cr, uid): | ||
834 | 236 | return self.pool.get("publisher_warranty.contract").status(cr, uid) | ||
835 | 237 | |||
836 | 238 | def send(self, cr, uid, tb, explanations, remarks=None): | ||
837 | 239 | return self.pool.get("publisher_warranty.contract").send(cr, uid, tb, explanations, remarks) | ||
838 | 240 | |||
839 | 241 | maintenance_contract() | ||
840 | 242 | |||
841 | 243 | class publisher_warranty_contract_wizard(osv.osv_memory): | ||
842 | 244 | """ | ||
843 | 245 | A wizard osv to help people entering a publisher warranty contract. | ||
844 | 246 | """ | ||
845 | 247 | _name = 'publisher_warranty.contract.wizard' | ||
846 | 248 | _inherit = "ir.wizard.screen" | ||
847 | 249 | |||
848 | 250 | _columns = { | ||
849 | 251 | 'name' : fields.char('Serial Key', size=256, required=True ), | ||
850 | 252 | 'state' : fields.selection([("draft", "Draft"), ("finished", "Finished")]) | ||
851 | 253 | } | ||
852 | 254 | |||
853 | 255 | _defaults = { | ||
854 | 256 | "state": "draft", | ||
855 | 257 | } | ||
856 | 258 | |||
857 | 259 | def action_validate(self, cr, uid, ids, context=None): | ||
858 | 260 | if not ids: | ||
859 | 261 | return False | ||
860 | 262 | |||
861 | 263 | wiz = self.browse(cr, uid, ids[0]) | ||
862 | 264 | c_name = wiz.name | ||
863 | 265 | |||
864 | 266 | contract_osv = self.pool.get("publisher_warranty.contract") | ||
865 | 267 | contracts = contract_osv.search(cr, uid, [("name","=",c_name)]) | ||
866 | 268 | if contracts: | ||
867 | 269 | raise osv.except_osv(_("Error"), _("That contract is already registered in the system.")) | ||
868 | 270 | |||
869 | 271 | contract_id = contract_osv.create(cr, uid, { | ||
870 | 272 | "name": c_name, | ||
871 | 273 | "state": "unvalidated", | ||
872 | 274 | }) | ||
873 | 275 | |||
874 | 276 | contract_osv.check_validity(cr, uid, [contract_id]) | ||
875 | 277 | |||
876 | 278 | self.write(cr, uid, ids, {"state": "finished"}) | ||
877 | 279 | |||
878 | 280 | return True | ||
879 | 281 | |||
880 | 282 | |||
881 | 283 | publisher_warranty_contract_wizard() | ||
882 | 284 | |||
883 | 285 | def get_sys_logs(cr, uid): | ||
884 | 286 | """ | ||
885 | 287 | Utility method to send a publisher warranty get logs messages. | ||
886 | 288 | """ | ||
887 | 289 | pool = pooler.get_pool(cr.dbname) | ||
888 | 290 | |||
889 | 291 | dbuuid = pool.get('ir.config_parameter').get_param(cr, uid, 'database.uuid') | ||
890 | 292 | db_create_date = pool.get('ir.config_parameter').get_param(cr, uid, 'database.create_date') | ||
891 | 293 | nbr_users = pool.get("res.users").search(cr, uid, [], count=True) | ||
892 | 294 | contractosv = pool.get('publisher_warranty.contract') | ||
893 | 295 | contracts = contractosv.browse(cr, uid, contractosv.search(cr, uid, [])) | ||
894 | 296 | user = pool.get("res.users").browse(cr, uid, uid) | ||
895 | 297 | msg = { | ||
896 | 298 | "dbuuid": dbuuid, | ||
897 | 299 | "nbr_users": nbr_users, | ||
898 | 300 | "dbname": cr.dbname, | ||
899 | 301 | "db_create_date": db_create_date, | ||
900 | 302 | "version": release.version, | ||
901 | 303 | "contracts": [c.name for c in contracts], | ||
902 | 304 | "language": user.context_lang, | ||
903 | 305 | } | ||
904 | 306 | |||
905 | 307 | add_arg = {"timeout":30} if sys.version_info >= (2,6) else {} | ||
906 | 308 | uo = urllib2.urlopen(config.get("publisher_warranty_url"), | ||
907 | 309 | urllib.urlencode({'arg0': msg, "action": "update",}), **add_arg) | ||
908 | 310 | try: | ||
909 | 311 | submit_result = uo.read() | ||
910 | 312 | finally: | ||
911 | 313 | uo.close() | ||
912 | 314 | |||
913 | 315 | result = safe_eval(submit_result) | ||
914 | 316 | |||
915 | 317 | return result | ||
916 | 318 | |||
917 | 319 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
918 | 320 | |||
919 | 0 | 321 | ||
920 | === added file 'bin/addons/base/publisher_warranty/publisher_warranty_data.xml' | |||
921 | --- bin/addons/base/publisher_warranty/publisher_warranty_data.xml 1970-01-01 00:00:00 +0000 | |||
922 | +++ bin/addons/base/publisher_warranty/publisher_warranty_data.xml 2010-12-08 16:09:30 +0000 | |||
923 | @@ -0,0 +1,20 @@ | |||
924 | 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
925 | 2 | <openerp> | ||
926 | 3 | <data> | ||
927 | 4 | |||
928 | 5 | <record id="ir_cron_ping_scheduler" model="ir.cron"> | ||
929 | 6 | <field name="name">Update System Logs</field> | ||
930 | 7 | <field eval="True" name="active" /> | ||
931 | 8 | <field name="user_id" ref="base.user_root" /> | ||
932 | 9 | <field name="interval_number">1</field> | ||
933 | 10 | <field name="interval_type">weeks</field> | ||
934 | 11 | <field name="numbercall">-1</field> | ||
935 | 12 | <field eval="False" name="doall" /> | ||
936 | 13 | <field eval="'publisher_warranty.contract'" name="model" /> | ||
937 | 14 | <field eval="'get_logs'" name="function" /> | ||
938 | 15 | <field eval="'(None,)'" name="args" /> | ||
939 | 16 | <field name="priority">1000</field> | ||
940 | 17 | </record> | ||
941 | 18 | |||
942 | 19 | </data> | ||
943 | 20 | </openerp> | ||
944 | 0 | \ No newline at end of file | 21 | \ No newline at end of file |
945 | 1 | 22 | ||
946 | === added file 'bin/addons/base/publisher_warranty/publisher_warranty_view.xml' | |||
947 | --- bin/addons/base/publisher_warranty/publisher_warranty_view.xml 1970-01-01 00:00:00 +0000 | |||
948 | +++ bin/addons/base/publisher_warranty/publisher_warranty_view.xml 2010-12-08 16:09:30 +0000 | |||
949 | @@ -0,0 +1,146 @@ | |||
950 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
951 | 2 | <openerp> | ||
952 | 3 | <data> | ||
953 | 4 | |||
954 | 5 | <record id="publisher_warranty_contract_tree_view" model="ir.ui.view"> | ||
955 | 6 | <field name="name">publisher_warranty.contract.tree</field> | ||
956 | 7 | <field name="model">publisher_warranty.contract</field> | ||
957 | 8 | <field name="type">tree</field> | ||
958 | 9 | <field name="arch" type="xml"> | ||
959 | 10 | <tree string="Publisher Warranty Contracts"> | ||
960 | 11 | <field name="name"/> | ||
961 | 12 | <field name="date_start"/> | ||
962 | 13 | <field name="date_stop"/> | ||
963 | 14 | <field name="state" /> | ||
964 | 15 | </tree> | ||
965 | 16 | </field> | ||
966 | 17 | </record> | ||
967 | 18 | |||
968 | 19 | <record id="publisher_warranty_contract_form_view" model="ir.ui.view"> | ||
969 | 20 | <field name="name">publisher_warranty.contract.form</field> | ||
970 | 21 | <field name="model">publisher_warranty.contract</field> | ||
971 | 22 | <field name="type">form</field> | ||
972 | 23 | <field name="arch" type="xml"> | ||
973 | 24 | <form string="Publisher Warranty Contract"> | ||
974 | 25 | <group col="2" colspan="4"> | ||
975 | 26 | <group col="2"> | ||
976 | 27 | <field name="name"/> | ||
977 | 28 | </group> | ||
978 | 29 | <group col="2"> | ||
979 | 30 | <field name="date_start"/> | ||
980 | 31 | <field name="date_stop"/> | ||
981 | 32 | </group> | ||
982 | 33 | <group col="2"> | ||
983 | 34 | <field name="state"/> | ||
984 | 35 | <field name="kind"/> | ||
985 | 36 | </group> | ||
986 | 37 | <group col="2"> | ||
987 | 38 | <button name="check_validity" string="Validate" type="object" | ||
988 | 39 | attrs="{'invisible':[('state','in',['valid', 'terminated', 'canceled'])]}"/> | ||
989 | 40 | <button name="check_validity" string="Refresh Validation Dates" type="object" | ||
990 | 41 | attrs="{'invisible':[('state','in',['unvalidated'])]}"/> | ||
991 | 42 | </group> | ||
992 | 43 | </group> | ||
993 | 44 | </form> | ||
994 | 45 | </field> | ||
995 | 46 | </record> | ||
996 | 47 | |||
997 | 48 | <record id="publisher_warranty_contract_search_view" model="ir.ui.view"> | ||
998 | 49 | <field name="name">publisher_warranty.contract.search</field> | ||
999 | 50 | <field name="model">publisher_warranty.contract</field> | ||
1000 | 51 | <field name="type">search</field> | ||
1001 | 52 | <field name="arch" type="xml"> | ||
1002 | 53 | <search string="Publisher Warranty Contract"> | ||
1003 | 54 | <field name="name"/> | ||
1004 | 55 | <field name="date_start"/> | ||
1005 | 56 | <field name="date_stop"/> | ||
1006 | 57 | </search> | ||
1007 | 58 | </field> | ||
1008 | 59 | </record> | ||
1009 | 60 | |||
1010 | 61 | <record id="publisher_warranty_contract_view_calendar" model="ir.ui.view"> | ||
1011 | 62 | <field name="name">publisher_warranty.contract.calendar</field> | ||
1012 | 63 | <field name="model">publisher_warranty.contract</field> | ||
1013 | 64 | <field name="type">calendar</field> | ||
1014 | 65 | <field name="arch" type="xml"> | ||
1015 | 66 | <calendar string="Maintenance Contract" date_start="date_start" color="state"> | ||
1016 | 67 | <field name="name"/> | ||
1017 | 68 | <field name="state"/> | ||
1018 | 69 | </calendar> | ||
1019 | 70 | </field> | ||
1020 | 71 | </record> | ||
1021 | 72 | |||
1022 | 73 | <record id="action_publisher_warranty_contract_form" model="ir.actions.act_window"> | ||
1023 | 74 | <field name="name">Contracts</field> | ||
1024 | 75 | <field name="type">ir.actions.act_window</field> | ||
1025 | 76 | <field name="res_model">publisher_warranty.contract</field> | ||
1026 | 77 | <field name="view_type">form</field> | ||
1027 | 78 | <field name="view_mode">tree,form,calendar</field> | ||
1028 | 79 | <field name="search_view_id" ref="publisher_warranty_contract_search_view"/> | ||
1029 | 80 | </record> | ||
1030 | 81 | |||
1031 | 82 | <menuitem name="Publisher Warranty" id="publisher_warranty" | ||
1032 | 83 | parent="base.menu_administration" groups="base.group_extended"/> | ||
1033 | 84 | |||
1034 | 85 | <menuitem action="action_publisher_warranty_contract_form" id="menu_publisher_warranty_contract" | ||
1035 | 86 | parent="publisher_warranty" sequence="2"/> | ||
1036 | 87 | |||
1037 | 88 | |||
1038 | 89 | <record id="publisher_warranty_contract_add_wizard" model="ir.ui.view"> | ||
1039 | 90 | <field name="name">publisher_warranty.contract.add.wizard</field> | ||
1040 | 91 | <field name="model">publisher_warranty.contract.wizard</field> | ||
1041 | 92 | <field name="type">form</field> | ||
1042 | 93 | <field name="arch" type="xml"> | ||
1043 | 94 | <form string="Register a Contract"> | ||
1044 | 95 | <group col="8"> | ||
1045 | 96 | <group colspan="3" col="1"> | ||
1046 | 97 | <field name="config_logo" widget="image" width="220" height="130" nolabel="1" colspan="1"/> | ||
1047 | 98 | <newline/> | ||
1048 | 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."/> | ||
1049 | 100 | <label width="220"/> | ||
1050 | 101 | <label width="220" string=""/> | ||
1051 | 102 | <field name="state" invisible="1"/> | ||
1052 | 103 | </group> | ||
1053 | 104 | <separator orientation="vertical" rowspan="5"/> | ||
1054 | 105 | <group colspan="4"> | ||
1055 | 106 | <separator string="Register a Contract" colspan="4"/> | ||
1056 | 107 | <group states="draft" col="4"> | ||
1057 | 108 | <label string="Please enter the serial key provided in your contract document:" colspan="4"/> | ||
1058 | 109 | <field name="name" colspan="4"/> | ||
1059 | 110 | </group> | ||
1060 | 111 | <group states="finished" col="4"> | ||
1061 | 112 | <label string="Publisher warranty contract successfully registered!" colspan="4"/> | ||
1062 | 113 | </group> | ||
1063 | 114 | </group> | ||
1064 | 115 | <group colspan="8" col="8" states="draft"> | ||
1065 | 116 | <separator string="" colspan="8"/> | ||
1066 | 117 | <label colspan="6" width="220"/> | ||
1067 | 118 | <button special="cancel" string="Cancel" icon="gtk-cancel"/> | ||
1068 | 119 | <button name="action_validate" string="Register" type="object" icon="gtk-apply"/> | ||
1069 | 120 | </group> | ||
1070 | 121 | <group colspan="8" col="8" states="finished"> | ||
1071 | 122 | <separator string="" colspan="8"/> | ||
1072 | 123 | <label colspan="6" width="220"/> | ||
1073 | 124 | <button special="cancel" string="Close" icon="gtk-ok"/> | ||
1074 | 125 | </group> | ||
1075 | 126 | </group> | ||
1076 | 127 | </form> | ||
1077 | 128 | </field> | ||
1078 | 129 | </record> | ||
1079 | 130 | |||
1080 | 131 | <record id="action_publisher_warranty_contract_add_wizard" model="ir.actions.act_window"> | ||
1081 | 132 | <field name="name">Register a Contract</field> | ||
1082 | 133 | <field name="type">ir.actions.act_window</field> | ||
1083 | 134 | <field name="res_model">publisher_warranty.contract.wizard</field> | ||
1084 | 135 | <field name="view_type">form</field> | ||
1085 | 136 | <field name="view_mode">form</field> | ||
1086 | 137 | <field name="target">new</field> | ||
1087 | 138 | </record> | ||
1088 | 139 | |||
1089 | 140 | <menuitem | ||
1090 | 141 | action="action_publisher_warranty_contract_add_wizard" | ||
1091 | 142 | id="menu_publisher_warranty_contract_add" | ||
1092 | 143 | parent="publisher_warranty" sequence="1"/> | ||
1093 | 144 | |||
1094 | 145 | </data> | ||
1095 | 146 | </openerp> | ||
1096 | 0 | 147 | ||
1097 | === modified file 'bin/addons/base/res/res_log.py' | |||
1098 | --- bin/addons/base/res/res_log.py 2010-11-23 16:05:06 +0000 | |||
1099 | +++ bin/addons/base/res/res_log.py 2010-12-08 16:09:30 +0000 | |||
1100 | @@ -20,24 +20,23 @@ | |||
1101 | 20 | ############################################################################## | 20 | ############################################################################## |
1102 | 21 | 21 | ||
1103 | 22 | from osv import fields, osv | 22 | from osv import fields, osv |
1104 | 23 | import tools | ||
1105 | 24 | 23 | ||
1106 | 25 | class res_log(osv.osv): | 24 | class res_log(osv.osv): |
1107 | 26 | _name = 'res.log' | 25 | _name = 'res.log' |
1108 | 27 | _columns = { | 26 | _columns = { |
1112 | 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), |
1113 | 29 | 'user_id': fields.many2one('res.users','User', required=True), | 28 | 'user_id': fields.many2one('res.users','User'), |
1114 | 30 | 'res_model': fields.char('Object', size=128), | 29 | 'res_model': fields.char('Object', size=128, select=1), |
1115 | 31 | 'context': fields.char('Context', size=250), | 30 | 'context': fields.char('Context', size=250), |
1116 | 32 | 'res_id': fields.integer('Object ID'), | 31 | 'res_id': fields.integer('Object ID'), |
1117 | 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'), |
1120 | 34 | 'create_date': fields.datetime('Created Date', readonly=True), | 33 | 'create_date': fields.datetime('Created Date', readonly=True, select=1), |
1121 | 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"), |
1122 | 36 | } | 35 | } |
1123 | 37 | _defaults = { | 36 | _defaults = { |
1124 | 38 | 'user_id': lambda self,cr,uid,ctx: uid, | 37 | 'user_id': lambda self,cr,uid,ctx: uid, |
1125 | 39 | 'context': "{}", | 38 | 'context': "{}", |
1127 | 40 | 'read': False | 39 | 'read': False, |
1128 | 41 | } | 40 | } |
1129 | 42 | _order='create_date desc' | 41 | _order='create_date desc' |
1130 | 43 | 42 | ||
1131 | 44 | 43 | ||
1132 | === modified file 'bin/addons/base/res/res_log_view.xml' | |||
1133 | --- bin/addons/base/res/res_log_view.xml 2010-10-17 21:47:55 +0000 | |||
1134 | +++ bin/addons/base/res/res_log_view.xml 2010-12-08 16:09:30 +0000 | |||
1135 | @@ -11,6 +11,8 @@ | |||
1136 | 11 | <filter icon="terp-stock_align_left_24" string="Unread" domain="[('read','<>',True)]" name="unread"/> | 11 | <filter icon="terp-stock_align_left_24" string="Unread" domain="[('read','<>',True)]" name="unread"/> |
1137 | 12 | <separator orientation="vertical"/> | 12 | <separator orientation="vertical"/> |
1138 | 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"/> |
1139 | 14 | <filter icon="terp-stock_align_left_24" string="System Logs" | ||
1140 | 15 | domain="[('res_model','=','publisher_warranty.contract')]" name="sys"/> | ||
1141 | 14 | <separator orientation="vertical"/> | 16 | <separator orientation="vertical"/> |
1142 | 15 | <field name="name"/> | 17 | <field name="name"/> |
1143 | 16 | <field name="user_id"/> | 18 | <field name="user_id"/> |
1144 | 17 | 19 | ||
1145 | === modified file 'bin/addons/base/security/ir.model.access.csv' | |||
1146 | --- bin/addons/base/security/ir.model.access.csv 2010-10-17 21:30:11 +0000 | |||
1147 | +++ bin/addons/base/security/ir.model.access.csv 2010-12-08 16:09:30 +0000 | |||
1148 | @@ -112,8 +112,8 @@ | |||
1149 | 112 | "access_res_payterm_group_system","res_payterm_group_system","model_res_payterm","group_system",1,1,1,1 | 112 | "access_res_payterm_group_system","res_payterm_group_system","model_res_payterm","group_system",1,1,1,1 |
1150 | 113 | "access_res_bank_group_partner_manager","res_bank_group_partner_manager","model_res_bank","group_partner_manager",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,1 |
1151 | 114 | "access_res_bank_user","res_bank user","model_res_bank","group_user",1,0,0,0 | 114 | "access_res_bank_user","res_bank user","model_res_bank","group_user",1,0,0,0 |
1154 | 115 | "access_maintenance_group_user","maintenance_contract group_user","model_maintenance_contract","group_system",1,1,1,1 | 115 | "access_publisher_warranty_group_user","publisher_warranty_contract group_user","model_publisher_warranty_contract","group_system",1,1,1,1 |
1155 | 116 | "access_maintenance_contract_module","maintenance.contract.module","model_maintenance_contract_module","group_system",1,1,1,1 | 116 | "access_publisher_warranty_all","publisher_warranty_contract all","model_publisher_warranty_contract",,1,0,0,0 |
1156 | 117 | "access_multi_company_default user","multi_company_default all","model_multi_company_default",,1,0,0,0 | 117 | "access_multi_company_default user","multi_company_default all","model_multi_company_default",,1,0,0,0 |
1157 | 118 | "access_multi_company_default manager","multi_company_default Manager","model_multi_company_default","group_erp_manager",1,1,1,1 | 118 | "access_multi_company_default manager","multi_company_default Manager","model_multi_company_default","group_erp_manager",1,1,1,1 |
1158 | 119 | "access_ir_filter all","ir_filters all","model_ir_filters",,1,0,0,0 | 119 | "access_ir_filter all","ir_filters all","model_ir_filters",,1,0,0,0 |
1159 | @@ -123,3 +123,4 @@ | |||
1160 | 123 | "access_res_widget","res.widget","model_res_widget","group_erp_manager",1,1,1,1 | 123 | "access_res_widget","res.widget","model_res_widget","group_erp_manager",1,1,1,1 |
1161 | 124 | "access_res_widget_user","res.widget.user","model_res_widget",,1,0,0,0 | 124 | "access_res_widget_user","res.widget.user","model_res_widget",,1,0,0,0 |
1162 | 125 | "access_res_log_all","res.log","model_res_log",,1,1,1,1 | 125 | "access_res_log_all","res.log","model_res_log",,1,1,1,1 |
1163 | 126 | "access_ir_config_parameter","ir_config_parameter","model_ir_config_parameter",,1,0,0,0 | ||
1164 | 126 | 127 | ||
1165 | === modified file 'bin/netsvc.py' | |||
1166 | --- bin/netsvc.py 2010-11-26 13:02:25 +0000 | |||
1167 | +++ bin/netsvc.py 2010-12-08 16:09:30 +0000 | |||
1168 | @@ -490,6 +490,7 @@ | |||
1169 | 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)) |
1170 | 491 | return result | 491 | return result |
1171 | 492 | except Exception, e: | 492 | except Exception, e: |
1172 | 493 | logging.getLogger(__name__).exception("Dispatcher error") | ||
1173 | 493 | self.log('exception', tools.exception_to_unicode(e)) | 494 | self.log('exception', tools.exception_to_unicode(e)) |
1174 | 494 | tb = getattr(e, 'traceback', sys.exc_info()) | 495 | tb = getattr(e, 'traceback', sys.exc_info()) |
1175 | 495 | tb_s = "".join(traceback.format_exception(*tb)) | 496 | tb_s = "".join(traceback.format_exception(*tb)) |
1176 | 496 | 497 | ||
1177 | === modified file 'bin/tools/config.py' | |||
1178 | --- bin/tools/config.py 2010-11-17 12:39:28 +0000 | |||
1179 | +++ bin/tools/config.py 2010-12-08 16:09:30 +0000 | |||
1180 | @@ -31,8 +31,8 @@ | |||
1181 | 31 | try: | 31 | try: |
1182 | 32 | from OpenSSL import SSL | 32 | from OpenSSL import SSL |
1183 | 33 | import socket | 33 | import socket |
1186 | 34 | 34 | ||
1187 | 35 | return hasattr(socket, 'ssl') | 35 | return hasattr(socket, 'ssl') and hasattr(SSL, "Connection") |
1188 | 36 | except: | 36 | except: |
1189 | 37 | return False | 37 | return False |
1190 | 38 | 38 | ||
1191 | @@ -91,7 +91,10 @@ | |||
1192 | 91 | 'static_http_url_prefix': None, | 91 | 'static_http_url_prefix': None, |
1193 | 92 | 'secure_cert_file': 'server.cert', | 92 | 'secure_cert_file': 'server.cert', |
1194 | 93 | 'secure_pkey_file': 'server.pkey', | 93 | 'secure_pkey_file': 'server.pkey', |
1195 | 94 | 'publisher_warranty_url': 'http://www.openerp.com/publisher-warranty', | ||
1196 | 94 | } | 95 | } |
1197 | 96 | |||
1198 | 97 | self.blacklist_for_save = set(["publisher_warranty_url"]) | ||
1199 | 95 | 98 | ||
1200 | 96 | self.misc = {} | 99 | self.misc = {} |
1201 | 97 | self.config_file = fname | 100 | self.config_file = fname |
1202 | @@ -224,7 +227,7 @@ | |||
1203 | 224 | parser.add_option_group(security) | 227 | parser.add_option_group(security) |
1204 | 225 | 228 | ||
1205 | 226 | def parse_config(self): | 229 | def parse_config(self): |
1207 | 227 | (opt, args) = self.parser.parse_args() | 230 | opt = self.parser.parse_args()[0] |
1208 | 228 | 231 | ||
1209 | 229 | def die(cond, msg): | 232 | def die(cond, msg): |
1210 | 230 | if cond: | 233 | if cond: |
1211 | @@ -317,7 +320,7 @@ | |||
1212 | 317 | # If an explicit TZ was provided in the config, make sure it is known | 320 | # If an explicit TZ was provided in the config, make sure it is known |
1213 | 318 | try: | 321 | try: |
1214 | 319 | import pytz | 322 | import pytz |
1216 | 320 | tz = pytz.timezone(self.options['timezone']) | 323 | pytz.timezone(self.options['timezone']) |
1217 | 321 | except pytz.UnknownTimeZoneError: | 324 | except pytz.UnknownTimeZoneError: |
1218 | 322 | die(True, "The specified timezone (%s) is invalid" % self.options['timezone']) | 325 | die(True, "The specified timezone (%s) is invalid" % self.options['timezone']) |
1219 | 323 | except: | 326 | except: |
1220 | @@ -374,7 +377,10 @@ | |||
1221 | 374 | fp.close() | 377 | fp.close() |
1222 | 375 | 378 | ||
1223 | 376 | if is_win32: | 379 | if is_win32: |
1225 | 377 | import _winreg | 380 | try: |
1226 | 381 | import _winreg | ||
1227 | 382 | except ImportError: | ||
1228 | 383 | _winreg = None | ||
1229 | 378 | x=_winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE) | 384 | x=_winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE) |
1230 | 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) |
1231 | 380 | _winreg.SetValueEx(y,"PGPASSFILE", 0, _winreg.REG_EXPAND_SZ, filename ) | 386 | _winreg.SetValueEx(y,"PGPASSFILE", 0, _winreg.REG_EXPAND_SZ, filename ) |
1232 | @@ -436,16 +442,18 @@ | |||
1233 | 436 | p = ConfigParser.ConfigParser() | 442 | p = ConfigParser.ConfigParser() |
1234 | 437 | loglevelnames = dict(zip(self._LOGLEVELS.values(), self._LOGLEVELS.keys())) | 443 | loglevelnames = dict(zip(self._LOGLEVELS.values(), self._LOGLEVELS.keys())) |
1235 | 438 | p.add_section('options') | 444 | p.add_section('options') |
1237 | 439 | for opt in self.options.keys(): | 445 | for opt in sorted(self.options.keys()): |
1238 | 440 | if opt in ('version', 'language', 'translate_out', 'translate_in', 'init', 'update'): | 446 | if opt in ('version', 'language', 'translate_out', 'translate_in', 'init', 'update'): |
1239 | 441 | continue | 447 | continue |
1240 | 448 | if opt in self.blacklist_for_save: | ||
1241 | 449 | continue | ||
1242 | 442 | if opt in ('log_level', 'assert_exit_level'): | 450 | if opt in ('log_level', 'assert_exit_level'): |
1243 | 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])) |
1244 | 444 | else: | 452 | else: |
1245 | 445 | p.set('options', opt, self.options[opt]) | 453 | p.set('options', opt, self.options[opt]) |
1246 | 446 | 454 | ||
1249 | 447 | for sec in self.misc.keys(): | 455 | for sec in sorted(self.misc.keys()): |
1250 | 448 | for opt in self.misc[sec].keys(): | 456 | for opt in sorted(self.misc[sec].keys()): |
1251 | 449 | p.set(sec,opt,self.misc[sec][opt]) | 457 | p.set(sec,opt,self.misc[sec][opt]) |
1252 | 450 | 458 | ||
1253 | 451 | # try to create the directories and write the file | 459 | # try to create the directories and write the file |
1254 | 452 | 460 | ||
1255 | === removed file 'bin/tools/maintenance.py' | |||
1256 | --- bin/tools/maintenance.py 2009-10-20 10:52:23 +0000 | |||
1257 | +++ bin/tools/maintenance.py 1970-01-01 00:00:00 +0000 | |||
1258 | @@ -1,69 +0,0 @@ | |||
1259 | 1 | # -*- coding: utf-8 -*- | ||
1260 | 2 | ############################################################################## | ||
1261 | 3 | # | ||
1262 | 4 | # OpenERP, Open Source Management Solution | ||
1263 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
1264 | 6 | # | ||
1265 | 7 | # This program is free software: you can redistribute it and/or modify | ||
1266 | 8 | # it under the terms of the GNU Affero General Public License as | ||
1267 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
1268 | 10 | # License, or (at your option) any later version. | ||
1269 | 11 | # | ||
1270 | 12 | # This program is distributed in the hope that it will be useful, | ||
1271 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1272 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1273 | 15 | # GNU Affero General Public License for more details. | ||
1274 | 16 | # | ||
1275 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
1276 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1277 | 19 | # | ||
1278 | 20 | ############################################################################## | ||
1279 | 21 | |||
1280 | 22 | import xmlrpclib | ||
1281 | 23 | |||
1282 | 24 | class RemoteContractException(Exception): pass | ||
1283 | 25 | |||
1284 | 26 | class remote_contract(object): | ||
1285 | 27 | def __init__(self, contract_id, contract_password, modules=None): | ||
1286 | 28 | self.__server = 'http://tiny.my.odoo.com:8069/xmlrpc/' | ||
1287 | 29 | self.__db = "tiny_belgium" | ||
1288 | 30 | self.__password = "maintenance" | ||
1289 | 31 | self.__login = "maintenance" | ||
1290 | 32 | |||
1291 | 33 | rpc = xmlrpclib.ServerProxy(self.__server + 'common') | ||
1292 | 34 | try: | ||
1293 | 35 | self.__userid = rpc.login(self.__db, self.__login, self.__password) | ||
1294 | 36 | except: | ||
1295 | 37 | raise RemoteContractException("Unable to contact the migration server") | ||
1296 | 38 | |||
1297 | 39 | if not self.__userid: | ||
1298 | 40 | raise RemoteContractException("Unable to contact the migration server") | ||
1299 | 41 | |||
1300 | 42 | self.__rpc = xmlrpclib.ServerProxy(self.__server + 'object') | ||
1301 | 43 | |||
1302 | 44 | |||
1303 | 45 | contract = { | ||
1304 | 46 | 'name': contract_id, | ||
1305 | 47 | 'password': contract_password, | ||
1306 | 48 | } | ||
1307 | 49 | if modules is None: | ||
1308 | 50 | modules = [] | ||
1309 | 51 | |||
1310 | 52 | info = self.check_contract(modules, contract) | ||
1311 | 53 | for n in info: | ||
1312 | 54 | setattr(self, n, info[n]) | ||
1313 | 55 | |||
1314 | 56 | self.name = contract_id | ||
1315 | 57 | self.contract_id = self.name | ||
1316 | 58 | self.password = contract_password | ||
1317 | 59 | |||
1318 | 60 | def __getattr__(self, fun): | ||
1319 | 61 | def remote_call(*args, **kwargs): | ||
1320 | 62 | return self.__rpc.execute(self.__db, self.__userid, self.__password, 'maintenance.maintenance', fun, *args, **kwargs) | ||
1321 | 63 | return remote_call | ||
1322 | 64 | |||
1323 | 65 | def __getitem__(self, item): | ||
1324 | 66 | return getattr(self, item) | ||
1325 | 67 | |||
1326 | 68 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
1327 | 69 |