<commit_before># -*- coding: utf-8 -*-
# (c) 2015 <NAME>. - <NAME>
# (c) 2015 <NAME>. - <NAME>
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

import math

from openerp import models, fields, api
from openerp.addons.decimal_precision import decimal_precision as dp

class SaleOrderLine(models.Model):
    _inherit = 'sale.order.line'

    packaging_price = fields.Float(
        related='product_packaging.list_price', string='Package Price',
        readonly=True)
    product_packaging = fields.Many2one(ondelete='restrict')
    packaging_weight = fields.Float(
        string='Package Weight',
        digits_compute=dp.get_precision('Stock Weight'))

    @api.multi
    def product_packaging_change(
            self, pricelist, product, qty=0, uom=False, partner_id=False,
            packaging=False, flag=False):
        res = super(SaleOrderLine, self).product_packaging_change(
            pricelist, product, qty, uom, partner_id, packaging, flag)
        if packaging:
            product_packaging = self.env['product.packaging'].browse(packaging)
            product_prec = self.env['decimal.precision'].precision_get(
                'Product Price')
            res['value']['price_unit'] = round(
                product_packaging.list_price / product_packaging.qty,
                product_prec)
            package_weight = math.ceil(
                qty / product_packaging.qty) * product_packaging.ul.weight
            res['value']['packaging_weight'] = package_weight
        else:
            res = self.product_id_change(pricelist=pricelist,
                    product=product, qty=qty, uom=uom, partner_id=partner_id,
                    packaging=packaging, flag=False)
            price_unit = res['value'].get('price_unit', 0.0)<commit_msg>[FIX] sale_packaging_price: Fix flake8.<commit_after># -*- coding: utf-8 -*-
# (c) 2015 <NAME>. - <NAME>
# (c) 2015 <NAME>. - <NAME>
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

import math

from openerp import models, fields, api
from openerp.addons.decimal_precision import decimal_precision as dp


class SaleOrderLine(models.Model):
    _inherit = 'sale.order.line'

    packaging_price = fields.Float(
        related='product_packaging.list_price', string='Package Price',
        readonly=True)
    product_packaging = fields.Many2one(ondelete='restrict')
    packaging_weight = fields.Float(
        string='Package Weight',
        digits_compute=dp.get_precision('Stock Weight'))

    @api.multi
    def product_packaging_change(
            self, pricelist, product, qty=0, uom=False, partner_id=False,
            packaging=False, flag=False):
        res = super(SaleOrderLine, self).product_packaging_change(
            pricelist, product, qty, uom, partner_id, packaging, flag)
        if packaging:
            product_packaging = self.env['product.packaging'].browse(packaging)
            product_prec = self.env['decimal.precision'].precision_get(
                'Product Price')
            res['value']['price_unit'] = round(
                product_packaging.list_price / product_packaging.qty,
                product_prec)
            package_weight = math.ceil(
                qty / product_packaging.qty) * product_packaging.ul.weight
            res['value']['packaging_weight'] = package_weight
        else:
            res = self.product_id_change(
                pricelist=pricelist, product=product, qty=qty, uom=uom,
                partner_id=partner_id, packaging=packaging, flag=False)
            price_unit = res['value'].get('price_unit', 0.0)
{'fraction_non_alphanumeric': 0.11630495269894268, 'fraction_numerical': 0.009181969949916527, 'mean_word_length': 2.748696558915537, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '120237', 'n_tokens_mistral': 1125, 'n_tokens_neox': 1059, 'n_words': 203}