Merge lp:~magentoerpconnect-community/magentoerpconnect/openerp6.1-module-fixes-and-legacy-ports into lp:magentoerpconnect/oerp6.1-stable

Proposed by Guewen Baconnier @ Camptocamp
Status: Needs review
Proposed branch: lp:~magentoerpconnect-community/magentoerpconnect/openerp6.1-module-fixes-and-legacy-ports
Merge into: lp:magentoerpconnect/oerp6.1-stable
Diff against target: 292 lines (+86/-53)
7 files modified
magentoerpconnect/__openerp__.py (+1/-1)
magentoerpconnect/magerp_osv.py (+36/-15)
magentoerpconnect/product.py (+14/-6)
magentoerpconnect/settings/1.3.2.4/external.mappinglines.template.csv (+5/-8)
magentoerpconnect/settings/1.5.0.0/product.category/external.mappinglines.template.csv (+16/-21)
magentoerpconnect/settings/magerp.product_category_attribute_options.csv (+2/-2)
magentoerpconnect_payment/sale.py (+12/-0)
To merge this branch: bzr merge lp:~magentoerpconnect-community/magentoerpconnect/openerp6.1-module-fixes-and-legacy-ports
Reviewer Review Type Date Requested Status
MagentoERPConnect core editors Pending
Review via email: mp+116208@code.launchpad.net

Description of the change

Fixes forwarded from the legacy branch.

To post a comment you must log in.

Unmerged revisions

674. By Guewen Baconnier @ Camptocamp <email address hidden>

[FIX] available_sort_by should send a list with an empty string when default value is wished

673. By Guewen Baconnier @ Camptocamp <email address hidden>

[FIX] mappings, sort_by and page_layout whose value should not be None (lp:876312) and some other mappings which fail

672. By Alexandre Fayolle @ camptocamp <email address hidden>

bump up version number, reflecting schema change

671. By Alexandre Fayolle @ camptocamp <email address hidden>

[FIX] magentoerpconnect: the product.category metat_title has a max length of 255 char on magento

670. By Guewen Baconnier @ Camptocamp <email address hidden>

[IMP] port the logging improvements by Alexandre Fayolle on legacy branch (truncate too long values, like base64 images...,, user proper arguments in logger)

669. By Guewen Baconnier @ Camptocamp <email address hidden>

[IMP] magentoerpconnect_payment: deactivate need_to_update when the payment are created from openerp

668. By Guewen Baconnier @ Camptocamp <email address hidden>

