Merge lp:~sebastien.beau/magentoerpconnect/oerp6.1-stable-minor-improvement into lp:magentoerpconnect/oerp6.1-stable

Proposed by Sébastien BEAU - http://www.akretion.com
Status: Needs review
Proposed branch: lp:~sebastien.beau/magentoerpconnect/oerp6.1-stable-minor-improvement
Merge into: lp:magentoerpconnect/oerp6.1-stable
Diff against target: 224 lines (+63/-28)
10 files modified
magentoerpconnect/delivery.py (+3/-2)
magentoerpconnect/invoice.py (+1/-1)
magentoerpconnect/magerp_osv.py (+3/-1)
magentoerpconnect/sale.py (+32/-3)
magentoerpconnect/settings/1.5.0.0/external.mapping.template.csv (+1/-1)
magentoerpconnect/settings/1.5.0.0/sale.order/external.mappinglines.template.csv (+0/-10)
magentoerpconnect/stock.py (+3/-0)
magentoerpconnect_bundle_split/sale.py (+6/-6)
magentoerpconnect_magento_invoice/account.py (+14/-3)
magentoerpconnect_product_variant/settings/1.5.0.0/external.mappinglines.template.csv (+0/-1)
To merge this branch: bzr merge lp:~sebastien.beau/magentoerpconnect/oerp6.1-stable-minor-improvement
Reviewer Review Type Date Requested Status
MagentoERPConnect core editors Pending
Review via email: mp+168270@code.launchpad.net
To post a comment you must log in.
699. By Sébastien BEAU - http://www.akretion.com

[IMP] magentoerpconnect: to support more kind of filter when doing a search check if the filter is not already a list/tupple if it's the case then we do not put the list in a list

Unmerged revisions

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

[IMP] magentoerpconnect: to support more kind of filter when doing a search check if the filter is not already a list/tupple if it's the case then we do not put the list in a list

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

[MERGE] merge with stable and solve conflict

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

[FIX] magentoerpconnect_product_variant: remove broken mapping

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

[FIX] magentoerpconnect_magento_invoice: fix the invoice date, it should be the same in the to system

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

[FIX] magentoerpconnect_bundle_split: fix indentation

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

[IMP] complete mapping for invoice

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

[IMP] improve message error when carrier method have an invalid magento code

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

[REF] refactor the carrier mapping, move it out of the mapping and replace it by a python function. It's more simple to overwrite. This is needed for exemple for the delivery module connected to the French carrier

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

[FIX] magentoerpconnect: fix import of order without shipping address

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

