Skip to content

Commit

Permalink
[FIX] stock_ux: expiration_date in lot
Browse files Browse the repository at this point in the history
closes #421

Signed-off-by: Alexis Lopez <loa@adhoc.com.ar>
  • Loading branch information
mav-adhoc committed Jan 9, 2024
1 parent e720cec commit ae87d41
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions stock_ux/models/stock_move_line.py
Expand Up @@ -2,6 +2,7 @@
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
import datetime
from odoo import models, api, fields, _
from odoo.exceptions import ValidationError
from odoo.tools import float_is_zero
Expand Down Expand Up @@ -115,3 +116,20 @@ def _get_aggregated_product_quantities(self, **kwargs):
aggregated_move_lines[line]['description'] = False
aggregated_move_lines[line]['name'] =', '.join(moves.mapped('origin_description'))
return aggregated_move_lines

@api.onchange('expiration_date')
def onchange_expiration_date(self):
if self.lot_id and self.product_id:
lot = self.env['stock.lot'].search([
('name', '=', self.lot_id.name),
('product_id', '=', self.product_id.id),
])
prod = lot.product_id.product_tmpl_id
lot.write({
'expiration_date': self.expiration_date,
})
lot.write({
'removal_date': lot.expiration_date - datetime.timedelta(days=prod.removal_time),
'alert_date': lot.expiration_date - datetime.timedelta(days=prod.alert_time),
'use_date': lot.expiration_date - datetime.timedelta(days=prod.use_time),
})

0 comments on commit ae87d41

Please sign in to comment.