# -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. import datetime from odoo import fields, models class ProductProduct(models.Model): _inherit = "product.product" def _compute_quantities_dict(self, lot_id, owner_id, package_id, from_date=False, to_date=False): return super(ProductProduct, self.with_context(with_expiration=datetime.date.today()))._compute_quantities_dict(lot_id, owner_id, package_id, from_date, to_date) free_qty = fields.Float(help="Available quantity (computed as Quantity On Hand " "- reserved quantity - quantity to remove)\n" "In a context with a single Stock Location, this includes " "goods stored in this location, or any of its children.\n" "In a context with a single Warehouse, this includes " "goods stored in the Stock Location of this Warehouse, or any " "of its children.\n" "Otherwise, this includes goods stored in any Stock Location " "with 'internal' type.") virtual_available = fields.Float(help="Forecast quantity (computed as Quantity On Hand " "- Outgoing + Incoming - Quantity to Remove)\n" "In a context with a single Stock Location, this includes " "goods stored in this location, or any of its children.\n" "In a context with a single Warehouse, this includes " "goods stored in the Stock Location of this Warehouse, or any " "of its children.\n" "Otherwise, this includes goods stored in any Stock Location " "with 'internal' type.") class ProductTemplate(models.Model): _inherit = 'product.template' use_expiration_date = fields.Boolean(string='Use Expiration Date', help='When this box is ticked, you have the possibility to specify dates to manage' ' product expiration, on the product and on the corresponding lot/serial numbers') expiration_time = fields.Integer(string='Expiration Date', help='Number of days after the receipt of the products (from the vendor' ' or in stock after production) after which the goods may become dangerous' ' and must not be consumed. It will be computed on the lot/serial number.') use_time = fields.Integer(string='Best Before Date', help='Number of days before the Expiration Date after which the goods starts' ' deteriorating, without being dangerous yet. It will be computed on the lot/serial number.') removal_time = fields.Integer(string='Removal Date', help='Number of days before the Expiration Date after which the goods' ' should be removed from the stock and not be counted in the Fresh On Hand Stock anymore.' 'It will be computed on the lot/serial number.') alert_time = fields.Integer(string='Alert Date', help='Number of days before the Expiration Date after which an alert should be' ' raised on the lot/serial number. It will be computed on the lot/serial number.')