diff --git a/odoo/addons/delivery_slip_custom/__init__.py b/odoo/addons/delivery_slip_custom/__init__.py
index 40a96af..a0fdc10 100644
--- a/odoo/addons/delivery_slip_custom/__init__.py
+++ b/odoo/addons/delivery_slip_custom/__init__.py
@@ -1 +1,2 @@
# -*- coding: utf-8 -*-
+from . import models
diff --git a/odoo/addons/delivery_slip_custom/__manifest__.py b/odoo/addons/delivery_slip_custom/__manifest__.py
index 79f6573..bd165c5 100644
--- a/odoo/addons/delivery_slip_custom/__manifest__.py
+++ b/odoo/addons/delivery_slip_custom/__manifest__.py
@@ -1,19 +1,17 @@
# -*- coding: utf-8 -*-
{
'name': 'Custom Delivery Slip',
- 'version': '19.0.1.0.0',
+ 'version': '19.0.1.0.1',
'category': 'Inventory',
- 'summary': 'Customize delivery slip with lot number, production date, expiration date',
+ 'summary': 'Add production and expiration dates to delivery order labels',
'description': """
- Adds the following fields to delivery slips:
- - Lot/Serial number
+ Adds production and expiration date labels to delivery orders.
- Production date (today's date)
- Expiration date (6 months from production)
- - Product name
""",
'depends': ['stock'],
'data': [
- 'views/report_deliveryslip.xml',
+ 'views/stock_picking_form.xml',
],
'installable': True,
'application': False,
diff --git a/odoo/addons/delivery_slip_custom/models.py b/odoo/addons/delivery_slip_custom/models.py
new file mode 100644
index 0000000..597c347
--- /dev/null
+++ b/odoo/addons/delivery_slip_custom/models.py
@@ -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)
diff --git a/odoo/addons/delivery_slip_custom/views/report_deliveryslip.xml b/odoo/addons/delivery_slip_custom/views/report_deliveryslip.xml
deleted file mode 100644
index 2d23e41..0000000
--- a/odoo/addons/delivery_slip_custom/views/report_deliveryslip.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
- |
-
- |
-
-
-
-
-
- |
-
-
-
-
-
-
-
- Production Date |
- Expiration Date |
-
-
-
diff --git a/odoo/addons/delivery_slip_custom/views/stock_picking_form.xml b/odoo/addons/delivery_slip_custom/views/stock_picking_form.xml
new file mode 100644
index 0000000..b7214f3
--- /dev/null
+++ b/odoo/addons/delivery_slip_custom/views/stock_picking_form.xml
@@ -0,0 +1,15 @@
+
+
+
+
+ stock.move.line.tree.custom
+ stock.move.line
+
+
+
+
+
+
+
+
+