| 1 |
# -*- coding: utf-8 -*- |
| 2 |
# Part of Odoo. See LICENSE file for full copyright and licensing details. |
| 3 |
import datetime |
| 4 |
|
| 5 |
from odoo import fields, models |
| 6 |
|
| 7 |
|
| 8 |
class ProductProduct(models.Model): |
| 9 |
_inherit = "product.product" |
| 10 |
|
| 11 |
def _compute_quantities_dict(self, lot_id, owner_id, package_id, from_date=False, to_date=False): |
| 12 |
return super(ProductProduct, self.with_context(with_expiration=datetime.date.today()))._compute_quantities_dict(lot_id, owner_id, package_id, from_date, to_date) |
| 13 |
|
| 14 |
free_qty = fields.Float(help="Available quantity (computed as Quantity On Hand " |
| 15 |
"- reserved quantity - quantity to remove)\n" |
| 16 |
"In a context with a single Stock Location, this includes " |
| 17 |
"goods stored in this location, or any of its children.\n" |
| 18 |
"In a context with a single Warehouse, this includes " |
| 19 |
"goods stored in the Stock Location of this Warehouse, or any " |
| 20 |
"of its children.\n" |
| 21 |
"Otherwise, this includes goods stored in any Stock Location " |
| 22 |
"with 'internal' type.") |
| 23 |
|
| 24 |
virtual_available = fields.Float(help="Forecast quantity (computed as Quantity On Hand " |
| 25 |
"- Outgoing + Incoming - Quantity to Remove)\n" |
| 26 |
"In a context with a single Stock Location, this includes " |
| 27 |
"goods stored in this location, or any of its children.\n" |
| 28 |
"In a context with a single Warehouse, this includes " |
| 29 |
"goods stored in the Stock Location of this Warehouse, or any " |
| 30 |
"of its children.\n" |
| 31 |
"Otherwise, this includes goods stored in any Stock Location " |
| 32 |
"with 'internal' type.") |
| 33 |
|
| 34 |
|
| 35 |
class ProductTemplate(models.Model): |
| 36 |
_inherit = 'product.template' |
| 37 |
|
| 38 |
use_expiration_date = fields.Boolean(string='Use Expiration Date', |
| 39 |
help='When this box is ticked, you have the possibility to specify dates to manage' |
| 40 |
' product expiration, on the product and on the corresponding lot/serial numbers') |
| 41 |
expiration_time = fields.Integer(string='Expiration Date', |
| 42 |
help='Number of days after the receipt of the products (from the vendor' |
| 43 |
' or in stock after production) after which the goods may become dangerous' |
| 44 |
' and must not be consumed. It will be computed on the lot/serial number.') |
| 45 |
use_time = fields.Integer(string='Best Before Date', |
| 46 |
help='Number of days before the Expiration Date after which the goods starts' |
| 47 |
' deteriorating, without being dangerous yet. It will be computed on the lot/serial number.') |
| 48 |
removal_time = fields.Integer(string='Removal Date', |
| 49 |
help='Number of days before the Expiration Date after which the goods' |
| 50 |
' should be removed from the stock and not be counted in the Fresh On Hand Stock anymore.' |
| 51 |
'It will be computed on the lot/serial number.') |
| 52 |
alert_time = fields.Integer(string='Alert Date', |
| 53 |
help='Number of days before the Expiration Date after which an alert should be' |
| 54 |
' raised on the lot/serial number. It will be computed on the lot/serial number.') |