<commit_before># -*- encoding: utf-8 -*-
#################################################################################
#                                                                               #
#    amazonerpconnect for OpenERP                                               #
#    Copyright (C) 2011 <NAME> <<EMAIL>>   #
#                                                                               #
#    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/>.      #
#                                                                               #
#################################################################################

from osv import osv, fields


class account_tax_code(osv.osv):
    _inherit='account.tax'
    
    def get_tax_from_rate(self, cr, uid, rate, is_tax_included=False, context=None):
        #TODO improve, if tax are not correctly mapped the order should be in exception (integration with sale_execption)
        tax_ids = self.pool.get('account.tax').search(cr, uid, [('price_include', '=', is_tax_included),
                ('type_tax_use', '=', 'sale'), ('amount', '>=', rate - 0.001), ('amount', '<=', rate + 0.001)])
        if tax_ids and len(tax_ids) > 0:
            return tax_ids[0]
        else:
        #try to find a tax with less precision 
            tax_ids = self.pool.get('account.tax').search(cr, uid, [('price_include', '=', is_tax_included), 
                    ('type_tax_use', '=', 'sale'), ('amount', '>=', rate - 0.01), ('amount', '<=', rate + 0.01)])
            if tax_ids and len(tax_ids) > 0:
                return tax_ids[0]
        return False<commit_msg>[MERGE] merge fix allow all tax type for external orders from https://code.launchpad.net/~gadgetscentralservice/e-commerce-addons/e-commerce-addons<commit_after># -*- encoding: utf-8 -*-
#################################################################################
#                                                                               #
#    amazonerpconnect for OpenERP                                               #
#    Copyright (C) 2011 <NAME> <<EMAIL>>   #
#                                                                               #
#    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/>.      #
#                                                                               #
#################################################################################

from osv import osv, fields


class account_tax_code(osv.osv):
    _inherit='account.tax'
    
    def get_tax_from_rate(self, cr, uid, rate, is_tax_included=False, context=None):
        #TODO improve, if tax are not correctly mapped the order should be in exception (integration with sale_execption)
        tax_ids = self.pool.get('account.tax').search(cr, uid, [('price_include', '=', is_tax_included),
                ('type_tax_use', 'in', ['sale', 'all']), ('amount', '>=', rate - 0.001), ('amount', '<=', rate + 0.001)])
        if tax_ids and len(tax_ids) > 0:
            return tax_ids[0]
        else:
        #try to find a tax with less precision 
            tax_ids = self.pool.get('account.tax').search(cr, uid, [('price_include', '=', is_tax_included), 
                    ('type_tax_use', 'in', ['sale', 'all']), ('amount', '>=', rate - 0.01), ('amount', '<=', rate + 0.01)])
            if tax_ids and len(tax_ids) > 0:
                return tax_ids[0]
        return False
{'fraction_non_alphanumeric': 0.15664255805100877, 'fraction_numerical': 0.009135896459840122, 'mean_word_length': 1.5179683756588405, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 19, 'https://': 1, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 34, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '909312', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1190, 'n_words': 406}