Merge lp:~magentoerpconnect-community/magentoerpconnect/legacy61-fix-1011463 into lp:magentoerpconnect/oerp6.1-oldstable

Proposed by Guewen Baconnier @ Camptocamp
Status: Merged
Merge reported by: Guewen Baconnier @ Camptocamp
Merged at revision: not available
Proposed branch: lp:~magentoerpconnect-community/magentoerpconnect/legacy61-fix-1011463
Merge into: lp:magentoerpconnect/oerp6.1-oldstable
Diff against target: 39 lines (+12/-3)
1 file modified
magentoerpconnect/sale.py (+12/-3)
To merge this branch: bzr merge lp:~magentoerpconnect-community/magentoerpconnect/legacy61-fix-1011463
Reviewer Review Type Date Requested Status
Alexandre Fayolle - camptocamp code review Approve
Review via email: mp+109574@code.launchpad.net

Description of the change

To post a comment you must log in.
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

looks good to me.

review: Approve (code review)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'magentoerpconnect/sale.py'
2--- magentoerpconnect/sale.py 2012-05-25 09:01:25 +0000
3+++ magentoerpconnect/sale.py 2012-06-11 08:05:33 +0000
4@@ -418,6 +418,7 @@
5 @param data_record: full data dict of the order
6 @param ext_field: name of the field in data_record where the amount of the extra lineis stored
7 @param product_ref: tuple with module and xml_id (module, xml_id) of the product to use for the extra line
8+ or id as int/long of the product
9
10 Optional arguments in context:
11 sign: multiply the amount with the sign to add or substract it from the sale order
12@@ -430,7 +431,10 @@
13 ext_tax_field = 'ext_tax_field' in context and context['ext_tax_field'] or None
14 ext_code_field = 'ext_code_field' in context and context['ext_code_field'] or None
15
16- model, product_id = model_data_obj.get_object_reference(cr, uid, *product_ref)
17+ if isinstance(product_ref, tuple):
18+ dummy, product_id = model_data_obj.get_object_reference(cr, uid, *product_ref)
19+ else:
20+ product_id = product_ref
21 product = self.pool.get('product.product').browse(cr, uid, product_id, context)
22 is_tax_included = context.get('price_is_tax_included', False)
23 amount = float(data_record[ext_field]) * sign
24@@ -473,8 +477,13 @@
25 ctx.update({
26 'ext_tax_field': 'shipping_tax_amount',
27 })
28- product_ref = ('base_sale_multichannels', 'product_product_shipping')
29- res = self.add_order_extra_line(cr, uid, res, data_record, 'shipping_amount', product_ref, defaults, ctx)
30+ product = False
31+ if res.get('carrier_id'):
32+ carrier = self.pool.get('delivery.carrier').browse(cr, uid, res['carrier_id'], context=context)
33+ product = carrier.product_id.id
34+ else:
35+ product = ('base_sale_multichannels', 'product_product_shipping')
36+ res = self.add_order_extra_line(cr, uid, res, data_record, 'shipping_amount', product, defaults, ctx)
37 return res
38
39 def add_gift_certificates(self, cr, uid, res, external_referential_id, data_record, defaults, context=None):