diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-11-11 16:10:44 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-11-11 16:10:44 +0700 |
| commit | c8ce7890c7174ea678da282e3fa04501b24951bc (patch) | |
| tree | f007d7bed000bdfa38f64d85af122f1d65b5c565 /indoteknik_custom/models/crm_lead.py | |
| parent | 4c2325d4a983ced3a25a9d53d7613a9186360b17 (diff) | |
| parent | 17d46cf9f4eede8177b2373c03d5b36123f712c1 (diff) | |
Merge branch 'production' into iman/request-renca-stock
Diffstat (limited to 'indoteknik_custom/models/crm_lead.py')
| -rwxr-xr-x | indoteknik_custom/models/crm_lead.py | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/indoteknik_custom/models/crm_lead.py b/indoteknik_custom/models/crm_lead.py index b0d3430c..078d9810 100755 --- a/indoteknik_custom/models/crm_lead.py +++ b/indoteknik_custom/models/crm_lead.py @@ -31,6 +31,8 @@ class CrmLead(models.Model): if rec.email_from == 'api.noreply@altama.co.id' and rec.name.startswith('INDOTEKNIK|ODOO|'): rec.user_id = 20 # User ID: Nabila Rahmawati + if not rec.user_id: + rec.user_id = 2 # User ID: Sales return rec @api.onchange('user_id') @@ -98,7 +100,27 @@ class CrmLead(models.Model): lead.user_id = salesperson_id - def _cancel_pipeline(self, delta=48): + def _update_pipeline(self, delta=48, limit=100): + # Get the current time + current_time = datetime.now() + + # Calculate the time 24 hours ago + time_48_hours_ago = current_time - timedelta(hours=delta) + + # Define the allowed states + allowed_states = ['sale', 'done'] + + # Search for sale orders with date_order greater than 24 hours ago and opportunity_id is null + orders = self.env['sale.order'].search([ + ('write_date', '>=', time_48_hours_ago), + ('opportunity_id', '!=', False), + ('state', 'in', allowed_states) + ], limit=limit) + for order in orders: + order.opportunity_id.stage_id = 4 + _logger.info('finish order stage pipeline %s' % order.id) + + def _cancel_pipeline(self, delta=48, limit=100): # Get the current time current_time = datetime.now() @@ -113,12 +135,12 @@ class CrmLead(models.Model): ('write_date', '>=', time_48_hours_ago), ('opportunity_id', '!=', False), ('state', 'in', allowed_states) - ]) + ], limit=limit) for order in orders: order.opportunity_id.stage_id = 7 _logger.info('cancel order stage pipeline %s' % order.id) - def _convert_to_pipeline(self, delta=48): + def _convert_to_pipeline(self, delta=48, limit=100): # Get the current time current_time = datetime.now() @@ -133,7 +155,7 @@ class CrmLead(models.Model): ('write_date', '>=', time_48_hours_ago), ('opportunity_id', '=', False), ('state', 'in', allowed_states) - ]) + ], limit=limit) # stage # 1 potensi baru, 2 proses quotation, 3 proses lain visit, 4 proses berhasil, 5 proses negosiasi, 7 tidak terpakai / gagal for order in orders: |
