Merge lp:~camptocamp/magentoerpconnect/oerp6.1-oldstable-stock-config-1070726 into lp:magentoerpconnect/oerp6.1-oldstable

Proposed by Guewen Baconnier @ Camptocamp
Status: Merged
Merged at revision: 663
Proposed branch: lp:~camptocamp/magentoerpconnect/oerp6.1-oldstable-stock-config-1070726
Merge into: lp:magentoerpconnect/oerp6.1-oldstable
Diff against target: 70 lines (+19/-1)
3 files modified
magentoerpconnect/magerp_osv.py (+4/-1)
magentoerpconnect/product.py (+14/-0)
magentoerpconnect/product_view.xml (+1/-0)
To merge this branch: bzr merge lp:~camptocamp/magentoerpconnect/oerp6.1-oldstable-stock-config-1070726
Reviewer Review Type Date Requested Status
Alexandre Fayolle - camptocamp code review, no test Approve
Review via email: mp+131178@code.launchpad.net

Description of the change

lp:1070726

Allows to choose if the product should:
 * have a stock
 * not have a stock
 * use the default configuration of magento

A sql query in the init of the module ensures that the values are initialized to "use_default" when we update the module.

That's basically a port of this feature from the the oerp6.1-stable branch.

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

[FIX] debug? no!

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

I would be glad to have someone review my branch.

Thanks

Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

LGTM

review: Approve (code review, no test)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'magentoerpconnect/magerp_osv.py'
--- magentoerpconnect/magerp_osv.py 2012-07-05 12:55:29 +0000
+++ magentoerpconnect/magerp_osv.py 2012-10-24 13:13:21 +0000
@@ -116,7 +116,10 @@
116 self.logger.error(_("Method: %s\nArguments:%s\nError:%s"), method, arguments, e, exc_info=True)116 self.logger.error(_("Method: %s\nArguments:%s\nError:%s"), method, arguments, e, exc_info=True)
117 self.logger.warn(_("Webservice Failure, sleeping %s second before next attempt"), sleep_time)117 self.logger.warn(_("Webservice Failure, sleeping %s second before next attempt"), sleep_time)
118 time.sleep(sleep_time)118 time.sleep(sleep_time)
119 raise119 raise
120 except xmlrpclib.Fault, exc:
121 self.logger.error('call to %s%s failed: %s', method, tuple(arguments), exc)
122 raise
120123
121124
122 def fetch_image(self, imgloc):125 def fetch_image(self, imgloc):
123126
=== modified file 'magentoerpconnect/product.py'
--- magentoerpconnect/product.py 2012-08-23 13:28:10 +0000
+++ magentoerpconnect/product.py 2012-10-24 13:13:21 +0000
@@ -1161,17 +1161,29 @@
1161 'tier_price':fields.one2many('product.tierprice', 'product', 'Tier Price'),1161 'tier_price':fields.one2many('product.tierprice', 'product', 'Tier Price'),
1162 'product_type': fields.selection(_product_type_get, 'Magento Product Type'),1162 'product_type': fields.selection(_product_type_get, 'Magento Product Type'),
1163 'magento_exported': fields.function(_is_magento_exported, type="boolean", method=True, string="Exists on Magento"), # used to set the sku readonly when already exported1163 'magento_exported': fields.function(_is_magento_exported, type="boolean", method=True, string="Exists on Magento"), # used to set the sku readonly when already exported
1164 'mag_manage_stock': fields.selection([
1165 ('use_default','Use Default Config'),
1166 ('no', 'Do Not Manage Stock'),
1167 ('yes','Manage Stock')],
1168 'Manage Stock Level', required=True),
1164 }1169 }
11651170
1166 _defaults = {1171 _defaults = {
1167 'magento_exportable': True,1172 'magento_exportable': True,
1168 'product_type': 'simple',1173 'product_type': 'simple',
1174 'mag_manage_stock': 'use_default',
1169 }1175 }
11701176
1171 _sql_constraints = [1177 _sql_constraints = [
1172 ('magento_sku_uniq', 'unique (magento_sku)', 'The Magento SKU should be uniq!'),1178 ('magento_sku_uniq', 'unique (magento_sku)', 'The Magento SKU should be uniq!'),
1173 ]1179 ]
11741180
1181 def init(self, cr):
1182 """Initialize the empty magento manage stock option to the use_default when we
1183 update the module"""
1184 cr.execute("UPDATE product_product SET mag_manage_stock = 'use_default' "
1185 "WHERE mag_manage_stock IS NULL")
1186
1175 def write(self, cr, uid, ids, vals, context=None):1187 def write(self, cr, uid, ids, vals, context=None):
1176 if vals.get('referential_id', False):1188 if vals.get('referential_id', False):
1177 instance = vals['referential_id']1189 instance = vals['referential_id']
@@ -1541,6 +1553,8 @@
1541 'virtual_available')1553 'virtual_available')
1542 stock_quantity = product[stock_field]1554 stock_quantity = product[stock_field]
1543 return {'qty': stock_quantity,1555 return {'qty': stock_quantity,
1556 'manage_stock': int(product.mag_manage_stock == 'yes'),
1557 'use_config_manage_stock': int(product.mag_manage_stock == 'use_default'),
1544 # put the stock availability to "out of stock"1558 # put the stock availability to "out of stock"
1545 'is_in_stock': int(stock_quantity > 0)}1559 'is_in_stock': int(stock_quantity > 0)}
15461560
15471561
=== modified file 'magentoerpconnect/product_view.xml'
--- magentoerpconnect/product_view.xml 2012-03-28 09:58:18 +0000
+++ magentoerpconnect/product_view.xml 2012-10-24 13:13:21 +0000
@@ -280,6 +280,7 @@
280 <field name="set" select="2" attrs="{'required':[('magento_exportable','==',True)], 'readonly': [('magento_exported', '=', True)]}"/>280 <field name="set" select="2" attrs="{'required':[('magento_exportable','==',True)], 'readonly': [('magento_exported', '=', True)]}"/>
281 <field name="magento_sku" select="2" attrs="{'required':[('magento_exportable','==',True)]}"/>281 <field name="magento_sku" select="2" attrs="{'required':[('magento_exportable','==',True)]}"/>
282 <field name="product_type" select="2" attrs="{'required':[('magento_exportable','==',True)]}"/>282 <field name="product_type" select="2" attrs="{'required':[('magento_exportable','==',True)]}"/>
283 <field name="mag_manage_stock" select="2" attrs="{'required':[('magento_exportable','==',True)]}"/>
283 <field name="magento_exportable"/>284 <field name="magento_exportable"/>
284 <field name="magento_exported" invisible="1" />285 <field name="magento_exported" invisible="1" />
285 </group>286 </group>