From bfaee558997160c891a394a9862ad338a494337f Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 29 Sep 2023 16:54:54 +0700 Subject: delete weekly solr & Helper by di Quotation / SO --- indoteknik_custom/models/sale_order.py | 9 ++++++++- indoteknik_custom/models/solr/apache_solr_queue.py | 11 ++++++++++- indoteknik_custom/views/apache_solr_queue.xml | 15 +++++++++++++++ indoteknik_custom/views/sale_order.xml | 3 +++ 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 71163fa4..e201496a 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -1,6 +1,6 @@ from odoo import fields, models, api, _ from odoo.exceptions import UserError -import logging, random, string, requests, math, json, re +import logging, random, string, requests, math, json, re _logger = logging.getLogger(__name__) @@ -80,6 +80,7 @@ class SaleOrder(models.Model): estimated_arrival_days = fields.Integer('Estimated Arrival Days', default=0) email = fields.Char(string='Email') picking_iu_id = fields.Many2one('stock.picking', 'Picking IU') + helper_by_id = fields.Many2one('res.users', 'Helper By') @api.model def action_multi_update_state(self): @@ -246,6 +247,12 @@ class SaleOrder(models.Model): minimum_amount = 20000000 for order in self: order.have_visit_service = self.amount_total > minimum_amount + + def write(self, values): + if self.env.user.id in [991, 20, 1180]: + values['helper_by_id'] = self.env.user.id + + return super(SaleOrder, self).write(values) def check_due(self): """To show the due amount and warning stage""" diff --git a/indoteknik_custom/models/solr/apache_solr_queue.py b/indoteknik_custom/models/solr/apache_solr_queue.py index 6a5b480f..8dd7c273 100644 --- a/indoteknik_custom/models/solr/apache_solr_queue.py +++ b/indoteknik_custom/models/solr/apache_solr_queue.py @@ -1,5 +1,5 @@ from odoo import models, fields -from datetime import datetime +from datetime import datetime, timedelta import logging, time @@ -72,3 +72,12 @@ class ApacheSolrQueue(models.Model): if count == 0: self.create(payload) + def delete_weekly_solr(self, limit=500): + solr = self.search([ + ('execute_status', '=', 'success'), + ('execute_date', '>=', (datetime.utcnow() - timedelta(days=7))), + ], limit=limit) + for rec in solr: + rec.unlink() + + diff --git a/indoteknik_custom/views/apache_solr_queue.xml b/indoteknik_custom/views/apache_solr_queue.xml index 3861fd20..9685ef06 100644 --- a/indoteknik_custom/views/apache_solr_queue.xml +++ b/indoteknik_custom/views/apache_solr_queue.xml @@ -57,6 +57,21 @@ records.execute_queue() + + + Solr Queue: Delete Weekly + 14 + minutes + -1 + + + model.delete_weekly_solr() + code + 65 + True + + + Solr Queue: Process diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index bc098f18..0d972ec1 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -41,6 +41,9 @@ 1 + + + -- cgit v1.2.3