Merge lp:~gbaconnier-c2c/magentoerpconnect/magentoerpconnectv6-c2c into lp:magentoerpconnect/oerp6.0-stable

Proposed by Guewen Baconnier @ Camptocamp
Status: Merged
Merge reported by: Guewen Baconnier @ Camptocamp
Merged at revision: not available
Proposed branch: lp:~gbaconnier-c2c/magentoerpconnect/magentoerpconnectv6-c2c
Merge into: lp:magentoerpconnect/oerp6.0-stable
Diff against target: 412 lines (+180/-68)
6 files modified
magerp_data.xml (+22/-2)
product.py (+54/-19)
product_view.xml (+3/-0)
sale.py (+75/-40)
settings/external.mappinglines.template.csv (+9/-3)
stock.py (+17/-4)
To merge this branch: bzr merge lp:~gbaconnier-c2c/magentoerpconnect/magentoerpconnectv6-c2c
Reviewer Review Type Date Requested Status
Raphaël Valyi - http://www.akretion.com Pending
Review via email: mp+55476@code.launchpad.net

Description of the change

Hi,

Here is some proposal for the connector.

Revno 396: (Rationalized import of extra sales orders lines like shipping, discount, cash on delivery,... into one single method instead of a method for each one.)
On the sale order's creation, there's a method to add shipping fees. A new method appears to add gift certificates, and there is still the case of the discount coupons and the cash on delivery fees (and maybe other fees/rebates).
The behavior is the same for each of them : get the amount in the magento's data, get a product, get a tax if a tax amount is found in the magento's data and add the line to the order.
That's why instead of having 4 methods doing nearly the same things, I propose you to use the same.
I couldn't test the gift certificate and cash on delivery because I have not them on Magento, but the shipping and discount coupons are ok. I'm also not sure with my methods definitions (I first started with one method with a loop on each type and a dict to define types, but I think the version I propose here let more space for overridings) so don't put your priority on this proposal if you have not a lot of time.

Revno 398: (include_in_menu and page_layout attributes on product categories)
Configure these 2 magento's attributes from OpenERP.

Revno 399: (hooks and small refactoring to allow management of configurable products from a module)
We are going to release our module to manage configurable products very soon (as soon as you approve the hooks in magentoerpconnect in fact).
I added a hook in the method ext_export to export configurable products, the reason is clear.
A little more explanation why I modified the method create_ext_partial_shipping in stock.py :
When you order a configurable product in Magento, and do a "sales_order.info" on the API, it gives you 2 items : the configurable and the simple product. We put the configurable as a service, so it doesn't appear in the picking. But when you want to create the (partial) shipping on Magento, it expects the configurable and the simple product.
So I added the method "add_picking_line" which basically just add the line of the picking. But in our module, I do a super on that method and then I add a second line with the configurable product if so.

There is also a proposal on base_sale_multichannels in that branch :
https://code.launchpad.net/~gbaconnier-c2c/openobject-addons/extra-6.0-c2c-magento-improvements
revno 5352 : (base_sale_multichannels: configure a different payment term for each base_sale_payment_type)

Apply a payment term on sales orders based on payment types.

I'm open to change things that bother you.

Thanks !

Guewen

To post a comment you must log in.
400. By Guewen Baconnier @ CampToCamp <email address hidden>

[FIX] mapping for discount

Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote :

Seems Good Guewen!
Sebastien already merged the base_sale_multichannels thing and we will merge the other part as soon as we can. Thank you very much, always a pleasure to get all those improvements from CampToCamp.

401. By Guewen Baconnier @ CampToCamp <email address hidden>

[FIX] replaced options parameter by context

402. By Guewen Baconnier @ CampToCamp <email address hidden>

