<commit_before>##############################################################################
#
#    Copyright (C) 2004-2014 Pexego Sistemas Informáticos All Rights Reserved
#    $<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 odoo import models, fields, api
import odoo.addons.decimal_precision as dp


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

    qty_available = fields.\
        Float('Qty available', readonly=True,compute="_compute_qty_available",
              digits=dp.get_precision('Product Unit of Measure'))
    qty_available_wo_wh = fields.\
        Float('Qty. on kitchen', readonly=True,
              related='product_id.qty_available_wo_wh',
              digits=dp.get_precision('Product Unit of Measure'))
    incoming_qty = fields.\
        Float('Incoming qty.', readonly=True, compute='_get_incoming_qty',
              digits=dp.get_precision('Product Unit of Measure'))

    @api.multi
    def _compute_qty_available(self):
        for line in self:
            line.qty_available=line.product_id.virtual_stock_conservative-line.product_id.qty_available_wo_wh

    @api.multi
    def _get_incoming_qty(self):
        for sol in self:
            incoming_qty = 0
            if sol.product_id:
                product = sol.product_id
                incoming_qty = product.incoming_qty + \
                    product.qty_available_input_loc
            sol.incoming_qty = incoming_qty


class SaleOrder(models.Model):
    _inherit = "sale.order"

    @api.multi
    @api.returns('self', lambda value: value.id)
    def message_post(self, **kwargs):
        context = dict(self.env.context)
        context.pop('mail_post_autofollow', False)
        self = self.with_context(context)<commit_msg>[FIX] sale_display_stock:Arreglado error en el stock disponible<commit_after>##############################################################################
#
#    Copyright (C) 2004-2014 Pexego Sistemas Informáticos All Rights Reserved
#    $<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 odoo import models, fields, api
import odoo.addons.decimal_precision as dp


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

    qty_available = fields.\
        Float('Qty available', readonly=True, compute="_compute_qty_available",
              digits=dp.get_precision('Product Unit of Measure'))
    qty_available_wo_wh = fields.\
        Float('Qty. on kitchen', readonly=True,
              related='product_id.qty_available_wo_wh',
              digits=dp.get_precision('Product Unit of Measure'))
    incoming_qty = fields.\
        Float('Incoming qty.', readonly=True, compute='_get_incoming_qty',
              digits=dp.get_precision('Product Unit of Measure'))

    @api.multi
    @api.depends('product_id')
    def _compute_qty_available(self):
        for line in self:
            line.qty_available = line.product_id.virtual_stock_conservative - line.product_id.qty_available_input_loc

    @api.multi
    def _get_incoming_qty(self):
        for sol in self:
            incoming_qty = 0
            if sol.product_id:
                product = sol.product_id
                incoming_qty = product.incoming_qty + \
                    product.qty_available_input_loc
            sol.incoming_qty = incoming_qty


class SaleOrder(models.Model):
    _inherit = "sale.order"

    @api.multi
    @api.returns('self', lambda value: value.id)
    def message_post(self, **kwargs):
        context = dict(self.env.context)
        context.pop('mail_post_autofollow', False)
        self = self.with_context(context)
{'fraction_non_alphanumeric': 0.14249113125739063, 'fraction_numerical': 0.003941663381947182, 'mean_word_length': 3.1666666666666665, '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': '2644208', 'n_tokens_mistral': 1461, 'n_tokens_neox': 1393, 'n_words': 413}