diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2023-07-22 11:12:14 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2023-07-22 11:12:14 +0700 |
| commit | 2a1179b22cd1b8ee9e3e31c157821dbbeb66195f (patch) | |
| tree | 89f85127c41b13c95db04725771ed7f78a379798 | |
| parent | f4c02f0ca17c0c72314334c03417c2f54382dfa1 (diff) | |
fix bug api product sla stock vendor
| -rw-r--r-- | indoteknik_api/controllers/api_v1/product.py | 6 | ||||
| -rwxr-xr-x | indoteknik_custom/models/stock_vendor.py | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/indoteknik_api/controllers/api_v1/product.py b/indoteknik_api/controllers/api_v1/product.py index 3667a787..587773ee 100644 --- a/indoteknik_api/controllers/api_v1/product.py +++ b/indoteknik_api/controllers/api_v1/product.py @@ -13,12 +13,14 @@ class Product(controller.Controller): prefix = '/api/v1/' @http.route(prefix + 'product_variant/<id>/stock', auth='public', methods=['GET', 'OPTIONS']) - @controller.Controller.must_authorized() + # @controller.Controller.must_authorized() def get_product_template_stock_by_id(self, **kw): id = int(kw.get('id')) product = request.env['product.product'].search([('id', '=', id)], limit=1) product_sla = request.env['product.sla'].search([('product_variant_id', '=', id)], limit=1) - stock_vendor = self.env['stock.vendor'].get_stock_updated_last_7_days(id) + stock_vendor = request.env['stock.vendor'].search([('product_variant_id', '=', id)], limit=1) + + stock_vendor = stock_vendor.get_stock_updated_last_7_days() qty_available = product.qty_onhand_bandengan diff --git a/indoteknik_custom/models/stock_vendor.py b/indoteknik_custom/models/stock_vendor.py index e72748c3..dcbeb399 100755 --- a/indoteknik_custom/models/stock_vendor.py +++ b/indoteknik_custom/models/stock_vendor.py @@ -17,12 +17,10 @@ class StockVendor(models.Model): ('done', 'Done') ], string="Cache Reset") - @api.model - def get_stock_updated_last_7_days(self, id): + def get_stock_updated_last_7_days(self): 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) |
