From 80433401aeba163a03f0f30902332331338b005f Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 15 Oct 2024 09:12:20 +0700 Subject: remove set npwp and sppkp while confirm sales order for disruption --- indoteknik_custom/models/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index c1c2c267..2e0b5775 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -943,7 +943,7 @@ class SaleOrder(models.Model): return self._create_approval_notification('Sales Manager') order.approval_status = 'approved' - order._set_sppkp_npwp_contact() + # order._set_sppkp_npwp_contact() order.calculate_line_no() order.send_notif_to_salesperson() # order.order_line.get_reserved_from() -- cgit v1.2.3 From 1833d42fe880ca3c63630c46d1b2e4f19e89c9ab Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 15 Oct 2024 09:20:19 +0700 Subject: disable update if not null in npwp sppkp contact while confirm so --- indoteknik_custom/models/sale_order.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 2e0b5775..e6382cd9 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -943,7 +943,7 @@ class SaleOrder(models.Model): return self._create_approval_notification('Sales Manager') order.approval_status = 'approved' - # order._set_sppkp_npwp_contact() + order._set_sppkp_npwp_contact() order.calculate_line_no() order.send_notif_to_salesperson() # order.order_line.get_reserved_from() @@ -1024,11 +1024,20 @@ class SaleOrder(models.Model): def _set_sppkp_npwp_contact(self): partner = self.partner_id.parent_id or self.partner_id - if not partner.sppkp or not partner.npwp or not partner.email or partner.customer_type: - partner.customer_type = self.customer_type - partner.npwp = self.npwp + if not partner.sppkp: partner.sppkp = self.sppkp + if not partner.npwp: + partner.npwp = self.npwp + if not partner.email: partner.email = self.email + if not partner.customer_type: + partner.customer_type = self.customer_type + + # if not partner.sppkp or not partner.npwp or not partner.email or partner.customer_type: + # partner.customer_type = self.customer_type + # partner.npwp = self.npwp + # partner.sppkp = self.sppkp + # partner.email = self.email def _compute_total_margin(self): for order in self: -- cgit v1.2.3 From 387fe06b8d8d212172a1ef0a61ad2657f618ec1b Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 15 Oct 2024 11:33:36 +0700 Subject: scheduled action for pipeline --- indoteknik_custom/models/crm_lead.py | 71 +++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/crm_lead.py b/indoteknik_custom/models/crm_lead.py index 9ffd607c..b0d3430c 100755 --- a/indoteknik_custom/models/crm_lead.py +++ b/indoteknik_custom/models/crm_lead.py @@ -2,6 +2,7 @@ from odoo import fields, models, api import logging import random from odoo.exceptions import AccessError, UserError, ValidationError +from datetime import datetime, timedelta _logger = logging.getLogger(__name__) @@ -97,4 +98,72 @@ class CrmLead(models.Model): lead.user_id = salesperson_id - + def _cancel_pipeline(self, delta=48): + # 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 = ['cancel'] + + # 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) + ]) + 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): + # 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 = ['draft', 'done', 'sale', 'sent', 'cancel'] + + # 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) + ]) + # 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: + # stage_id = 2 + if order.state == 'sale' or order.state == 'done': + stage_id = 4 + elif order.state == 'sent': + stage_id = 5 + elif order.state == 'cancel': + stage_id = 7 + else: + stage_id = 2 + crm_lead = self.env['crm.lead'].create([{ + 'email_normalized': order.email, + 'name': order.name, + 'user_id': order.user_id.id, + 'company_id': 1, + 'type': 'opportunity', + 'priority': 0, + 'team_id': order.team_id.id, + 'stage_id': stage_id, + 'expected_revenue': order.amount_untaxed, + 'partner_id': order.partner_id.parent_id.id or order.partner_id.id, + 'contact_name': order.partner_id.name, + 'partner_name': order.partner_id.parent_id.name or order.partner_id.name, + 'phone': order.partner_id.mobile, + 'street': order.partner_id.street, + 'street2': order.partner_id.street2, + 'zip': order.partner_id.zip, + 'order_id': order.id + }]) + order.opportunity_id = crm_lead.id + _logger.info('convert order to opportunity %s' % crm_lead.id) -- cgit v1.2.3 From 0b5623adc1c6d6f5ef7a4d68f42bcf2f524107c1 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 15 Oct 2024 12:05:53 +0700 Subject: update code ambil data stock mandatory ke stock awailable --- indoteknik_api/controllers/api_v1/product.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/indoteknik_api/controllers/api_v1/product.py b/indoteknik_api/controllers/api_v1/product.py index e779e623..8fe48932 100644 --- a/indoteknik_api/controllers/api_v1/product.py +++ b/indoteknik_api/controllers/api_v1/product.py @@ -73,7 +73,10 @@ class Product(controller.Controller): total_adem = qty_altama if qty_available > 0: - qty = qty_available + total_adem + total_excell + qty = qty_available + sla_date = '1 Hari' + elif qty_available > 0 and qty_altama > 0: + qty = qty_available sla_date = '1 Hari' elif qty_altama > 0 or qty_vendor > 0: qty = total_adem if qty_altama > 0 else total_excell -- cgit v1.2.3 From 6ae562de235d0a150db594d93522e2ad3b395aa8 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 15 Oct 2024 14:32:30 +0700 Subject: add limit to pipeline --- indoteknik_custom/models/crm_lead.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/indoteknik_custom/models/crm_lead.py b/indoteknik_custom/models/crm_lead.py index b0d3430c..eac75cb0 100755 --- a/indoteknik_custom/models/crm_lead.py +++ b/indoteknik_custom/models/crm_lead.py @@ -98,7 +98,7 @@ class CrmLead(models.Model): lead.user_id = salesperson_id - def _cancel_pipeline(self, delta=48): + def _cancel_pipeline(self, delta=48, limit=100): # Get the current time current_time = datetime.now() @@ -113,12 +113,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 +133,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: -- cgit v1.2.3 From 02499d14bb9e6cd5063df0ef3ad00e362a99fbde Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 15 Oct 2024 14:46:26 +0700 Subject: add 1 nol agar npwp jadi 16 angka --- indoteknik_api/controllers/api_v1/user.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_api/controllers/api_v1/user.py b/indoteknik_api/controllers/api_v1/user.py index c7bfe91a..e4f8b97f 100644 --- a/indoteknik_api/controllers/api_v1/user.py +++ b/indoteknik_api/controllers/api_v1/user.py @@ -248,7 +248,7 @@ class User(controller.Controller): if type_acc == 'individu': user.partner_id.customer_type = 'nonpkp' - user.partner_id.npwp = '0.000.000.0-000.000' + user.partner_id.npwp = '00.000.000.0-000.000' user.partner_id.sppkp = '-' user.partner_id.nama_wajib_pajak = name user.partner_id.user_id = 3222 -- cgit v1.2.3 From 65436a03d40cd31e0111727fe6c84380eba005d5 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 15 Oct 2024 15:34:36 +0700 Subject: update pipeline --- indoteknik_custom/models/crm_lead.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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() -- cgit v1.2.3