feat: Add production and expiration dates to stock move lines and update delivery slip report
This commit is contained in:
33
odoo/addons/delivery_slip_custom/models.py
Normal file
33
odoo/addons/delivery_slip_custom/models.py
Normal file
@@ -0,0 +1,33 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from odoo import models, fields, api
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
|
||||
class StockMoveLine(models.Model):
|
||||
_inherit = 'stock.move.line'
|
||||
|
||||
production_date = fields.Date(
|
||||
string='Production Date',
|
||||
compute='_compute_production_date',
|
||||
store=False,
|
||||
readonly=True,
|
||||
)
|
||||
|
||||
expiration_date = fields.Date(
|
||||
string='Expiration Date',
|
||||
compute='_compute_expiration_date',
|
||||
store=False,
|
||||
readonly=True,
|
||||
)
|
||||
|
||||
@api.depends('move_id.create_date')
|
||||
def _compute_production_date(self):
|
||||
"""Set production date to today or the move's creation date"""
|
||||
for line in self:
|
||||
line.production_date = fields.Date.today()
|
||||
|
||||
@api.depends('move_id.create_date')
|
||||
def _compute_expiration_date(self):
|
||||
"""Set expiration date to 6 months (180 days) from today"""
|
||||
for line in self:
|
||||
line.expiration_date = fields.Date.today() + timedelta(days=180)
|
||||
Reference in New Issue
Block a user