<commit_before># -*- coding: utf-8 -*-
#############################################################################
#
#    Copyright (c) 2007 <NAME> <<EMAIL>>
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU 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 General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

from openerp.osv import fields, osv
import openerp.addons.decimal_precision as dp

class product_product(osv.osv):

    def onchange_brutto_price(self, cr, uid, ids, brutto_price, taxes_id, company_id, context=None):
        res = {
           "value" : {}
        }

        tax_obj = self.pool.get("account.tax")
        cur_obj = self.pool.get("res.currency")
        company_obj = self.pool.get("res.company")

        price = brutto_price
        taxes_list = taxes_id[0][2]
        if taxes_list:
            price_list = tax_obj.compute_inv(cr, uid, tax_obj.browse(cr, uid, taxes_list), price, 1)
            if price_list:
                price = price_list[0]["price_unit"]
        currency_id = company_obj.browse(cr, uid, company_id).currency_id
        if currency_id:
            res["value"]["lst_price"] = cur_obj.round(cr, uid, currency_id, price)
        else:
            res["value"]["lst_price"] = price

        return res

    _inherit = "product.product"


class product_template(osv.osv):

    def onchange_brutto_price(self, cr, uid, ids, brutto_price, taxes_id, company_id, context=None):
        res = {
           "value" : {}
        }

        tax_obj = self.pool.get("account.tax")
        cur_obj = self.pool.get("res.currency")
        company_obj = self.pool.get("res.company")

        price = brutto_price
        taxes_list = taxes_id[0][2]
        if taxes_list:
            price_list = tax_obj.compute_inv(cr, uid, tax_obj.browse(cr, uid, taxes_list), price, 1)
            if price_list:
                price = price_list[0]["price_unit"]
        currency_id = company_obj.browse(cr, uid, company_id).currency_id
        if currency_id:
            res["value"]["list_price"] = cur_obj.round(cr, uid, currency_id, price)
        else:
            res["value"]["list_price"] = price

        return res

    def _calculate_price(self, cr, uid, ids, field_name, arg, context=None):
        res = dict.fromkeys(ids)
        tax_obj = self.pool.get("account.tax")
        cur_obj = self.pool.get("res.currency")

        for product in self.browse(cr, uid, ids, context=context):
            price = product.list_price
            tax_ids = product.taxes_id
            if tax_ids:
                price = tax_obj.compute_all(cr, uid, tax_ids, price, 1)["total_included"]
            if product.company_id and product.company_id.currency_id:
                cur = product.company_id.currency_id
                res[product.id] = cur_obj.round(cr, uid, cur, price)
            else:
                res[product.id] = price

        return res

    _inherit = "product.template"
    _columns = {
        "brutto_price" : fields.function(_calculate_price, type="float", string="Brutto Price",
                                         help="The brutto price is based on the given tax."),
    }
<commit_msg>[FIX] security issue<commit_after># -*- coding: utf-8 -*-
#############################################################################
#
#    Copyright (c) 2007 <NAME> <<EMAIL>>
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU 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 General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

from openerp.osv import fields, osv
import openerp.addons.decimal_precision as dp
from openerp import SUPERUSER_ID

class product_product(osv.osv):

    def onchange_brutto_price(self, cr, uid, ids, brutto_price, taxes_id, company_id, context=None):
        res = {
           "value" : {}
        }

        tax_obj = self.pool.get("account.tax")
        cur_obj = self.pool.get("res.currency")
        company_obj = self.pool.get("res.company")

        price = brutto_price
        taxes_list = taxes_id[0][2]
        if taxes_list:
            price_list = tax_obj.compute_inv(cr, uid, tax_obj.browse(cr, uid, taxes_list), price, 1)
            if price_list:
                price = price_list[0]["price_unit"]
        currency_id = company_obj.browse(cr, uid, company_id).currency_id
        if currency_id:
            res["value"]["lst_price"] = cur_obj.round(cr, uid, currency_id, price)
        else:
            res["value"]["lst_price"] = price

        return res

    _inherit = "product.product"


class product_template(osv.osv):

    def onchange_brutto_price(self, cr, uid, ids, brutto_price, taxes_id, company_id, context=None):
        res = {
           "value" : {}
        }

        tax_obj = self.pool.get("account.tax")
        cur_obj = self.pool.get("res.currency")
        company_obj = self.pool.get("res.company")

        price = brutto_price
        taxes_list = taxes_id[0][2]
        if taxes_list:
            price_list = tax_obj.compute_inv(cr, uid, tax_obj.browse(cr, uid, taxes_list), price, 1)
            if price_list:
                price = price_list[0]["price_unit"]
        currency_id = company_obj.browse(cr, uid, company_id).currency_id
        if currency_id:
            res["value"]["list_price"] = cur_obj.round(cr, uid, currency_id, price)
        else:
            res["value"]["list_price"] = price

        return res

    def _calculate_price(self, cr, uid, ids, field_name, arg, context=None):
        res = dict.fromkeys(ids)
        tax_obj = self.pool.get("account.tax")
        cur_obj = self.pool.get("res.currency")

        for product in self.browse(cr, SUPERUSER_ID, ids, context=context):
            price = product.list_price
            tax_ids = product.taxes_id
            if tax_ids:
                price = tax_obj.compute_all(cr, SUPERUSER_ID, tax_ids, price, 1)["total_included"]
            if product.company_id and product.company_id.currency_id:
                cur = product.company_id.currency_id
                res[product.id] = cur_obj.round(cr, SUPERUSER_ID, cur, price)
            else:
                res[product.id] = price

        return res

    _inherit = "product.template"
    _columns = {
        "brutto_price" : fields.function(_calculate_price, type="float", string="Brutto Price",
                                         help="The brutto price is based on the given tax."),
    }

{'fraction_non_alphanumeric': 0.14359381197937326, 'fraction_numerical': 0.003966679888932963, 'mean_word_length': 2.546179090482888, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7466907', 'n_tokens_mistral': 2292, 'n_tokens_neox': 2219, 'n_words': 586}