summaryrefslogtreecommitdiff
path: root/indoteknik_custom
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2023-07-21 08:20:16 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2023-07-21 08:20:16 +0700
commit70c667cb341efa30f29626183bb5dc25654714de (patch)
treea3e9f67d6c1a6acea42f9636f7c96456acb5c1f6 /indoteknik_custom
parent81175e09c6fa406ee3269265a91ca859659ef7fe (diff)
update stock vendor
Diffstat (limited to 'indoteknik_custom')
-rwxr-xr-xindoteknik_custom/models/stock_vendor.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/indoteknik_custom/models/stock_vendor.py b/indoteknik_custom/models/stock_vendor.py
index 1e5bce16..e72748c3 100755
--- a/indoteknik_custom/models/stock_vendor.py
+++ b/indoteknik_custom/models/stock_vendor.py
@@ -1,5 +1,6 @@
from odoo import fields, models, api
import logging
+from datetime import datetime, timedelta
_logger = logging.getLogger(__name__)
@@ -16,6 +17,17 @@ class StockVendor(models.Model):
('done', 'Done')
], string="Cache Reset")
+ @api.model
+ def get_stock_updated_last_7_days(self, id):
+ date_7_days_ago = datetime.now() - timedelta(days=7)
+
+ stocks = self.search([
+ ('product_variant_id', '=', id),
+ ('write_date', '>=', date_7_days_ago.strftime("%Y-%m-%d %H:%M:%S"))
+ ], limit=1)
+
+ return stocks
+
def cache_reset(self):
stocks = self.env['stock.vendor'].search([
('cache_reset_status', '=', 'reset'),