Merge lp:~initos.com/openerp-connector-magento/7.0-no-stock-sync into lp:~openerp-connector-core-editors/openerp-connector-magento/7.0

Proposed by Katja Matthes
Status: Merged
Approved by: Guewen Baconnier @ Camptocamp
Approved revision: 969
Merge reported by: Guewen Baconnier @ Camptocamp
Merged at revision: not available
Proposed branch: lp:~initos.com/openerp-connector-magento/7.0-no-stock-sync
Merge into: lp:~openerp-connector-core-editors/openerp-connector-magento/7.0
Diff against target: 62 lines (+8/-2)
3 files modified
magentoerpconnect/magento_model.py (+2/-1)
magentoerpconnect/product.py (+5/-1)
magentoerpconnect/product_view.xml (+1/-0)
To merge this branch: bzr merge lp:~initos.com/openerp-connector-magento/7.0-no-stock-sync
Reviewer Review Type Date Requested Status
Guewen Baconnier @ Camptocamp code review Approve
Review via email: mp+218366@code.launchpad.net

Description of the change

Add a flag to magento.product.product to disable inventory synchonization (for flagged products).
Usefull for dropshipping and managed stock in an other system.

To post a comment you must log in.
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Nice.
Thanks!

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/magento_model.py'
2--- magentoerpconnect/magento_model.py 2013-08-15 08:01:46 +0000
3+++ magentoerpconnect/magento_model.py 2014-05-06 08:52:27 +0000
4@@ -223,7 +223,8 @@
5 ids = [ids]
6 mag_product_obj = self.pool.get('magento.product.product')
7 product_ids = mag_product_obj.search(cr, uid,
8- [('backend_id', 'in', ids)],
9+ [('backend_id', 'in', ids),
10+ ('no_stock_sync', '=', False)],
11 context=context)
12 mag_product_obj.recompute_magento_qty(cr, uid, product_ids,
13 context=context)
14
15=== modified file 'magentoerpconnect/product.py'
16--- magentoerpconnect/product.py 2014-01-14 10:41:05 +0000
17+++ magentoerpconnect/product.py 2014-05-06 08:52:27 +0000
18@@ -102,12 +102,14 @@
19 'magento_qty': fields.float('Computed Quantity',
20 help="Last computed quantity to send "
21 "on Magento."),
22+ 'no_stock_sync': fields.boolean('No Stock Synchronization', help="Check this to exclude the product from stock synchronizations.", required=False)
23 }
24
25 _defaults = {
26 'product_type': 'simple',
27 'manage_stock': 'use_default',
28 'backorders': 'use_default',
29+ 'no_stock_sync': False,
30 }
31
32 _sql_constraints = [
33@@ -387,7 +389,7 @@
34 @magento
35 class ProductImportMapper(ImportMapper):
36 _model_name = 'magento.product.product'
37- #TODO : categ, special_price => minimal_price
38+ # TODO : categ, special_price => minimal_price
39 direct = [('name', 'name'),
40 ('description', 'description'),
41 ('weight', 'weight'),
42@@ -513,6 +515,8 @@
43 def magento_product_modified(session, model_name, record_id, vals):
44 if session.context.get('connector_no_export'):
45 return
46+ if session.browse(model_name, record_id).no_stock_sync:
47+ return
48 inventory_fields = list(set(vals).intersection(INVENTORY_FIELDS))
49 if inventory_fields:
50 export_product_inventory.delay(session, model_name,
51
52=== modified file 'magentoerpconnect/product_view.xml'
53--- magentoerpconnect/product_view.xml 2013-10-14 09:29:39 +0000
54+++ magentoerpconnect/product_view.xml 2014-05-06 08:52:27 +0000
55@@ -80,6 +80,7 @@
56 <field name="product_type" readonly="1"/>
57 </group>
58 <group string="Inventory Options">
59+ <field name="no_stock_sync"/>
60 <field name="manage_stock"/>
61 <field name="backorders"/>
62 <div class="oe_inline">