diff --git a/rigpl_erpnext/hooks.py b/rigpl_erpnext/hooks.py index 896b8a6b..e4c4f5dd 100755 --- a/rigpl_erpnext/hooks.py +++ b/rigpl_erpnext/hooks.py @@ -194,9 +194,6 @@ "rigpl_erpnext.rigpl_erpnext.scheduled_tasks.variant_copy.check_wrong_variants" # Runs everyday at 2:10 AM ], - "*/16 * * * *": [ - "rigpl_erpnext.rigpl_erpnext.scheduled_tasks.indiamart.execute" - ], "10 3 * * *": [ "rigpl_erpnext.rigpl_erpnext.scheduled_tasks.item_valuation_rate.set_valuation_rate_for_all" # Runs everyday at 3:10 AM @@ -207,7 +204,8 @@ ], "daily": [ "rigpl_erpnext.rigpl_erpnext.scheduled_tasks.permission_check.check_permission_exist", - "rigpl_erpnext.rigpl_erpnext.scheduled_tasks.work_order_status.execute" + "rigpl_erpnext.rigpl_erpnext.scheduled_tasks.work_order_status.execute", + "rigpl_erpnext.rigpl_erpnext.scheduled_tasks.indiamart.execute" ], "hourly": [ diff --git a/rigpl_erpnext/rigpl_erpnext/doctype/carrier_tracking/carrier_tracking.py b/rigpl_erpnext/rigpl_erpnext/doctype/carrier_tracking/carrier_tracking.py index 46b380da..f1dacc9e 100644 --- a/rigpl_erpnext/rigpl_erpnext/doctype/carrier_tracking/carrier_tracking.py +++ b/rigpl_erpnext/rigpl_erpnext/doctype/carrier_tracking/carrier_tracking.py @@ -50,10 +50,14 @@ def validate(self): else: self.docstatus = 1 if self.published == 1: - self.route = self.document_name.lower() + self.name.lower() + self.route = self.name.lower() else: self.route = "" trans_doc = frappe.get_doc("Transporters", self.carrier_name) + if trans_doc.track_on_shipway != 1 and trans_doc.fedex_credentials != 1 and trans_doc.fedex_tracking_only != 1: + if trans_doc.docstatus != 1: + trans_doc.docstatus = 1 + trans_doc.manual_exception_removed = 1 self.update_fields(trans_doc) from_address_doc = frappe.get_doc("Address", self.from_address) to_address_doc = frappe.get_doc("Address", self.to_address) @@ -82,7 +86,7 @@ def auto_submit_ctrack(self, trans_doc): def on_submit(self): self.published = 1 - self.route = self.document_name.lower() + self.name.lower() + self.route = self.name.lower() self.push_data_to_sales_invoice() def on_cancel(self): @@ -189,7 +193,7 @@ def non_fedex_validations(self): if re.sub('[^A-Za-z0-9]+', '', str(self.awb_number)) != si_awb or \ si_doc.transporters != self.carrier_name: create_new_carrier_track(si_doc, frappe) - self.submit(ignore_permissions = True) + self.submit() # self.save(ignore_permissions=True) #else: #self.awb_number = si_doc.lr_no @@ -329,7 +333,7 @@ def book_shipment(self): if packages.idx == 1: shipment_booking(self) self.published = 1 - self.route = self.document_name.lower() + self.name.lower() + self.route = self.name.lower() self.docstatus = 1 self.save(ignore_permissions=True) else: @@ -380,12 +384,12 @@ def set_recipient_email(self, to_address_doc, contact_doc): if len(str(to_address_doc.email_id) + ", " + str(contact_doc.email_id)) < 140: self.customer_emails = str(to_address_doc.email_id) + ", " + str(contact_doc.email_id) else: - if len(contact_doc.email_id) < 140: + if len(str(contact_doc.email_id)) < 140: self.customer_emails = contact_doc.email_id elif len(to_address_doc.email_id) < 140: self.customer_emails = to_address_doc.email_id else: - if len(contact_doc.email_id) < 140: + if len(str(contact_doc.email_id)) < 140: self.customer_emails = contact_doc.email_id elif len(to_address_doc.email_id) < 140: self.customer_emails = to_address_doc.email_id diff --git a/rigpl_erpnext/rigpl_erpnext/scheduled_tasks/shipment_data_update.py b/rigpl_erpnext/rigpl_erpnext/scheduled_tasks/shipment_data_update.py index fb10665d..f282f020 100644 --- a/rigpl_erpnext/rigpl_erpnext/scheduled_tasks/shipment_data_update.py +++ b/rigpl_erpnext/rigpl_erpnext/scheduled_tasks/shipment_data_update.py @@ -135,12 +135,17 @@ def get_all_ship_data(): track_doc = frappe.get_doc("Carrier Tracking", tracks.name) getOrderShipmentDetails(track_doc) else: - print("{}. Tracking was updated less than 6 hrs ago hence skipping {}".format(str(sno+1), tracks.name)) + print("{}. Fedex Tracking was updated less than 6 hrs ago hence skipping {}". + format(str(sno+1), tracks.name)) elif (tracks.cred == 0 and tracks.tracking_only == 0) and days_diff < 60: - # Get from Shipway only less than 90 days old shipments - print("{}. Getting Tracking for {} from Shipway".format(str(sno+1), tracks.name)) - track_doc = frappe.get_doc("Carrier Tracking", tracks.name) - getOrderShipmentDetails(track_doc) + # Get from Shipway only less than 60 days old shipments + if last_update_hrs > 6: + print("{}. Getting Tracking for {} from Shipway".format(str(sno+1), tracks.name)) + track_doc = frappe.get_doc("Carrier Tracking", tracks.name) + getOrderShipmentDetails(track_doc) + else: + print("{}. Shipway Tracking was updated less than 6 hrs ago hence skipping {}". + format(str(sno + 1), tracks.name)) #track_doc.flags.ignore_permissions = True sno += 1 diff --git a/rigpl_erpnext/rigpl_erpnext/validations/sales_invoice.py b/rigpl_erpnext/rigpl_erpnext/validations/sales_invoice.py index bf90b1de..1671ea97 100755 --- a/rigpl_erpnext/rigpl_erpnext/validations/sales_invoice.py +++ b/rigpl_erpnext/rigpl_erpnext/validations/sales_invoice.py @@ -234,8 +234,9 @@ def check_existing_track(doctype, docname): def is_tracked_transporter(doc, method): fedex = frappe.get_value("Transporters", doc.transporters, "fedex_credentials") + fedex_track = frappe.get_value("Transporters", doc.transporters, "fedex_tracking_only") shipway = frappe.get_value("Transporters", doc.transporters, "track_on_shipway") - if fedex == 1 or shipway == 1: + if fedex == 1 or shipway == 1 or fedex_track == 1: ttrans = 1 else: ttrans = 0