diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/product_expiry/models/stock_move.py | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/product_expiry/models/stock_move.py')
| -rw-r--r-- | addons/product_expiry/models/stock_move.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/addons/product_expiry/models/stock_move.py b/addons/product_expiry/models/stock_move.py new file mode 100644 index 00000000..d0fc75be --- /dev/null +++ b/addons/product_expiry/models/stock_move.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +import datetime + +from odoo import fields, models + + +class StockMove(models.Model): + _inherit = "stock.move" + use_expiration_date = fields.Boolean( + string='Use Expiration Date', related='product_id.use_expiration_date') + + def _generate_serial_move_line_commands(self, lot_names, origin_move_line=None): + """Override to add a default `expiration_date` into the move lines values.""" + move_lines_commands = super()._generate_serial_move_line_commands(lot_names, origin_move_line=origin_move_line) + if self.product_id.use_expiration_date: + date = fields.Datetime.today() + datetime.timedelta(days=self.product_id.expiration_time) + for move_line_command in move_lines_commands: + move_line_vals = move_line_command[2] + move_line_vals['expiration_date'] = date + return move_lines_commands |
