diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2023-09-29 16:54:54 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2023-09-29 16:54:54 +0700 |
| commit | bfaee558997160c891a394a9862ad338a494337f (patch) | |
| tree | 2b68f1fb4eb762911934149641ae04e25fd06377 | |
| parent | 0bb47005022b33c79ecfb5924d41f35ce794c5fb (diff) | |
delete weekly solr & Helper by di Quotation / SO
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 9 | ||||
| -rw-r--r-- | indoteknik_custom/models/solr/apache_solr_queue.py | 11 | ||||
| -rw-r--r-- | indoteknik_custom/views/apache_solr_queue.xml | 15 | ||||
| -rwxr-xr-x | 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 @@ -58,6 +58,21 @@ </record> <data noupdate="1"> + <record id="cron_apache_solr_queue_delete" model="ir.cron"> + <field name="name">Solr Queue: Delete Weekly</field> + <field name="interval_number">14</field> + <field name="interval_type">minutes</field> + <field name="numbercall">-1</field> + <field name="doall" eval="False"/> + <field name="model_id" ref="model_apache_solr_queue"/> + <field name="code">model.delete_weekly_solr()</field> + <field name="state">code</field> + <field name="priority">65</field> + <field name="active">True</field> + </record> + </data> + + <data noupdate="1"> <record id="cron_apache_solr_queue_process" model="ir.cron"> <field name="name">Solr Queue: Process</field> <field name="interval_number">6</field> 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 @@ <field name="source_id" position="attributes"> <attribute name="invisible">1</attribute> </field> + <field name="user_id" position="after"> + <field name="helper_by_id" readonly="1"/> + </field> <field name="analytic_account_id" position="after"> <field name="customer_type" attrs="{'required': ['|', ('create_date', '>', '2023-06-28'), ('create_date', '=', False)]}"/> <field name="npwp" placeholder='99.999.999.9-999.999' attrs="{'required': ['|', ('create_date', '>', '2023-06-28'), ('create_date', '=', False)]}"/> |