[FIX] remove useless "space"

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'magentoerpconnect/delivery.py'
2--- magentoerpconnect/delivery.py 2012-08-21 15:34:50 +0000
3+++ magentoerpconnect/delivery.py 2013-06-09 02:36:28 +0000
4@@ -63,10 +63,11 @@
5 _("Error"),
6 _("The carrier %s doesn't have a magento_code valid !"
7 "The value %s is not in the carrier list %s "
8- "allowed by Magento") %
9+ "allowed by Magento. Please fix it before trying"
10+ " to export again the picking %s") %
11 (carrier['name'],
12 carrier['magento_carrier_code'],
13- mag_carrier.keys()))
14+ mag_carrier.keys(),context['picking_name']))
15 return True
16 delivery_carrier()
17
18
19=== modified file 'magentoerpconnect/invoice.py'
20--- magentoerpconnect/invoice.py 2012-12-03 15:05:27 +0000
21+++ magentoerpconnect/invoice.py 2013-06-09 02:36:28 +0000
22@@ -138,7 +138,7 @@
23 context=context)
24
25 def export_invoice(self, cr, uid, ids, context=None):
26- for invoice in self .browse(cr, uid, ids, context=context):
27+ for invoice in self.browse(cr, uid, ids, context=context):
28 self._export_one_invoice(cr, uid, invoice, context=context)
29 return True
30
31
32=== modified file 'magentoerpconnect/magerp_osv.py'
33--- magentoerpconnect/magerp_osv.py 2012-08-21 15:34:50 +0000
34+++ magentoerpconnect/magerp_osv.py 2013-06-09 02:36:28 +0000
35@@ -93,7 +93,9 @@
36 raise except_osv(_('User Error'),
37 _('There is no "List Method" configured on the mapping %s') %
38 mapping[mapping_id]['model'])
39- return external_session.connection.call(search_read_method, [resource_filter or {}])
40+ if not type(resource_filter) in [list, tuple]:
41+ resource_filter = [resource_filter or {}]
42+ return external_session.connection.call(search_read_method, resource_filter)
43
44 Model._get_external_resources = _get_external_resources
45
46
47=== modified file 'magentoerpconnect/sale.py'
48--- magentoerpconnect/sale.py 2013-05-13 11:36:53 +0000
49+++ magentoerpconnect/sale.py 2013-06-09 02:36:28 +0000
50@@ -428,11 +428,37 @@
51 local_defaults[address_key]['partner_id'] = partner_id
52 return local_defaults
53
54+ def get_magento_carrier_info(self, cr, uid, resource, context=None):
55+ if 'shipping_method' in resource:
56+ method = resource['shipping_method']
57+ carrier_obj = self.pool['delivery.carrier']
58+ partner_obj = self.pool['res.partner']
59+ carrier_ids = carrier_obj.search(cr, uid, [
60+ ('magento_code', '=', method)
61+ ], context=context)
62+ if carrier_ids:
63+ carrier_id = carrier_ids[0]
64+ else:
65+ fake_partner_id = partner_obj.search(cr, uid, [])[0]
66+ model_data_obj = self.pool['ir.model.data']
67+ model, product_id = model_data_obj.get_object_reference(cr, uid,
68+ 'base_sale_multichannels', 'product_product_shipping')
69+ carrier_id = carrier_obj.create(cr, uid, {
70+ 'partner_id': fake_partner_id,
71+ 'product_id': product_id,
72+ 'name': method,
73+ 'magento_code': method,
74+ }, context=context)
75+ return {'carrier_id': carrier_id}
76+ return {}
77+
78 @only_for_referential('magento')
79 def _transform_one_resource(self, cr, uid, external_session, convertion_type, resource, mapping, mapping_id, \
80 mapping_line_filter_ids=None, parent_data=None, previous_result=None, defaults=None, context=None):
81 resource = self.clean_magento_resource(cr, uid, resource, context=context)
82 resource = self.clean_magento_items(cr, uid, resource, context=context)
83+ result = self.get_magento_carrier_info(cr, uid, resource, context=context)
84+
85 for line in mapping[mapping_id]['mapping_lines']:
86 if line['name'] == 'customer_id' and not resource.get('customer_id'):
87 #If there is not partner it's a guest order
88@@ -445,9 +471,12 @@
89 resource['shipping_address'].pop('customer_id', None)
90 defaults = self.create_onfly_partner(cr, uid, external_session, resource, mapping, defaults, context=context)
91
92- return super(sale_order, self)._transform_one_resource(cr, uid, external_session, convertion_type, resource,\
93+ result.update(super(sale_order, self)._transform_one_resource(cr, uid, external_session, convertion_type, resource,\
94 mapping, mapping_id, mapping_line_filter_ids=mapping_line_filter_ids, parent_data=parent_data,\
95- previous_result=previous_result, defaults=defaults, context=context)
96+ previous_result=previous_result, defaults=defaults, context=context))
97+ return result
98+
99+
100
101 @only_for_referential('magento')
102 def _get_external_resource_ids(self, cr, uid, external_session, resource_filter=None, mapping=None, mapping_id=None, context=None):
103@@ -617,7 +646,7 @@
104 else:
105 if not resource['billing_address'].get('customer_id'):
106 resource['billing_address']['customer_id'] = resource['customer_id']
107- if not resource['shipping_address'].get('customer_id'):
108+ if resource['shipping_address'] and not resource['shipping_address'].get('customer_id'):
109 resource['shipping_address']['customer_id'] = resource['customer_id']
110 return resource
111
112
113=== modified file 'magentoerpconnect/settings/1.5.0.0/external.mapping.template.csv'
114--- magentoerpconnect/settings/1.5.0.0/external.mapping.template.csv 2012-05-19 11:35:11 +0000
115+++ magentoerpconnect/settings/1.5.0.0/external.mapping.template.csv 2013-06-09 02:36:28 +0000
116@@ -12,5 +12,5 @@
117 mag1500_res_partner,,magentoerpconnect.magento1500,account.model_res_partner,customer.list,customer.info,customer.update,customer.create,,,,customer_id,
118 mag1500_sale_shop,,magentoerpconnect.magento1500,base_sale_multichannels.model_sale_shop,ol_groups.list,,,,,,,group_id,
119 mag1500_sale_order,,magentoerpconnect.magento1500,base_sale_multichannels.model_sale_order,sales_order.list,sales_order.info,,,,sales_order.search,sales_order.done,increment_id,
120-mag1500_account_invoice,,magentoerpconnect.magento1500,account.model_account_invoice,,,,,,,,,
121+mag1500_account_invoice,,magentoerpconnect.magento1500,account.model_account_invoice,,order_invoice.info,,,,,,,
122 mag1500_product_link,,magentoerpconnect.magento1500,magentoerpconnect.model_product_link,,,,,,,,,
123
124=== modified file 'magentoerpconnect/settings/1.5.0.0/sale.order/external.mappinglines.template.csv'
125--- magentoerpconnect/settings/1.5.0.0/sale.order/external.mappinglines.template.csv 2013-02-26 12:15:30 +0000
126+++ magentoerpconnect/settings/1.5.0.0/sale.order/external.mappinglines.template.csv 2013-06-09 02:36:28 +0000
127@@ -18,16 +18,6 @@
128 ",,,
129 mag1500_sale_order_gift_certificates_amount=>,,in,function,giftcert_amount,,float,False,mag1500_sale_order,gift_certificates_amount,"result=[('gift_certificates_amount', ifield)]",,,
130 mag1500_sale_order_gift_certificates_code=>,,in,function,giftcert_code,,unicode,False,mag1500_sale_order,gift_certificates_code,"result = [('gift_certificates_code', ifield)]",,,
131-mag1500_sale_order_carrier_id=>,,in,function,shipping_method,,unicode,False,mag1500_sale_order,carrier_id,"if ifield:
132- carrier_ids = self.pool.get('delivery.carrier').search(cr, uid, [('magento_code', '=', ifield)])
133- if carrier_ids:
134- result=[('carrier_id', carrier_ids[0])]
135- else:
136- fake_partner_id = self.pool.get('res.partner').search(cr, uid, [])[0]
137- model_data_obj = self.pool.get('ir.model.data')
138- model, product_id = model_data_obj.get_object_reference(cr, uid, 'base_sale_multichannels', 'product_product_shipping')
139- carrier_id = self.pool.get('delivery.carrier').create(cr, uid, {'partner_id' : fake_partner_id, 'product_id' : product_id, 'name' : ifield, 'magento_code' : ifield})
140- result=[('carrier_id', carrier_id)]",,,
141 mag1500_sale_order_shipping_amount_tax_included=>,,in,function,base_shipping_incl_tax,,float,False,mag1500_sale_order,shipping_amount_tax_included,"amount_tax_inc = float(resource.get('base_shipping_incl_tax', 0.0)) - float(resource.get('shipping_discount_amount', 0.0))
142 amount_tax_exc = float(resource.get('shipping_amount', 0))
143
144
145=== modified file 'magentoerpconnect/stock.py'
146--- magentoerpconnect/stock.py 2013-01-29 08:13:16 +0000
147+++ magentoerpconnect/stock.py 2013-06-09 02:36:28 +0000
148@@ -86,6 +86,9 @@
149 carrier_id = carrier_id[0]
150
151 if carrier_id and picking.carrier_tracking_ref:
152+ if context is None: context = {}
153+ picking = self.browse(cr, uid, id, context=context)
154+ context['picking_name'] = picking.name
155 self.pool.get('delivery.carrier').check_ext_carrier_reference(
156 cr, uid, carrier_id, magento_incrementid, context)
157
158
159=== modified file 'magentoerpconnect_bundle_split/sale.py'
160--- magentoerpconnect_bundle_split/sale.py 2012-10-08 15:55:39 +0000
161+++ magentoerpconnect_bundle_split/sale.py 2013-06-09 02:36:28 +0000
162@@ -51,12 +51,12 @@
163 def oe_create(self, cr, uid,
164 external_session, vals, resource, defaults, context):
165
166- order_id = super(sale_order, self).\
167- oe_create(cr, uid, external_session,
168- vals,
169- resource,
170- defaults=defaults,
171- context=context)
172+ order_id = super(sale_order, self).\
173+ oe_create(cr, uid, external_session,
174+ vals,
175+ resource,
176+ defaults=defaults,
177+ context=context)
178
179 order_line_obj = self.pool.get('sale.order.line')
180 order = self.browse(cr, uid, order_id, context=context)
181
182=== modified file 'magentoerpconnect_magento_invoice/account.py'
183--- magentoerpconnect_magento_invoice/account.py 2012-08-30 08:39:41 +0000
184+++ magentoerpconnect_magento_invoice/account.py 2013-06-09 02:36:28 +0000
185@@ -21,15 +21,26 @@
186
187
188 from openerp.osv.orm import Model
189+from base_external_referentials.external_osv import ExternalSession
190
191 class account_invoice(Model):
192 _inherit = "account.invoice"
193
194+ def _get_magento_invoice_date(self, cr, uid, invoice, ext_invoice_id, context=None):
195+ external_session = ExternalSession(invoice.shop_id.referential_id, invoice.shop_id)
196+ resource = self._get_external_resources(cr, uid, external_session, external_id=ext_invoice_id)
197+ return resource['created_at'].split(' ')[0]
198+
199 def action_move_create(self, cr, uid, ids, context=None):
200 if context is None:
201 context = {'lang': 'en_US'}
202 for invoice in self.browse(cr, uid, ids, context=context):
203- ext_invoice_id = self._export_one_invoice(cr, uid, invoice, context=context)
204- invoice.write({'internal_number': ext_invoice_id}, context=context)
205+ if not invoice.internal_number and invoice.type == 'out_invoice'\
206+ and invoice.sale_ids and invoice.sale_ids[0].shop_id.type_name == 'Magento':
207+ ext_invoice_id = self._export_one_invoice(cr, uid, invoice, context=context)
208+ date_invoice = self._get_magento_invoice_date(cr, uid, invoice, ext_invoice_id, context=context)
209+ invoice.write({
210+ 'internal_number': ext_invoice_id,
211+ 'date_invoice': date_invoice,
212+ }, context=context)
213 return super(account_invoice, self).action_move_create(cr, uid, ids, context=context)
214-
215
216=== modified file 'magentoerpconnect_product_variant/settings/1.5.0.0/external.mappinglines.template.csv'
217--- magentoerpconnect_product_variant/settings/1.5.0.0/external.mappinglines.template.csv 2012-05-09 15:36:12 +0000
218+++ magentoerpconnect_product_variant/settings/1.5.0.0/external.mappinglines.template.csv 2013-06-09 02:36:28 +0000
219@@ -1,5 +1,4 @@
220 id,sequence,type,evaluation_type,external_field,field_id:id,external_type,alternative_key,mapping_id:id,function_name,in_function,out_function,child_mapping_id:id,datetime_format
221-magentoerpconnect.mag1500_product_product_weight,,in_out,direct,weight,product_variant_multi.field_product_product_total_weight,float,False,magentoerpconnect.mag1500_product_product,,,,,
222 mag1500_product_product_dim_value,10,out,function,,,unicode,False,magentoerpconnect.mag1500_product_product,dim_value,,"result = []
223 if resource.get('is_multi_variants'):
224 for dim_value in self.pool.get('product.variant.dimension.value').browse(cr, uid, resource['dimension_value_ids'], context=context):