Merge lp:~openerp-dev/openobject-addons/atp-dev-addons1 into lp:~openerp-dev/openobject-addons/trunk-dev-addons1

Proposed by Atul Patel(OpenERP)
Status: Rejected
Rejected by: tfr (Openerp)
Proposed branch: lp:~openerp-dev/openobject-addons/atp-dev-addons1
Merge into: lp:~openerp-dev/openobject-addons/trunk-dev-addons1
Diff against target: 218 lines (+66/-23)
8 files modified
caldav/caldav_view.xml (+1/-0)
caldav/calendar.py (+18/-2)
crm_caldav/crm_caldav_data.xml (+2/-2)
crm_caldav/crm_caldav_setup.xml (+2/-2)
document/document.py (+31/-1)
document/document_data.xml (+4/-1)
document/std_index.py (+6/-14)
document_ftp/wizard/ftp_configuration.py (+2/-1)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/atp-dev-addons1
Reviewer Review Type Date Requested Status
xrg (community) Disapprove
Review via email: mp+44557@code.launchpad.net

This proposal supersedes a proposal from 2010-12-01.

Description of the change

1) PUT 'Datetime In UTC' in Function field of Calendar Form for Caldav module to Export ics datetime In UTC.

2) Add "write_date" for DTSTAMP in calendar based on standard RFC 5545, par 3.8.7.2.

3) Add Menutips in calendar View.

4)Fixed Problem of "After install document module, documents are lost which are added
  before installed document module"

Thanks.

To post a comment you must log in.
Revision history for this message
xrg (xrg) wrote : Posted in a previous version of this proposal

So far: document.py must *NEVER* access the database directly for datas.
The change in webdav_server.py actually /breaks/ the webdavS protocol.

review: Disapprove
Revision history for this message
xrg (xrg) wrote :

Errors were still present.
Please merge this one instead:
https://code.launchpad.net/~xrg/openobject-addons/trunk-patch17-dev-atp

