summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2024-10-15 15:34:36 +0700
committerstephanchrst <stephanchrst@gmail.com>2024-10-15 15:34:36 +0700
commit65436a03d40cd31e0111727fe6c84380eba005d5 (patch)
tree6c2649eb3a55e6ae1d5e1883023ac2b65486fbf7
parent02499d14bb9e6cd5063df0ef3ad00e362a99fbde (diff)
update pipeline
-rwxr-xr-xindoteknik_custom/models/crm_lead.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/indoteknik_custom/models/crm_lead.py b/indoteknik_custom/models/crm_lead.py
index eac75cb0..de2bdb12 100755
--- a/indoteknik_custom/models/crm_lead.py
+++ b/indoteknik_custom/models/crm_lead.py
@@ -98,6 +98,26 @@ class CrmLead(models.Model):
lead.user_id = salesperson_id
+ 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()