[FIX] Synchronization reporting menu was broken, fixed domain

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'magentoerpconnect/__openerp__.py'
2--- magentoerpconnect/__openerp__.py 2012-05-16 08:01:05 +0000
3+++ magentoerpconnect/__openerp__.py 2012-07-23 07:27:31 +0000
4@@ -18,7 +18,7 @@
5 #########################################################################
6 {
7 "name" : "Magento e-commerce",
8- "version" : "1.0",
9+ "version" : "1.0.1",
10 "depends" : ["base",
11 "product",
12 "product_m2mcategories",
13
14=== modified file 'magentoerpconnect/magerp_osv.py'
15--- magentoerpconnect/magerp_osv.py 2012-05-24 20:52:38 +0000
16+++ magentoerpconnect/magerp_osv.py 2012-07-23 07:27:31 +0000
17@@ -191,7 +191,7 @@
18 if not self.location[-1] == '/':
19 self.location += '/'
20 if self.debug:
21- self.logger.info("Attempting connection with Settings:%s,%s,%s" % (self.location, self.username, self.password))
22+ self.logger.info("Attempting connection with Settings:%s,%s,%s", self.location, self.username, self.password)
23 self.ser = xmlrpclib.ServerProxy(self.location)
24 for sleep_time in [1, 3, 6]:
25 try:
26@@ -200,17 +200,36 @@
27 self.logger.info("Login Successful")
28 return True
29 except IOError, e:
30- self.logger.error("Error in connecting:%s" % e)
31- self.logger.warning("Webservice Failure, sleeping %s second before next attempt" % sleep_time)
32+ self.logger.error("Error in connecting:%s", e, exc_info=True)
33+ self.logger.warn("Webservice Failure, sleeping %s second before next attempt", sleep_time)
34 time.sleep(sleep_time)
35 except Exception,e:
36- self.logger.error("Magento Connection" + netsvc.LOG_ERROR + "Error in connecting:%s" % e)
37- self.logger.warning("Webservice Failure, sleeping %s second before next attempt" % sleep_time)
38- time.sleep(sleep_time)
39- raise osv.except_osv(_('User Error'), _('Error when try to connect to magento, are your sure that your login is right? Did openerp can access to your magento?'))
40-
41-
42- def call(self, method, *arguments):
43+ self.logger.error("Error in connecting:%s", e, exc_info=True)
44+ self.logger.warn("Webservice Failure, sleeping %s second before next attempt", sleep_time)
45+ time.sleep(sleep_time)
46+ raise osv.except_osv(_('User Error'), _('Error connecting to magento, are your sure that your login is right? Did you configure API user in magento?'))
47+
48+ def _truncate_arguments(self, arguments, max_length=128):
49+ """truncate long strings in arguments for logging purpose"""
50+ logged_args = []
51+ try:
52+ for arg in arguments:
53+ # reduce verbosity of log for large strings (e.g. base64 encoded images...)
54+ if isinstance(arg, basestring) and len(arg) > max_length:
55+ arg = arg[:max_length] + '...'
56+ elif isinstance(arg, dict):
57+ new_arg = {}
58+ for key, value in arg.iteritems():
59+ if isinstance(value, basestring) and len(value) > max_length:
60+ value = value[:max_length] + '...'
61+ new_arg[key] = value
62+ arg = new_arg
63+ logged_args.append(arg)
64+ return logged_args
65+ except TypeError: # arguments can be a bool
66+ return arguments
67+
68+ def call(self, method, *arguments):
69 if arguments:
70 arguments = list(arguments)[0]
71 else:
72@@ -218,18 +237,20 @@
73 for sleep_time in [1, 3, 6]:
74 try:
75 if self.debug:
76- self.logger.info(_("Calling Method:%s,Arguments:%s") % (method, arguments))
77+ logged_args = self._truncate_arguments(arguments)
78+ self.logger.info("Calling Method:%s,Arguments:%s", method, logged_args)
79 res = self.ser.call(self.session, method, arguments)
80 if self.debug:
81+ logged_res = self._truncate_arguments(res)
82 if method=='catalog_product.list':
83 # the response of the method catalog_product.list can be very very long so it's better to see it only if debug log is activate
84- self.logger.debug(_("Query Returned:%s") % (res))
85+ self.logger.debug("Query Returned:%s", logged_res)
86 else:
87- self.logger.info(_("Query Returned:%s") % (res))
88+ self.logger.info("Query Returned:%s", logged_res)
89 return res
90 except IOError, e:
91- self.logger.error(_("Method: %s\nArguments:%s\nError:%s") % (method, arguments, e))
92- self.logger.warning(_("Webservice Failure, sleeping %s second before next attempt") % (sleep_time))
93+ self.logger.error("Method: %s\nArguments:%s\nError:%s", method, arguments, e, exc_info=True)
94+ self.logger.warn("Webservice Failure, sleeping %s second before next attempt", sleep_time)
95 time.sleep(sleep_time)
96 raise
97
98
99=== modified file 'magentoerpconnect/product.py'
100--- magentoerpconnect/product.py 2012-06-21 16:33:03 +0000
101+++ magentoerpconnect/product.py 2012-07-23 07:27:31 +0000
102@@ -100,6 +100,12 @@
103 'label':fields.char('Label', size=100),
104 }
105
106+ def init(self, cr):
107+ # the 'None' value was wrong and misinterpreted by Magento
108+ # this value should never be used even if Magento accept it.
109+ cr.execute("UPDATE magerp_product_category_attribute_options "
110+ "SET value = '' "
111+ "WHERE value = 'None'")
112
113 magerp_product_category_attribute_options()
114
115@@ -176,7 +182,7 @@
116 'description': fields.text('Description'),
117 'image': fields.binary('Image'),
118 'image_name':fields.char('File Name', size=100),
119- 'meta_title': fields.char('Title (Meta)', size=75),
120+ 'meta_title': fields.char('Title (Meta)', size=255),
121 'meta_keywords': fields.text('Meta Keywords'),
122 'meta_description': fields.text('Meta Description'),
123 'url_key': fields.char('URL-key', size=100), #Readonly
124@@ -187,22 +193,24 @@
125 ('PRODUCTS_AND_PAGE', 'Static Block & Products')], 'Display Mode', required=True),
126 'is_anchor': fields.boolean('Anchor?'),
127 'use_default_available_sort_by': fields.boolean('Default Config For Available Sort By', help="Use default config for available sort by"),
128- 'available_sort_by': fields.sparse(type='many2many', relation='magerp.product_category_attribute_options', string='Available Product Listing (Sort By)', serialization_field='magerp_fields', domain="[('attribute_name', '=', 'sort_by'), ('value', '!=','None')]"),
129+ 'available_sort_by': fields.sparse(type='many2many',
130+ relation='magerp.product_category_attribute_options',
131+ string='Available Product Listing (Sort By)',
132+ serialization_field='magerp_fields',
133+ domain="[('attribute_name', '=', 'sort_by'), ('value', '!=', False)]"),
134 'default_sort_by': fields.many2one('magerp.product_category_attribute_options', 'Default Product Listing Sort (Sort By)', domain="[('attribute_name', '=', 'sort_by')]", require=True),
135 'magerp_stamp':fields.datetime('Magento stamp'),
136 'include_in_menu': fields.boolean('Include in Navigation Menu'),
137 'page_layout': fields.many2one('magerp.product_category_attribute_options', 'Page Layout', domain="[('attribute_name', '=', 'page_layout')]"),
138 }
139
140-
141-
142 _defaults = {
143 'display_mode':lambda * a:'PRODUCTS',
144 'use_default_available_sort_by': lambda * a:True,
145- 'default_sort_by': lambda self,cr,uid,c: self.pool.get('magerp.product_category_attribute_options')._get_default_option(cr, uid, 'sort_by', 'None', context=c),
146+ 'default_sort_by': lambda self,cr,uid,c: self.pool.get('magerp.product_category_attribute_options')._get_default_option(cr, uid, 'sort_by', '', context=c),
147 'level':lambda * a:1,
148 'include_in_menu': lambda * a:True,
149- 'page_layout': lambda self,cr,uid,c: self.pool.get('magerp.product_category_attribute_options')._get_default_option(cr, uid, 'page_layout', 'None', context=c),
150+ 'page_layout': lambda self,cr,uid,c: self.pool.get('magerp.product_category_attribute_options')._get_default_option(cr, uid, 'page_layout', '', context=c),
151 }
152
153 def write(self, cr, uid, ids, vals, context=None):
154
155=== modified file 'magentoerpconnect/settings/1.3.2.4/external.mappinglines.template.csv'
156--- magentoerpconnect/settings/1.3.2.4/external.mappinglines.template.csv 2012-05-24 19:50:22 +0000
157+++ magentoerpconnect/settings/1.3.2.4/external.mappinglines.template.csv 2012-07-23 07:27:31 +0000
158@@ -86,17 +86,14 @@
159 attr_ids.append(cat_attr_obj.get_create_option_id(cr, uid, val,'sort_by', context=context))
160 result=[('available_sort_by', [(6, 0, attr_ids)]), ('use_default_available_sort_by', False)]
161 else:
162- result=[('use_default_available_sort_by', True)]","if record['use_default_available_sort_by']:
163- res = u'None'
164-else:
165- res = []
166- for cat_attr_option in self.pool.get('magerp.product_category_attribute_options').browse(cr, uid, record['available_sort_by'], context=context):
167- res.append(cat_attr_option.value)
168+ result=[('use_default_available_sort_by', True)]","res = ['']
169+if not resource.get('use_default_available_sort_by') and resource.get('available_sort_by'):
170+ res = [option.value for option in self.pool.get('magerp.product_category_attribute_options').browse(cr, uid, resource['available_sort_by'], context=context)]
171 result=[('available_sort_by', res)]"
172 "mag_1324_erp_procat_13","magento1324","product.model_product_category","default_sort_by",,"in_out","function","unicode",,"if ifield:
173 att_id = self.pool.get('magerp.product_category_attribute_options').get_create_option_id(cr, uid, ifield,'sort_by', context=context)
174 else:
175- att_id = self.pool.get('magerp.product_category_attribute_options').get_create_option_id(cr, uid, 'None','sort_by', context=context)
176+ att_id = self.pool.get('magerp.product_category_attribute_options').get_create_option_id(cr, uid, '','sort_by', context=context)
177 result=[('default_sort_by',att_id)]","cat_attr_option = self.pool.get('magerp.product_category_attribute_options').browse(cr, uid, record['default_sort_by'][0], context=context)
178 result=[('default_sort_by', cat_attr_option.value)]"
179 "mag_1324_erp_procat_14","magento1324","product.model_product_category","updated_at",,"in","function","unicode",,"result=[('magerp_stamp',ifield)]",
180@@ -120,7 +117,7 @@
181 "mag_1324_erp_procat_17","magento1324","product.model_product_category","page_layout",,"in_out","function","unicode",,"if ifield:
182 att_id = self.pool.get('magerp.product_category_attribute_options').get_create_option_id(cr, uid, ifield,'page_layout', context=context)
183 else:
184- att_id = self.pool.get('magerp.product_category_attribute_options').get_create_option_id(cr, uid, 'None','page_layout', context=context)
185+ att_id = self.pool.get('magerp.product_category_attribute_options').get_create_option_id(cr, uid, '','page_layout', context=context)
186 result=[('page_layout',att_id)]","result=[('page_layout', record['page_layout'][1] or '')]"
187 "mag_1324_erp_attrgrp_2","magento1324","model_magerp_product_attribute_groups","attribute_set_id",,"in_out","function","int",,"result=[('attribute_set_id', ifield)]","result=[('attribute_set_id', record['attribute_set_id'])]"
188 "mag_1324_erp_attrgrp_3","magento1324","model_magerp_product_attribute_groups","attribute_group_name",,"in_out","function","unicode",,"result=[('attribute_group_name', ifield)]","result=[('attribute_group_name', record['attribute_group_name'])]"
189
190=== modified file 'magentoerpconnect/settings/1.5.0.0/product.category/external.mappinglines.template.csv'
191--- magentoerpconnect/settings/1.5.0.0/product.category/external.mappinglines.template.csv 2012-05-07 20:54:47 +0000
192+++ magentoerpconnect/settings/1.5.0.0/product.category/external.mappinglines.template.csv 2012-07-23 07:27:31 +0000
193@@ -8,17 +8,17 @@
194 if resource['default_sort_by']:
195 att_id = self.pool.get('magerp.product_category_attribute_options').get_create_option_id(cr, uid, resource['default_sort_by'],'sort_by', context=context)
196 else:
197- att_id = self.pool.get('magerp.product_category_attribute_options').get_create_option_id(cr, uid, 'None','sort_by', context=context)
198- result=[('default_sort_by',att_id)]","if 'default_sort_by' in resource:
199+ att_id = self.pool.get('magerp.product_category_attribute_options').get_create_option_id(cr, uid, '','sort_by', context=context)
200+ result=[('default_sort_by',att_id)]","if resource.get('default_sort_by'):
201 cat_attr_option = self.pool.get('magerp.product_category_attribute_options').browse(cr, uid, resource['default_sort_by'][0], context=context)
202 result=[('default_sort_by', cat_attr_option.value)]"
203 magentoerpconnect.mag1500_product_category_updated_at,magentoerpconnect.mag1500_product_category,updated_at,magentoerpconnect.field_product_category_magerp_stamp,in,direct,unicode,,False,,
204 magentoerpconnect.mag1500_product_category_include_in_menu,magentoerpconnect.mag1500_product_category,include_in_menu,magentoerpconnect.field_product_category_include_in_menu,in_out,direct,int,,False,,
205-magentoerpconnect.mag1500_product_category_page_layout,magentoerpconnect.mag1500_product_category,page_layout,,in_out,function,unicode,,False,"if resource['page_layout']:
206+magentoerpconnect.mag1500_product_category_page_layout,magentoerpconnect.mag1500_product_category,page_layout,,in_out,function,unicode,,False,"if resource.get('page_layout'):
207 att_id = self.pool.get('magerp.product_category_attribute_options').get_create_option_id(cr, uid, resource['page_layout'],'page_layout', context=context)
208 else:
209- att_id = self.pool.get('magerp.product_category_attribute_options').get_create_option_id(cr, uid, 'None','page_layout', context=context)
210-result=[('page_layout',att_id)]","if 'page_layout' in resource:
211+ att_id = self.pool.get('magerp.product_category_attribute_options').get_create_option_id(cr, uid, '','page_layout', context=context)
212+result=[('page_layout',att_id)]","if resource.get('page_layout'):
213 result=[('page_layout', resource['page_layout'][1] or '')]"
214 magentoerpconnect.mag1500_product_category_available_sort_by,magentoerpconnect.mag1500_product_category,available_sort_by,,in_out,function,unicode,,False,"if 'use_default_available_sort_by' in resource:
215 attr_ids = []
216@@ -28,14 +28,10 @@
217 attr_ids.append(cat_attr_obj.get_create_option_id(cr, uid, val,'sort_by', context=context))
218 result=[('available_sort_by', [(6, 0, attr_ids)]), ('use_default_available_sort_by', False)]
219 else:
220- result=[('use_default_available_sort_by', True)]","if 'use_default_available_sort_by' in resource:
221- if resource['use_default_available_sort_by']:
222- res = u'None'
223- else:
224- res = []
225- for cat_attr_option in self.pool.get('magerp.product_category_attribute_options').browse(cr, uid, record['available_sort_by'], context=context):
226- res.append(cat_attr_option.value)
227- result=[('available_sort_by', res)]"
228+ result=[('use_default_available_sort_by', True)]","res = ['']
229+if not resource.get('use_default_available_sort_by') and resource.get('available_sort_by'):
230+ res = [option.value for option in self.pool.get('magerp.product_category_attribute_options').browse(cr, uid, resource['available_sort_by'], context=context)]
231+result=[('available_sort_by', res)]"
232 magentoerpconnect.mag1500_product_category_url_key,magentoerpconnect.mag1500_product_category,url_key,magentoerpconnect.field_product_category_url_key,in_out,direct,unicode,,False,,
233 magentoerpconnect.mag1500_product_category_meta_description,magentoerpconnect.mag1500_product_category,meta_description,magentoerpconnect.field_product_category_meta_description,in_out,direct,unicode,,False,,
234 magentoerpconnect.mag1500_product_category_description,magentoerpconnect.mag1500_product_category,description,magentoerpconnect.field_product_category_description,in_out,direct,unicode,,False,,
235@@ -50,11 +46,10 @@
236 pass
237 if image_binary:
238 image_binary = base64.encodestring(base64.urlsafe_b64decode(image_binary[0]['image_data']))
239-result=[('image_name',ifield),('image',image_binary)]","if 'image' in resource:
240- if resource['image']:
241- img = base64.decodestring(record['image'])
242- img_bin_enc = base64.encodestring(img)
243- conn.call('ol_catalog_category_media.create', [record['image_name'], img_bin_enc])
244- result = [('image',record['image_name'])]
245- else:
246- result=[]"
247+result=[('image_name',ifield),('image',image_binary)]","result = []
248+# FIXME: conn is False, call create at each update of the category?!
249+#if resource.get('image'):
250+# img = base64.decodestring(resource['image'])
251+# img_bin_enc = base64.encodestring(img)
252+# conn.call('ol_catalog_category_media.create', [resource['image_name'], img_bin_enc])
253+# result = [('image',resource['image_name'])]"
254
255=== modified file 'magentoerpconnect/settings/magerp.product_category_attribute_options.csv'
256--- magentoerpconnect/settings/magerp.product_category_attribute_options.csv 2011-10-16 17:14:20 +0000
257+++ magentoerpconnect/settings/magerp.product_category_attribute_options.csv 2012-07-23 07:27:31 +0000
258@@ -1,11 +1,11 @@
259 "id","attribute_name","label","value"
260-"mag_product_category_attribute_1","page_layout","No layout updates","None"
261+"mag_product_category_attribute_1","page_layout","No layout updates",""
262 "mag_product_category_attribute_2","page_layout","Empty","empty"
263 "mag_product_category_attribute_3","page_layout","1 column","one_column"
264 "mag_product_category_attribute_4","page_layout","2 columns with left bar","two_column_left"
265 "mag_product_category_attribute_5","page_layout","2 columns with right bar","two_columns_right"
266 "mag_product_category_attribute_6","page_layout","3 columns","three_columns"
267-"mag_product_category_attribute_7","sort_by","Use Config Settings","None"
268+"mag_product_category_attribute_7","sort_by","Use Config Settings",""
269 "mag_product_category_attribute_8","sort_by","Best Value","position"
270 "mag_product_category_attribute_9","sort_by","Name","name"
271 "mag_product_category_attribute_10","sort_by","Price","price"
272
273=== modified file 'magentoerpconnect_payment/sale.py'
274--- magentoerpconnect_payment/sale.py 2012-03-27 09:40:33 +0000
275+++ magentoerpconnect_payment/sale.py 2012-07-23 07:27:31 +0000
276@@ -123,4 +123,16 @@
277 vals['magento_ref'] = order.magento_ref
278 return vals
279
280+ def _apply_payment_settings(self, cr, uid, order, paid, context=None):
281+ """We should deactivate need_to_update to avoid to query magento
282+ on each import of orders and not to mislead the users if they use
283+ a filter on need_to_update.
284+ """
285+ res = super(sale_order, self)._apply_payment_settings(cr, uid, order,
286+ paid, context=context)
287+ payment_settings = order.base_payment_type_id
288+ if payment_settings and payment_settings.allow_magento_manual_invoice:
289+ self.write(cr, uid, order.id, {'need_to_update': False}, context=context)
290+ return res
291+
292 sale_order()