review: Disapprove

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'caldav/caldav_view.xml'
2--- caldav/caldav_view.xml 2010-11-18 05:21:19 +0000
3+++ caldav/caldav_view.xml 2010-12-29 12:07:47 +0000
4@@ -168,6 +168,7 @@
5 <field name="res_model">basic.calendar</field>
6 <field name="view_type">form</field>
7 <field name="view_mode">tree,form</field>
8+ <field name="help">"Calendars" allow you to Customize calendar event and todo attribute with any of OpenERP model.Caledars provide iCal Import/Export functionality.Webdav server that provides remote access to calendar.Help You to synchronize Meeting with Calendars client.You can access Calendars using CalDAV clients, like sunbird, Calendar Evaluation, Mobile.</field>
9 </record>
10
11 <record id="action_caldav_view1" model="ir.actions.act_window.view">
12
13=== modified file 'caldav/calendar.py'
14--- caldav/calendar.py 2010-12-20 14:02:20 +0000
15+++ caldav/calendar.py 2010-12-29 12:07:47 +0000
16@@ -164,6 +164,8 @@
17 res[attr] = {}
18 res[attr]['field'] = field.field_id.name
19 res[attr]['type'] = field.field_id.ttype
20+ if field.fn == 'datetime_utc':
21+ res[attr]['type'] = 'utc'
22 if field.fn == 'hours':
23 res[attr]['type'] = "timedelta"
24 if res[attr]['type'] in ('one2many', 'many2many', 'many2one'):
25@@ -254,7 +256,6 @@
26 @param name: Get Attribute Name
27 @param type: Get Attribute Type
28 """
29-
30 if self.__attribute__.get(name):
31 val = self.__attribute__.get(name).get(type, None)
32 valtype = self.__attribute__.get(name).get('type', None)
33@@ -273,7 +274,6 @@
34 @param self: The object pointer,
35 @param type: Get Attribute Type
36 """
37-
38 for name in self.__attribute__:
39 if self.__attribute__[name]:
40 self.__attribute__[name][type] = None
41@@ -446,6 +446,21 @@
42 dtfield.value = self.format_date_tz(parser.parse(data[map_field]), tzval.title())
43 else:
44 dtfield.value = parser.parse(data[map_field])
45+
46+ elif map_type == 'utc'and data[map_field]:
47+ if tzval:
48+ local = pytz.timezone (tzval.title())
49+ naive = datetime.strptime (data[map_field], "%Y-%m-%d %H:%M:%S")
50+ local_dt = naive.replace (tzinfo = local)
51+ utc_dt = local_dt.astimezone (pytz.utc)
52+ vevent.add(field).value = utc_dt
53+ else:
54+ utc_timezone = pytz.timezone ('UTC')
55+ naive = datetime.strptime (data[map_field], "%Y-%m-%d %H:%M:%S")
56+ local_dt = naive.replace (tzinfo = utc_timezone)
57+ utc_dt = local_dt.astimezone (pytz.utc)
58+ vevent.add(field).value = utc_dt
59+
60 elif map_type == "timedelta":
61 vevent.add(field).value = timedelta(hours=data[map_field])
62 elif map_type == "many2one":
63@@ -829,6 +844,7 @@
64 'fn': fields.selection([('field', 'Use the field'),
65 ('const', 'Expression as constant'),
66 ('hours', 'Interval in hours'),
67+ ('datetime_utc', 'Datetime In UTC'),
68 ], 'Function'),
69 'mapping': fields.text('Mapping'),
70 }
71
72=== modified file 'crm_caldav/crm_caldav_data.xml'
73--- crm_caldav/crm_caldav_data.xml 2010-11-24 04:53:34 +0000
74+++ crm_caldav/crm_caldav_data.xml 2010-12-29 12:07:47 +0000
75@@ -117,8 +117,8 @@
76 <record model="basic.calendar.fields" id="map_event_13">
77 <field name="name" ref="caldav.field_event_dtstamp"/>
78 <field name="type_id" ref="base_calendar.calendar_lines_event" />
79- <field name="field_id" search="[('name','=','date'),('model_id.model','=','calendar.event')]" />
80- <field name="fn">field</field>
81+ <field name="field_id" search="[('name','=','write_date'),('model_id.model','=','crm.meeting')]" />
82+ <field name="fn">datetime_utc</field>
83 </record>
84
85 <record model="basic.calendar.fields" id="map_event_14">
86
87=== modified file 'crm_caldav/crm_caldav_setup.xml'
88--- crm_caldav/crm_caldav_setup.xml 2010-11-22 11:42:07 +0000
89+++ crm_caldav/crm_caldav_setup.xml 2010-12-29 12:07:47 +0000
90@@ -176,8 +176,8 @@
91 <record id="basic_calendar_fields_24" model="basic.calendar.fields">
92 <field name="name" ref="caldav.field_event_dtstamp"/>
93 <field name="type_id" ref="basic_calendar_lines_vevent0"/>
94- <field name="field_id" ref="base_calendar.field_calendar_event_date"/>
95- <field name="fn">field</field>
96+ <field name="field_id" ref="crm.field_crm_meeting_write_date"/>
97+ <field name="fn">datetime_utc</field>
98 </record>
99 <record id="basic_calendar_fields_25" model="basic.calendar.fields">
100 <field name="name" ref="caldav.field_event_description"/>
101
102=== modified file 'document/document.py'
103--- document/document.py 2010-12-06 13:11:02 +0000
104+++ document/document.py 2010-12-29 12:07:47 +0000
105@@ -35,6 +35,36 @@
106 class document_file(osv.osv):
107 _inherit = 'ir.attachment'
108 _rec_name = 'datas_fname'
109+
110+ def _attach_parent_id(self, cr, uid, ids=None, context=None):
111+ """Migrate ir.attachments to the document module.
112+
113+ When the 'document' module is loaded on a db that has had plain attachments,
114+ they will need to be attached to some parent folder, and be converted from
115+ base64-in-bytea to raw-in-bytea format.
116+ This function performs the internal migration, once and forever, for these
117+ attachments. It cannot be done through the nominal ORM maintenance code,
118+ because the root folder is only created after the document_data.xml file
119+ is loaded.
120+ It also establishes the parent_id NOT NULL constraint that ir.attachment
121+ should have had (but would have failed if plain attachments contained null
122+ values).
123+ """
124+
125+ parent_id = self.pool.get('document.directory')._get_root_directory(cr,uid)
126+ if not parent_id:
127+ logging.getLogger('document').warning("at _attach_parent_id(), still not able to set the parent!")
128+ return False
129+
130+ if ids is not None:
131+ raise NotImplementedError("Ids is just there by convention! Don't use it yet, please.")
132+
133+ cr.execute("UPDATE ir_attachment " \
134+ "SET parent_id = %s, db_datas = decode(encode(db_datas,'escape'), 'base64') " \
135+ "WHERE parent_id IS NULL", (parent_id,))
136+ cr.execute("ALTER TABLE ir_attachment ALTER parent_id SET NOT NULL")
137+ return True
138+
139 def _get_filestore(self, cr):
140 return os.path.join(DMS_ROOT_PATH, cr.dbname)
141
142@@ -168,7 +198,7 @@
143 ids2 = []
144 for fbro in self.browse(cr, uid, ids, context=context):
145 if ('parent_id' not in vals or fbro.parent_id.id == vals['parent_id']) \
146- and ('name' not in vals or fbro.name == vals['name']) :
147+ and ('name' not in vals or fbro.name == vals['name']):
148 ids2.append(fbro.id)
149 continue
150 fnode = nctx.get_file_node(cr, fbro)
151
152=== modified file 'document/document_data.xml'
153--- document/document_data.xml 2010-10-27 10:24:28 +0000
154+++ document/document_data.xml 2010-12-29 12:07:47 +0000
155@@ -97,8 +97,11 @@
156 <field name="user_id" eval="False"/>
157 <field name="parent_id" ref="dir_root"/>
158 <field name="ressource_id">0</field>
159-
160 </record>
161
162+ <!-- After we have setup the root directory, migrate the attachments
163+ to point to that. -->
164+ <function model="ir.attachment" name="_attach_parent_id"/>
165+
166 </data>
167 </openerp>
168
169=== modified file 'document/std_index.py'
170--- document/std_index.py 2010-11-12 10:14:16 +0000
171+++ document/std_index.py 2010-12-29 12:07:47 +0000
172@@ -95,13 +95,9 @@
173 return ['.doc']
174
175 def _doIndexFile(self,fname):
176- fp = Popen(['antiword', fname], shell=False, stdout=PIPE).stdout
177- try:
178- file_data = _to_unicode(fp.read())
179- finally:
180- fp.close()
181-
182- return file_data
183+ pop = Popen(['antiword', fname], shell=False, stdout=PIPE)
184+ (data, _) = pop.communicate()
185+ return _to_unicode(data)
186
187 cntIndex.register(DocIndex())
188
189@@ -162,13 +158,9 @@
190 return ['.pdf']
191
192 def _doIndexFile(self,fname):
193- fp = Popen(['pdftotext', '-enc', 'UTF-8', '-nopgbrk', fname, '-'], shell=False, stdout=PIPE).stdout
194- try:
195- file_data = _to_unicode( fp.read())
196- finally:
197- fp.close()
198-
199- return file_data
200+ pop = Popen(['pdftotext', '-enc', 'UTF-8', '-nopgbrk', fname, '-'], shell=False, stdout=PIPE)
201+ (data, _) = pop.communicate()
202+ return _to_unicode(data)
203
204 cntIndex.register(PdfIndex())
205
206
207=== modified file 'document_ftp/wizard/ftp_configuration.py'
208--- document_ftp/wizard/ftp_configuration.py 2010-12-06 13:11:02 +0000
209+++ document_ftp/wizard/ftp_configuration.py 2010-12-29 12:07:47 +0000
210@@ -44,6 +44,7 @@
211 # Update the action for FTP browse.
212 aid = data_pool._get_id(cr, uid, 'document_ftp', 'action_document_browse')
213 aid = data_pool.browse(cr, uid, aid, context=context).res_id
214- self.pool.get('ir.actions.url').write(cr, uid, [aid], {'url': 'ftp://'+(conf.host or 'localhost:8021')+'/'})
215+ self.pool.get('ir.actions.url').write(cr, uid, [aid],
216+ {'url': 'ftp://'+(conf.host or 'localhost:8021')+'/' + cr.dbname+'/'})
217
218 document_ftp_configuration()

Subscribers

People subscribed via source and target branches