1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# Author: Guewen Baconnier
5
# Copyright 2012 Camptocamp SA
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU Affero General Public License as
9
# published by the Free Software Foundation, either version 3 of the
10
# License, or (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU Affero General Public License for more details.
17
# You should have received a copy of the GNU Affero General Public License
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
##############################################################################
25
_logger = logging.getLogger(__name__)
28
class product_product(osv.osv):
30
_inherit = 'product.product'
32
def _magento_init_stock(self, cr, uid, product_id,
33
magento_id, connection, context=None):
34
# initialize the inventory options on the created product
35
shop = self.pool.get('sale.shop').browse(
36
cr, uid, context['shop_id'], context=context)
37
stock = shop.warehouse_id.lot_stock_id
38
product = self.browse(cr, uid, product_id, context=context)
39
stock_vals = self._prepare_inventory_magento_vals(
40
cr, uid, product, stock, shop, context=context)
42
connection.call('product_stock.update', [magento_id, stock_vals])
43
_logger.info("Successfully initialized inventory "
44
"options on product with SKU %s " %
45
(product.magento_sku,))
48
def ext_create(self, cr, uid, data, conn, method, oe_id, context):
49
magento_product_id = super(product_product, self).ext_create(
50
cr, uid, data, conn, method, oe_id, context)
52
self._magento_init_stock(cr, uid, oe_id, magento_product_id,
53
conn, context=context)
54
return magento_product_id