[IMP] translations on product categories

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Last commit enable the translations of product categories on stores.
It correct also this bug :
- If your Magento Instance is configured with a default language of "French" and someone with an english account launch the export of catalog, or it is launched by the cron, translations are english translation instead of using the good one.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'magerp_data.xml'
--- magerp_data.xml 2011-01-18 18:22:58 +0000
+++ magerp_data.xml 2011-04-11 07:44:24 +0000
@@ -14,7 +14,17 @@
14 <field name="standard_price">0.0</field>14 <field name="standard_price">0.0</field>
15 <field name="type">service</field>15 <field name="type">service</field>
16 <field name="name">Shipping and Handling</field>16 <field name="name">Shipping and Handling</field>
17 <field name="exportable" eval="False" />17 <field name="magento_exportable" eval="False" />
18 <field name="categ_id" ref="mag0"/>
19 </record>
20
21 <record id="product_product_cash_on_delivery" model="product.product">
22 <field name="default_code">CASH ON DELIVERY MAGENTO</field>
23 <field name="list_price">0.0</field>
24 <field name="standard_price">0.0</field>
25 <field name="type">service</field>
26 <field name="name">Cash on delivery</field>
27 <field name="magento_exportable" eval="False" />
18 <field name="categ_id" ref="mag0"/>28 <field name="categ_id" ref="mag0"/>
19 </record>29 </record>
2030
@@ -24,10 +34,20 @@
24 <field name="standard_price">0.0</field>34 <field name="standard_price">0.0</field>
25 <field name="type">service</field>35 <field name="type">service</field>
26 <field name="name">Gift Certificate</field>36 <field name="name">Gift Certificate</field>
27 <field name="exportable" eval="False" />37 <field name="magento_exportable" eval="False" />
28 <field name="categ_id" ref="mag0"/>38 <field name="categ_id" ref="mag0"/>
29 </record>39 </record>
3040
41 <record id="product_product_discount" model="product.product">
42 <field name="default_code">DISCOUNT MAGENTO</field>
43 <field name="list_price">0.0</field>
44 <field name="standard_price">0.0</field>
45 <field name="type">service</field>
46 <field name="name">Discount coupon</field>
47 <field name="magento_exportable" eval="False" />
48 <field name="categ_id" ref="mag0"/>
49 </record>
50
31 <record forcecreate="True" id="ir_cron_import_orders_scheduler_action" model="ir.cron">51 <record forcecreate="True" id="ir_cron_import_orders_scheduler_action" model="ir.cron">
32 <field name="name">Magento Import Orders</field>52 <field name="name">Magento Import Orders</field>
33 <field eval="False" name="active"/>53 <field eval="False" name="active"/>
3454
=== modified file 'product.py'
--- product.py 2011-03-10 10:36:25 +0000
+++ product.py 2011-04-11 07:44:24 +0000
@@ -75,13 +75,24 @@
75 ('name', 'Name'),75 ('name', 'Name'),
76 ('price', 'Price')76 ('price', 'Price')
77 ], 'Default Product Listing Sort (Sort By)'),77 ], 'Default Product Listing Sort (Sort By)'),
78 'magerp_stamp':fields.datetime('Magento stamp')78 'magerp_stamp':fields.datetime('Magento stamp'),
79 'include_in_menu': fields.boolean('Include in Navigation Menu'),
80 'page_layout': fields.selection([
81 ('None', 'No layout updates'),
82 ('empty', 'Empty'),
83 ('one_column', '1 column'),
84 ('two_columns_left', '2 columns with left bar'),
85 ('two_columns_right', '2 columns with right bar'),
86 ('three_columns', '3 columns'),
87 ], 'Page Layout'),
79 }88 }
80 _defaults = {89 _defaults = {
81 'display_mode':lambda * a:'PRODUCTS',90 'display_mode':lambda * a:'PRODUCTS',
82 'available_sort_by':lambda * a:'None',91 'available_sort_by':lambda * a:'None',
83 'default_sort_by':lambda * a:'None',92 'default_sort_by':lambda * a:'None',
84 'level':lambda * a:193 'level':lambda * a:1,
94 'include_in_menu': lambda * a:True,
95 'page_layout': lambda * a:'None'
85 }96 }
86 97
87 def write(self, cr, uid, ids, vals, context=None):98 def write(self, cr, uid, ids, vals, context=None):
@@ -114,27 +125,45 @@
114 ids = [id for id in ids if id in ids_exportable] #we need to kept the order of the categories125 ids = [id for id in ids if id in ids_exportable] #we need to kept the order of the categories
115 126
116 shop = self.pool.get('sale.shop').browse(cr, uid, context['shop_id'])127 shop = self.pool.get('sale.shop').browse(cr, uid, context['shop_id'])
117 128
129 context_dic = [context.copy()]
130 context_dic[0]['export_url'] = True # for the magento version 1.3.2.4, only one url is autorized by category, so we only export with the MAPPING TEMPLATE the url of the default language
131 context_dic[0]['lang'] = shop.referential_id.default_lang_id.code
132
133 for storeview in shop.storeview_ids:
134 if storeview.lang_id and storeview.lang_id.code != shop.referential_id.default_lang_id.code:
135 context_dic += [context.copy()]
136 context_dic[len(context_dic)-1].update({'storeview_code': storeview.code, 'lang': storeview.lang_id.code})
137
118 if shop.last_products_export_date:138 if shop.last_products_export_date:
119 last_exported_time = datetime.datetime.fromtimestamp(time.mktime(time.strptime(shop.last_products_export_date, '%Y-%m-%d %H:%M:%S')))139 last_exported_time = datetime.datetime.fromtimestamp(time.mktime(time.strptime(shop.last_products_export_date, '%Y-%m-%d %H:%M:%S')))
120 else:140 else:
121 last_exported_time = False141 last_exported_time = False
122 142
123 cr.execute("select write_date, create_date from product_category where id in %s", (tuple(ids),))143 if not last_exported_time:
124 read = cr.fetchall()144 for ctx_storeview in context_dic:
125 for categ in read:145 ctx_storeview['force'] = True
126 last_updated_categ = categ[0] and categ[0].split('.')[0] or categ[1] and categ[1].split('.')[0] or False146 res = super(product_category, self).ext_export(cr, uid, ids, external_referential_ids, defaults, ctx_storeview)
127 last_updated_categ_time = datetime.datetime.fromtimestamp(time.mktime(time.strptime(last_updated_categ, '%Y-%m-%d %H:%M:%S')))147 else:
128 if last_updated_categ_time and last_exported_time:148 cr.execute("select write_date, create_date from product_category where id in %s", (tuple(ids),))
129 if last_exported_time - datetime.timedelta(seconds=1) < last_updated_categ_time:149 read = cr.fetchall()
130 context['force'] = True150 for categ in read:
131 res = super(product_category, self).ext_export(cr, uid, ids, external_referential_ids, defaults, context)151 last_updated_categ = categ[0] and categ[0].split('.')[0] or categ[1] and categ[1].split('.')[0] or False
132 break152 last_updated_categ_time = datetime.datetime.fromtimestamp(time.mktime(time.strptime(last_updated_categ, '%Y-%m-%d %H:%M:%S')))
133 if not res:153 if last_updated_categ_time and last_exported_time:
134 context['force'] = True154 if last_exported_time - datetime.timedelta(seconds=1) < last_updated_categ_time:
135 res = super(product_category, self).ext_export(cr, uid, ids, external_referential_ids, defaults, context)155 for ctx_storeview in context_dic:
156 ctx_storeview['force'] = True
157 res = super(product_category, self).ext_export(cr, uid, ids, external_referential_ids, defaults, ctx_storeview)
158 break
136 return res159 return res
137 160
161 def try_ext_update(self, cr, uid, data, conn, method, oe_id, external_id, ir_model_data_id, create_method, context):
162 if context.get('storeview_code', False):
163 return conn.call(method, [external_id, data, context.get('storeview_code', False)])
164 else:
165 return conn.call(method, [external_id, data])
166
138product_category()167product_category()
139168
140169
@@ -899,7 +928,10 @@
899 res = super(magerp_osv.magerp_osv, self).ext_create(cr, uid, [product_type, attr_set_id, sku, data], conn, method, oe_id, context)928 res = super(magerp_osv.magerp_osv, self).ext_create(cr, uid, [product_type, attr_set_id, sku, data], conn, method, oe_id, context)
900 self.write(cr, uid, oe_id, {'magento_sku': sku})929 self.write(cr, uid, oe_id, {'magento_sku': sku})
901 return res930 return res
902 931
932 def ext_export_configurable(self, cr, uid, id, external_referential_ids=None, defaults=None, context=None):
933 raise osv.except_osv(_("Not Implemented"), _("Configurable products are not implemented."))
934
903 def ext_export(self, cr, uid, ids, external_referential_ids=None, defaults=None, context=None):935 def ext_export(self, cr, uid, ids, external_referential_ids=None, defaults=None, context=None):
904 if context is None:936 if context is None:
905 context = {}937 context = {}
@@ -999,6 +1031,8 @@
999 self.ext_export(cr, uid, child_ids, external_referential_ids, defaults, context) #so we export them1031 self.ext_export(cr, uid, child_ids, external_referential_ids, defaults, context) #so we export them
1000 else:1032 else:
1001 logger.notifyChannel('ext synchro', netsvc.LOG_ERROR, "OpenERP 'grouped' products will export to Magento as 'grouped products' only if they have a BOM and if the 'mrp' BOM module is installed")1033 logger.notifyChannel('ext synchro', netsvc.LOG_ERROR, "OpenERP 'grouped' products will export to Magento as 'grouped products' only if they have a BOM and if the 'mrp' BOM module is installed")
1034 elif product_type == 'configurable':
1035 self.ext_export_configurable(cr, uid, id, external_referential_ids, defaults, context)
1002 for context_storeview in context_dic:1036 for context_storeview in context_dic:
1003 temp_result = super(magerp_osv.magerp_osv, self).ext_export(cr, uid, [id], external_referential_ids, defaults, context_storeview)1037 temp_result = super(magerp_osv.magerp_osv, self).ext_export(cr, uid, [id], external_referential_ids, defaults, context_storeview)
1004 if child_ids: 1038 if child_ids:
@@ -1030,6 +1064,7 @@
1030 is_in_stock = int(virtual_available > 0)1064 is_in_stock = int(virtual_available > 0)
1031 context['conn_obj'].call('product_stock.update', [product.magento_sku, {'qty': virtual_available, 'is_in_stock': is_in_stock}])1065 context['conn_obj'].call('product_stock.update', [product.magento_sku, {'qty': virtual_available, 'is_in_stock': is_in_stock}])
1032 logger.notifyChannel('ext synchro', netsvc.LOG_INFO, "Successfully updated stock level at %s for product with SKU %s " %(virtual_available, product.magento_sku))1066 logger.notifyChannel('ext synchro', netsvc.LOG_INFO, "Successfully updated stock level at %s for product with SKU %s " %(virtual_available, product.magento_sku))
1067 return True
10331068
1034 def ext_grouped_product_assign(self, cr, uid, parent_id, child_ids, quantities, context):1069 def ext_grouped_product_assign(self, cr, uid, parent_id, child_ids, quantities, context):
1035 logger = netsvc.Logger()1070 logger = netsvc.Logger()
10361071
=== modified file 'product_view.xml'
--- product_view.xml 2011-03-18 16:31:46 +0000
+++ product_view.xml 2011-04-11 07:44:24 +0000
@@ -22,6 +22,7 @@
22 <field name="meta_description" colspan="2" />22 <field name="meta_description" colspan="2" />
23 <field name="url_key" colspan="2" />23 <field name="url_key" colspan="2" />
24 <field name="level" colspan="2" />24 <field name="level" colspan="2" />
25 <field name="include_in_menu" colspan="2" />
25 </group>26 </group>
26 <group col="1" colspan="1">27 <group col="1" colspan="1">
27 <separator string="Category Image" />28 <separator string="Category Image" />
@@ -51,6 +52,8 @@
51 <separator string="Sorting method" colspan="4" />52 <separator string="Sorting method" colspan="4" />
52 <field name="available_sort_by" />53 <field name="available_sort_by" />
53 <field name="default_sort_by" />54 <field name="default_sort_by" />
55 <separator string="Page Layout" colspan="4" />
56 <field name="page_layout" nolabel="1" />
54 </page>57 </page>
55 </notebook>58 </notebook>
56 </group>59 </group>
5760
=== modified file 'sale.py'
--- sale.py 2011-04-02 14:58:57 +0000
+++ sale.py 2011-04-11 07:44:24 +0000
@@ -384,49 +384,83 @@
384 res['order_line'] = lines_vals384 res['order_line'] = lines_vals
385 return res385 return res
386386
387 def add_gift_certificates(self, cursor, user, order_values, 387 def add_order_extra_line(self, cr, uid, res, data_record, ext_field, product_code, context):
388 magento_order_data, context):388 """ Add or substract amount on order as a separate line item with single quantity for each type of amounts like :
389 '''Add gift certificate as a separate line item with single quantity 389 shipping, cash on delivery, discount, gift certificates...
390 and negative amount. Known to work with Unigry gift certificates also390 Arguments :
391 '''391 ext_field: name of the field in data_record where the amount is stored
392 product_obj = self.pool.get('product.product')392 product_code: code of the product to use in the sale order line
393 if ('giftcert_amount' in magento_order_data) and \393 Optional arguments in kwargs:
394 (float(magento_order_data.get('giftcert_amount', 0)) > 0):394 sign: multiply the amount with the sign to add or substract it from the sale order
395 gift_product_ids = product_obj.search(cursor, user, 395 ext_tax_field: name of the field in data_record where the tax amount is stored
396 [('default_code', '=', 'GIFT CERTIFICATE')], context=context)396 ext_code_field: name of the field in data_record containing a code (for coupons and gift certificates) which will be printed on the product name
397 if gift_product_ids:397 """
398 gift_product = product_obj.browse(398 sign = 'sign' in context and context['sign'] or 1
399 cursor, user, gift_product_ids[0], context)399 ext_tax_field = 'ext_tax_field' in context and context['ext_tax_field'] or None
400 gift_cert_code = magento_order_data['giftcert_code']400 ext_code_field = 'ext_code_field' in context and context['ext_code_field'] or None
401 order_values['order_line'].append((0, 0, {401
402 'product_id': gift_product.id,402 product_id = self.pool.get('product.product').search(cr, uid, [('default_code', '=', product_code)])[0]
403 'name': 'Gift Certificate %s' % gift_cert_code,403 product = self.pool.get('product.product').browse(cr, uid, product_id, context)
404 'product_uom': gift_product.uom_id.id,404 amount = float(data_record[ext_field]) * sign
405 'product_uom_qty': 1,405
406 'price_unit': -float(magento_order_data['giftcert_amount']),
407 }))
408 return order_values
409
410 def get_order_shipping(self, cr, uid, res, external_referential_id, data_record, key_field, mapping_lines, defaults, context):
411 ship_product_id = self.pool.get('product.product').search(cr, uid, [('default_code', '=', 'SHIP MAGENTO')])[0]
412 ship_product = self.pool.get('product.product').browse(cr, uid, ship_product_id, context)
413
414 #simple VAT tax on shipping (else override method):
415 tax_id = []406 tax_id = []
416 if data_record['shipping_tax_amount'] and float(data_record['shipping_tax_amount']) != 0:407 if ext_tax_field:
417 ship_tax_vat = float(data_record['shipping_tax_amount'])/float(data_record['shipping_amount'])408 if data_record[ext_tax_field] and float(data_record[ext_tax_field]) != 0:
418 ship_tax_ids = self.pool.get('account.tax').search(cr, uid, [('type_tax_use', '=', 'sale'), ('amount', '>=', ship_tax_vat - 0.001), ('amount', '<=', ship_tax_vat + 0.001)])409 tax_vat = abs(float(data_record[ext_tax_field]) / amount)
419 if ship_tax_ids and len(ship_tax_ids) > 0:410 tax_ids = self.pool.get('account.tax').search(cr, uid, [('type_tax_use', '=', 'sale'), ('amount', '>=', tax_vat - 0.001), ('amount', '<=', tax_vat + 0.001)])
420 tax_id = [(6, 0, [ship_tax_ids[0]])]411 if tax_ids and len(tax_ids) > 0:
412 tax_id = [(6, 0, [tax_ids[0]])]
413
414 name = product.name
415 if ext_code_field and data_record.get(ext_code_field, False):
416 name = "%s [%s]" % (name, data_record[ext_code_field])
417
421 res['order_line'].append((0, 0, {418 res['order_line'].append((0, 0, {
422 'product_id': ship_product.id,419 'product_id': product.id,
423 'name': ship_product.name,420 'name': name,
424 'product_uom': ship_product.uom_id.id,421 'product_uom': product.uom_id.id,
425 'product_uom_qty': 1,422 'product_uom_qty': 1,
426 'price_unit': float(data_record['shipping_amount']),423 'price_unit': amount,
427 'tax_id': tax_id424 'tax_id': tax_id
428 }))425 }))
429 return res426 return res
427
428 def add_order_shipping(self, cr, uid, res, external_referential_id, data_record, key_field, mapping_lines, defaults, context):
429 if data_record.get('shipping_amount', False) and float(data_record.get('shipping_amount', False)) > 0:
430 ctx = context.copy()
431 ctx.update({
432 'ext_tax_field': 'shipping_tax_amount',
433 })
434 res = self.add_order_extra_line(cr, uid, res, data_record, 'shipping_amount', 'SHIP MAGENTO', ctx)
435 return res
436
437 def add_gift_certificates(self, cr, uid, res, external_referential_id, data_record, key_field, mapping_lines, defaults, context):
438 if data_record.get('giftcert_amount', False) and float(data_record.get('giftcert_amount', False)) > 0:
439 ctx = context.copy()
440 ctx.update({
441 'ext_code_field': 'giftcert_code',
442 'sign': -1,
443 })
444 res = self.add_order_extra_line(cr, uid, res, data_record, 'giftcert_amount', 'GIFT CERTIFICATE', ctx)
445 return res
446
447 def add_discount(self, cr, uid, res, external_referential_id, data_record, key_field, mapping_lines, defaults, context):
448 if data_record.get('discount_amount', False) and float(data_record.get('discount_amount', False)) < 0:
449 ctx = context.copy()
450 ctx.update({
451 'ext_code_field': 'coupon_code',
452 })
453 res = self.add_order_extra_line(cr, uid, res, data_record, 'discount_amount', 'DISCOUNT MAGENTO', ctx)
454 return res
455
456 def add_cash_on_delivery(self, cr, uid, res, external_referential_id, data_record, key_field, mapping_lines, defaults, context):
457 if data_record.get('cod_fee', False) and float(data_record.get('cod_fee', False)) > 0:
458 ctx = context.copy()
459 ctx.update({
460 'ext_tax_field': 'cod_tax_amount',
461 })
462 res = self.add_order_extra_line(cr, uid, res, data_record, 'cod_fee', 'CASH ON DELIVERY MAGENTO', ctx)
463 return res
430 464
431 def oevals_from_extdata(self, cr, uid, external_referential_id, data_record, key_field, mapping_lines, defaults, context):465 def oevals_from_extdata(self, cr, uid, external_referential_id, data_record, key_field, mapping_lines, defaults, context):
432 if not context.get('one_by_one', False):466 if not context.get('one_by_one', False):
@@ -439,9 +473,10 @@
439 if data_record.get('items', False):473 if data_record.get('items', False):
440 try:474 try:
441 res = self.get_order_lines(cr, uid, res, external_referential_id, data_record, key_field, mapping_lines, defaults, context)475 res = self.get_order_lines(cr, uid, res, external_referential_id, data_record, key_field, mapping_lines, defaults, context)
442 if data_record.get('shipping_amount', False) and float(data_record.get('shipping_amount', False)) > 0:476 res = self.add_order_shipping(cr, uid, res, external_referential_id, data_record, key_field, mapping_lines, defaults, context)
443 res = self.get_order_shipping(cr, uid, res, external_referential_id, data_record, key_field, mapping_lines, defaults, context)477 res = self.add_gift_certificates(cr, uid, res, external_referential_id, data_record, key_field, mapping_lines, defaults, context)
444 res = self.add_gift_certificates(cr, uid, res, data_record, context)478 res = self.add_discount(cr, uid, res, external_referential_id, data_record, key_field, mapping_lines, defaults, context)
479 res = self.add_cash_on_delivery(cr, uid, res, external_referential_id, data_record, key_field, mapping_lines, defaults, context)
445 except Exception, e:480 except Exception, e:
446 print "order has errors with items lines, data are: ", data_record481 print "order has errors with items lines, data are: ", data_record
447 print e482 print e
448483
=== modified file 'settings/external.mappinglines.template.csv'
--- settings/external.mappinglines.template.csv 2010-12-14 21:01:23 +0000
+++ settings/external.mappinglines.template.csv 2011-04-11 07:44:24 +0000
@@ -35,7 +35,7 @@
35"mag_erp_soline_uomqty","magento1324","sale.model_sale_order_line","qty_ordered","in_out","str","result=[('product_uom_qty',ifield)]",35"mag_erp_soline_uomqty","magento1324","sale.model_sale_order_line","qty_ordered","in_out","str","result=[('product_uom_qty',ifield)]",
36"mag_erp_soline_uosqty","magento1324","sale.model_sale_order_line","qty_ordered","in","str","result=[('product_uos_qty',ifield)]",36"mag_erp_soline_uosqty","magento1324","sale.model_sale_order_line","qty_ordered","in","str","result=[('product_uos_qty',ifield)]",
37"mag_erp_soline_price","magento1324","sale.model_sale_order_line","price","in","str","result=[('price_unit', float(data['row_total'])/float(data['qty_ordered']))]",37"mag_erp_soline_price","magento1324","sale.model_sale_order_line","price","in","str","result=[('price_unit', float(data['row_total'])/float(data['qty_ordered']))]",
38"mag_erp_soline_disc","magento1324","sale.model_sale_order_line","discount_amount","in","str","result=[('discount', float(data['price']) != 0 and float(data['qty_ordered']) != 0 and float(100*float(ifield))/(float(data['price'])*float(data['qty_ordered'])) or 0)]",38"mag_erp_soline_disc","magento1324","sale.model_sale_order_line","discount_amount","in","str","result=[('discount', 0.0)]",
39"mag_erp_procat_2","magento1324","product.model_product_category","level","in","int","result=[('sequence',ifield),('level',ifield)]",39"mag_erp_procat_2","magento1324","product.model_product_category","level","in","int","result=[('sequence',ifield),('level',ifield)]",
40"mag_erp_procat_3","magento1324","product.model_product_category","parent_id","in_out","int","record_id = self.pool.get('ir.model.data').search(cr, uid, [('model', '=', self._name), ('name', '=', self.prefixed_id(ifield))])40"mag_erp_procat_3","magento1324","product.model_product_category","parent_id","in_out","int","record_id = self.pool.get('ir.model.data').search(cr, uid, [('model', '=', self._name), ('name', '=', self.prefixed_id(ifield))])
41parent_id = False41parent_id = False
@@ -46,7 +46,7 @@
46if record.get('parent_id',False):46if record.get('parent_id',False):
47 magento_parent_id = self.oeid_to_extid(cr, uid, record.get('parent_id')[0], external_referential_id)47 magento_parent_id = self.oeid_to_extid(cr, uid, record.get('parent_id')[0], external_referential_id)
48 if not magento_parent_id:48 if not magento_parent_id:
49 self.ext_export(cr,uid,[record.get('parent_id',[False])[0]],[external_referential_id],{},{'conn_obj':conn})49 self.ext_export(cr,uid,[record.get('parent_id',[False])[0]],[external_referential_id],{},context=context)
50 magento_parent_id = self.oeid_to_extid(cr, uid, record.get('parent_id')[0], external_referential_id)50 magento_parent_id = self.oeid_to_extid(cr, uid, record.get('parent_id')[0], external_referential_id)
51if magento_parent_id:51if magento_parent_id:
52 result = [('parent_id',magento_parent_id)]"52 result = [('parent_id',magento_parent_id)]"
@@ -55,7 +55,8 @@
55"mag_erp_procat_6","magento1324","product.model_product_category","meta_title","in_out","str","result=[('meta_title',ifield)]","result=[('meta_title',record['meta_title'])]"55"mag_erp_procat_6","magento1324","product.model_product_category","meta_title","in_out","str","result=[('meta_title',ifield)]","result=[('meta_title',record['meta_title'])]"
56"mag_erp_procat_7","magento1324","product.model_product_category","meta_keywords","in_out","str","result=[('meta_keywords',ifield)]","result=[('meta_keywords',record['meta_keywords'])]"56"mag_erp_procat_7","magento1324","product.model_product_category","meta_keywords","in_out","str","result=[('meta_keywords',ifield)]","result=[('meta_keywords',record['meta_keywords'])]"
57"mag_erp_procat_8","magento1324","product.model_product_category","meta_description","in_out","str","result=[('meta_description',ifield)]","result=[('meta_description',record['meta_description'])]"57"mag_erp_procat_8","magento1324","product.model_product_category","meta_description","in_out","str","result=[('meta_description',ifield)]","result=[('meta_description',record['meta_description'])]"
58"mag_erp_procat_9","magento1324","product.model_product_category","url_key","in_out","str","result=[('url_key',ifield)]","result=[('url_key',record['url_key'])]"58"mag_erp_procat_9","magento1324","product.model_product_category","url_key","in_out","str","result=[('url_key',ifield)]","if context.get('export_url', False) :
59 result=[('url_key',record['url_key'])]"
59"mag_erp_procat_10","magento1324","product.model_product_category","name","in_out","str","result=[('name',ifield or 'UNDEFINED'),('magento_exportable',True)]","result=[('name',record['name'])]"60"mag_erp_procat_10","magento1324","product.model_product_category","name","in_out","str","result=[('name',ifield or 'UNDEFINED'),('magento_exportable',True)]","result=[('name',record['name'])]"
60"mag_erp_procat_11","magento1324","product.model_product_category","is_anchor","in_out","str","result=[('is_anchor',ifield and bool(eval(ifield)) or False)]","result=[('is_anchor',record['is_anchor'])]"61"mag_erp_procat_11","magento1324","product.model_product_category","is_anchor","in_out","str","result=[('is_anchor',ifield and bool(eval(ifield)) or False)]","result=[('is_anchor',record['is_anchor'])]"
61"mag_erp_procat_12","magento1324","product.model_product_category","available_sort_by","in_out","str","result=[('available_sort_by',ifield)]","result=[('available_sort_by',record['available_sort_by'] or 'name')]"62"mag_erp_procat_12","magento1324","product.model_product_category","available_sort_by","in_out","str","result=[('available_sort_by',ifield)]","result=[('available_sort_by',record['available_sort_by'] or 'name')]"
@@ -77,6 +78,11 @@
77 result = [('image',record['image_name'])]78 result = [('image',record['image_name'])]
78else:79else:
79 result=[]"80 result=[]"
81"mag_erp_procat_16","magento1324","product.model_product_category","include_in_menu","in_out","str","result=[('include_in_menu', ifield and (eval(ifield)) or False)]","result=[('include_in_menu',record['include_in_menu'])]"
82"mag_erp_procat_17","magento1324","product.model_product_category","page_layout","in_out","str","if ifield:
83 result=[('page_layout',ifield)]
84else:
85 result=[('page_layout','None')]","result=[('page_layout', record['page_layout'] or '')]"
80"mag_erp_attrgrp_2","magento1324","model_magerp_product_attribute_groups","attribute_set_id","in_out","int","result=[('attribute_set_id', ifield)]","result=[('attribute_set_id', record['attribute_set_id'])]"86"mag_erp_attrgrp_2","magento1324","model_magerp_product_attribute_groups","attribute_set_id","in_out","int","result=[('attribute_set_id', ifield)]","result=[('attribute_set_id', record['attribute_set_id'])]"
81"mag_erp_attrgrp_3","magento1324","model_magerp_product_attribute_groups","attribute_group_name","in_out","str","result=[('attribute_group_name', ifield)]","result=[('attribute_group_name', record['attribute_group_name'])]"87"mag_erp_attrgrp_3","magento1324","model_magerp_product_attribute_groups","attribute_group_name","in_out","str","result=[('attribute_group_name', ifield)]","result=[('attribute_group_name', record['attribute_group_name'])]"
82"mag_erp_attrgrp_4","magento1324","model_magerp_product_attribute_groups","sort_order","in_out","int","result=[('sort_order', ifield)]","result=[('sort_order', record['sort_order'])]"88"mag_erp_attrgrp_4","magento1324","model_magerp_product_attribute_groups","sort_order","in_out","int","result=[('sort_order', ifield)]","result=[('sort_order', record['sort_order'])]"
8389
=== modified file 'stock.py'
--- stock.py 2010-11-15 20:46:10 +0000
+++ stock.py 2011-04-11 07:44:24 +0000
@@ -35,8 +35,15 @@
35 ext_shipping_id = conn.call('sales_order_shipment.create', [magento_incrementid, {}, _("Shipping Created"), True, True])35 ext_shipping_id = conn.call('sales_order_shipment.create', [magento_incrementid, {}, _("Shipping Created"), True, True])
36 except Exception, e:36 except Exception, e:
37 logger.notifyChannel(_("Magento Call"), netsvc.LOG_ERROR, _("The picking from the order %s can't be created on Magento, please attach it manually, %s") % (magento_incrementid, e))37 logger.notifyChannel(_("Magento Call"), netsvc.LOG_ERROR, _("The picking from the order %s can't be created on Magento, please attach it manually, %s") % (magento_incrementid, e))
38 return ext_shipping_id 38 return ext_shipping_id
3939
40 def add_picking_line(self, cr, uid, lines, picking_line, context):
41 """ A line to add in the shipping is a dict with : product_id and product_qty keys."""
42 line_info = {'product_id': picking_line.product_id.id,
43 'product_qty': picking_line.product_qty,
44 }
45 lines.append(line_info)
46 return lines
4047
41 def create_ext_partial_shipping(self, cr, uid, id, external_referential_id, magento_incrementid, context):48 def create_ext_partial_shipping(self, cr, uid, id, external_referential_id, magento_incrementid, context):
42 logger = netsvc.Logger()49 logger = netsvc.Logger()
@@ -48,11 +55,17 @@
48 product_2_item.update({self.pool.get('product.product').extid_to_oeid(cr, uid, item['product_id'], external_referential_id, context={}): item['item_id']})55 product_2_item.update({self.pool.get('product.product').extid_to_oeid(cr, uid, item['product_id'], external_referential_id, context={}): item['item_id']})
49 picking = self.pool.get('stock.picking').browse(cr, uid, id, context)56 picking = self.pool.get('stock.picking').browse(cr, uid, id, context)
50 item_qty = {}57 item_qty = {}
58
59 lines = []
60 # get product and quantities to ship from the picking
51 for line in picking.move_lines:61 for line in picking.move_lines:
52 if item_qty.get(product_2_item[line.product_id.id], False):62 lines = self.add_picking_line(cr, uid, lines, line, context)
53 item_qty[product_2_item[line.product_id.id]] += line.product_qty63
64 for line in lines:
65 if item_qty.get(product_2_item[line['product_id']], False):
66 item_qty[product_2_item[line['product_id']]] += line['product_qty']
54 else:67 else:
55 item_qty.update({product_2_item[line.product_id.id]:line.product_qty})68 item_qty.update({product_2_item[line['product_id']]: line['product_qty']})
56 try:69 try:
57 ext_shipping_id = conn.call('sales_order_shipment.create', [magento_incrementid, item_qty, _("Shipping Created"), True, True])70 ext_shipping_id = conn.call('sales_order_shipment.create', [magento_incrementid, item_qty, _("Shipping Created"), True, True])
58 except Exception, e:71 except Exception, e: