<commit_before># -*- coding: utf-8 -*-
###############################################################################
#
#    Copyright (C) 2001-2014 Micronaet SRL (<http://www.micronaet.it>).
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as published
#    by the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
import os
import sys
import netsvc
import logging
from openerp.osv import osv, orm, fields
from datetime import datetime, timedelta
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, \
    DEFAULT_SERVER_DATETIME_FORMAT, DATETIME_FORMATS_MAP, float_compare
import openerp.addons.decimal_precision as dp
from openerp.tools.translate import _


_logger = logging.getLogger(__name__)

class product_product(osv.osv):
    ''' Extend accounting query
    '''    
    _inherit = 'micronaet.accounting'

    def get_product_supplier_external(self, cr, uid, context=None):
        ''' Return query list from external query
        '''
        query_file = '~/etl/query/product_supplier.sql'
        query_file = os.path.expanduser(query_file)  
        _logger.info('Read external query file: %s' % query_file)
        
        query = ''
        try:
            for line in open(query_file, 'r'):
                query += line
            if not query:
                _logger.error('Empty query! [%s]' % query_file)
                return False
            cursor = self.connect(cr, uid, context=context)
            cursor.execute(query)
            return cursor
        except: 
            _logger.error('Error reading/executing query: %s' % filename)
            return False
    
    def get_product_supplier(self, cr, uid, context=None):
        ''' Return query for first supplier
            TODO manage this function, not used for now!!
        '''
        table = 'ar_anagrafiche' 
        if self.pool.get('res.company').table_capital_name(cr, uid, 
                context=context):
            table = table.upper()    

        cursor = self.connect(cr, uid, context=context)
        query = '''
            SELECT CKY_ART, CKY_CNT_FOR_AB FROM %s 
            WHERE CKY_CNT_FOR_AB != '';
            ''' % table
        try: 
            cursor.execute(query)
            return cursor
        except: 
            return False

class product_product(osv.osv):
    ''' Extend product.product
    '''    
    _inherit = 'product.product'
    
    _columns = {
        'first_supplier_id': fields.many2one('res.partner', 'First supplier'),
        }

    # -------------------------------------------------------------------------
    #                                  Override
    # -------------------------------------------------------------------------
    def schedule_sql_product_import(self, cr, uid, **args):
        ''' Launch import supplier after product
            verbose_log_count=100, write_date_from=False, write_date_to=False, 
            create_date_from=False, create_date_to=False, context=None):
        '''
        if args is None:
            args = {}
            context = {}
        else:
            context = args.get('context', {})
         
        import pdb; pdb.set_trace()
        # TODO restore:       
        #res = super(product_product, self).schedule_sql_product_import(
        #    cr, uid, **args)
<commit_msg>remove debug<commit_after># -*- coding: utf-8 -*-
###############################################################################
#
#    Copyright (C) 2001-2014 Micronaet SRL (<http://www.micronaet.it>).
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as published
#    by the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
import os
import sys
import netsvc
import logging
from openerp.osv import osv, orm, fields
from datetime import datetime, timedelta
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, \
    DEFAULT_SERVER_DATETIME_FORMAT, DATETIME_FORMATS_MAP, float_compare
import openerp.addons.decimal_precision as dp
from openerp.tools.translate import _


_logger = logging.getLogger(__name__)

class product_product(osv.osv):
    ''' Extend accounting query
    '''    
    _inherit = 'micronaet.accounting'

    def get_product_supplier_external(self, cr, uid, context=None):
        ''' Return query list from external query
        '''
        query_file = '~/etl/query/product_supplier.sql'
        query_file = os.path.expanduser(query_file)  
        _logger.info('Read external query file: %s' % query_file)
        
        query = ''
        try:
            for line in open(query_file, 'r'):
                query += line
            if not query:
                _logger.error('Empty query! [%s]' % query_file)
                return False
            cursor = self.connect(cr, uid, context=context)
            cursor.execute(query)
            return cursor
        except: 
            _logger.error('Error reading/executing query: %s' % filename)
            return False
    
    def get_product_supplier(self, cr, uid, context=None):
        ''' Return query for first supplier
            TODO manage this function, not used for now!!
        '''
        table = 'ar_anagrafiche' 
        if self.pool.get('res.company').table_capital_name(cr, uid, 
                context=context):
            table = table.upper()    

        cursor = self.connect(cr, uid, context=context)
        query = '''
            SELECT CKY_ART, CKY_CNT_FOR_AB FROM %s 
            WHERE CKY_CNT_FOR_AB != '';
            ''' % table
        try: 
            cursor.execute(query)
            return cursor
        except: 
            return False

class product_product(osv.osv):
    ''' Extend product.product
    '''    
    _inherit = 'product.product'
    
    _columns = {
        'first_supplier_id': fields.many2one('res.partner', 'First supplier'),
        }

    # -------------------------------------------------------------------------
    #                                  Override
    # -------------------------------------------------------------------------
    def schedule_sql_product_import(self, cr, uid, **args):
        ''' Launch import supplier after product
            verbose_log_count=100, write_date_from=False, write_date_to=False, 
            create_date_from=False, create_date_to=False, context=None):
        '''
        if args is None:
            args = {}
            context = {}
        else:
            context = args.get('context', {})
         
        res = super(product_product, self).schedule_sql_product_import(
            cr, uid, **args)

{'fraction_non_alphanumeric': 0.1625160462130937, 'fraction_numerical': 0.003594351732991014, 'mean_word_length': 2.0770142180094786, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4603114', 'n_tokens_mistral': 2109, 'n_tokens_neox': 2008, 'n_words': 598}