summaryrefslogtreecommitdiff
path: root/addons/stock/wizard/stock_orderpoint_snooze.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/stock/wizard/stock_orderpoint_snooze.py
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/stock/wizard/stock_orderpoint_snooze.py')
-rw-r--r--addons/stock/wizard/stock_orderpoint_snooze.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/addons/stock/wizard/stock_orderpoint_snooze.py b/addons/stock/wizard/stock_orderpoint_snooze.py
new file mode 100644
index 00000000..00808dbb
--- /dev/null
+++ b/addons/stock/wizard/stock_orderpoint_snooze.py
@@ -0,0 +1,34 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import api, fields, models
+from odoo.tools.date_utils import add
+
+
+class StockOrderpointSnooze(models.TransientModel):
+ _name = 'stock.orderpoint.snooze'
+ _description = 'Snooze Orderpoint'
+
+ orderpoint_ids = fields.Many2many('stock.warehouse.orderpoint')
+ predefined_date = fields.Selection([
+ ('day', '1 Day'),
+ ('week', '1 Week'),
+ ('month', '1 Month'),
+ ('custom', 'Custom')
+ ], string='Snooze for', default='day')
+ snoozed_until = fields.Date('Snooze Date')
+
+ @api.onchange('predefined_date')
+ def _onchange_predefined_date(self):
+ today = fields.Date.today()
+ if self.predefined_date == 'day':
+ self.snoozed_until = add(today, days=1)
+ elif self.predefined_date == 'week':
+ self.snoozed_until = add(today, weeks=1)
+ elif self.predefined_date == 'month':
+ self.snoozed_until = add(today, months=1)
+
+ def action_snooze(self):
+ self.orderpoint_ids.write({
+ 'snoozed_until': self.snoozed_until
+ })