Merge lp:~sebastien.beau/openobject-extension/oerp6.1-stable-fix into lp:openobject-extension/oerp6.1-stable

Proposed by Sébastien BEAU - http://www.akretion.com
Status: Needs review
Proposed branch: lp:~sebastien.beau/openobject-extension/oerp6.1-stable-fix
Merge into: lp:openobject-extension/oerp6.1-stable
Diff against target: 83 lines (+19/-10)
2 files modified
base_external_referentials/decorator.py (+15/-3)
base_file_protocole/base_file_protocole.py (+4/-7)
To merge this branch: bzr merge lp:~sebastien.beau/openobject-extension/oerp6.1-stable-fix
Reviewer Review Type Date Requested Status
extra-addons-commiter Pending
Review via email: mp+168486@code.launchpad.net

Description of the change

Fix base_file_protocole
And also fix the base_external_referential decorator for catching error. Indeed for example for the export of the picking the resource contain the id of the picking.

To post a comment you must log in.
396. By Sébastien BEAU - http://www.akretion.com

[FIX] fix error introduced by last merge. copy of log_kwargs must be out of the if

Unmerged revisions

398. By Sébastien BEAU - http://www.akretion.com

[REF] base_external_referentials : refactor the way to get the res_id, indeed in some case the resource is directly the res_id, so I just test if resource is an integer/long

397. By Sébastien BEAU - http://www.akretion.com

[FIX] base_file_protocole: fix read of fil ein file system

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'base_external_referentials/decorator.py'
2--- base_external_referentials/decorator.py 2012-12-03 16:26:23 +0000
3+++ base_external_referentials/decorator.py 2013-06-10 17:32:27 +0000
4@@ -112,18 +112,30 @@
5 if not context['report_line_based_on'] == self._name:
6 return func(self, cr, uid, external_session, resource, *args, **kwargs)
7 report_line_obj = self.pool.get('external.report.line')
8+
9+ #TODO improve me
10+ res_id = False
11+ external_id = False
12+ if context.get('external_id_key_for_report'):
13+ external_id = resource.get(context['external_id_key_for_report'])
14+ else:
15+ if type(resource) in [int, long]:
16+ res_id = resource
17+ else:
18+ res_id = args and args[0]
19+
20 report_line_id = report_line_obj.start_log(
21 cr,
22 uid,
23 self._name,
24 func.__name__,
25- #TODO manage external id and res_id in a good way
26- external_id=context.get('external_id_key_for_report') and resource.get(context.get('external_id_key_for_report')),
27- res_id= not context.get('external_id_key_for_report') and args and args[0],
28+ external_id = external_id,
29+ res_id = res_id,
30 resource=resource,
31 args = args,
32 kwargs = kwargs,
33 )
34+
35 import_cr = pooler.get_db(cr.dbname).cursor()
36 response = False
37 try:
38
39=== modified file 'base_file_protocole/base_file_protocole.py'
40--- base_file_protocole/base_file_protocole.py 2012-12-21 17:16:07 +0000
41+++ base_file_protocole/base_file_protocole.py 2013-06-10 17:32:27 +0000
42@@ -131,7 +131,7 @@
43 self.connection.storbinary('STOR ' + filename, output_file)
44 output_file.close()
45 return True
46- elif self.is_('filestore'):
47+ elif self.is_('filesystem'):
48 if not os.path.isabs(filepath):
49 filepath = os.path.join(self.location, filepath)
50 if self.allow_dir_creation and not os.path.exists(filepath):
51@@ -162,7 +162,7 @@
52 self.connection.retrbinary("RETR " + filename, outfile.write)
53 outfile.seek(0)
54 return outfile
55- elif self.is_('filestore'):
56+ elif self.is_('filesystem'):
57 return open(os.path.join(filepath, filename), 'r+b')
58
59 @open_and_close_connection
60@@ -171,14 +171,14 @@
61 self.connection.cwd(filepath)
62 #Take care that ftp lib use utf-8 and not unicode
63 return [x for x in self.connection.nlst() if filename.encode('utf-8') in x]
64- elif self.is_('filestore'):
65+ elif self.is_('filesystem'):
66 return [x for x in os.listdir(filepath) if filename in x]
67
68 @open_and_close_connection
69 def move(self, oldfilepath, newfilepath, filename):
70 if self.is_('ftp'):
71 self.connection.rename(os.path.join(oldfilepath, filename), os.path.join(newfilepath, filename))
72- elif self.is_('filestore'):
73+ elif self.is_('filesystem'):
74 os.rename(os.path.join(oldfilepath, filename), os.path.join(newfilepath, filename))
75
76 class FileCsvReader(object):
77@@ -287,6 +287,3 @@
78 index += 1
79 result.append(row)
80 return result
81-
82-
83-

Subscribers

People subscribed via source and target branches