Advertisement
SherinKR

opportunity_list.js

Jan 23rd, 2024
660
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. frappe.listview_settings['Opportunity'] = {
  2.   add_fields: ["customer_name", "opportunity_type", "opportunity_from", "status"],
  3.   get_indicator: function(doc) {
  4.     var indicator = [__(doc.status), frappe.utils.guess_colour(doc.status), "status,=," + doc.status];
  5.     if(doc.status=="Quotation") {
  6.       indicator[1] = "green";
  7.     }
  8.     if(doc.status=="Design Requested") {
  9.       indicator[1] = "blue";
  10.     }
  11.     if(doc.status=="Approved") {
  12.       indicator[1] = "green";
  13.     }
  14.     if(doc.status=="ECL Updated"){
  15.       indicator[1] = "blue";
  16.     }
  17.     return indicator;
  18.   },
  19.   onload: function(listview) {
  20.     let roles = frappe.user_roles
  21.     listview.page.add_actions_menu_item(__("Assign"), function() {
  22.       Assign(listview)
  23.     })
  24.   },
  25.   refresh:function(listview) {
  26.     listview.page.actions.find('[data-label="Edit"]').parent().parent().remove()
  27.     listview.page.actions.find('[data-label="Assign%20To"]').parent().parent().remove()
  28.     listview.page.actions.find('[data-label="Design%20Request"]').parent().parent().remove()
  29.     listview.page.actions.find('[data-label="Approve"]').parent().parent().remove()
  30.     listview.page.actions.find('[data-label="Reject"]').parent().parent().remove()
  31.   },
  32.   hide_name_column: true,
  33. }
  34.  
  35. let Assign = function(listview) {
  36.   let docnames = listview.get_checked_items(true);
  37.   let d = new frappe.ui.Dialog({
  38.     title: 'Add to ToDo',
  39.     fields: [
  40.       {
  41.         label: 'User',
  42.         fieldname: 'user',
  43.         fieldtype: 'Link',
  44.         options:"User",
  45.         reqd: 1,
  46.         get_query: function () {
  47.           return {
  48.             query : 'idms.idms.utils.user_query',
  49.           };
  50.         }
  51.       },
  52.       {
  53.         fieldtype: 'Section Break'
  54.       },
  55.       {
  56.         label: __("Complete By"),
  57.         fieldtype: 'Date',
  58.         fieldname: 'date'
  59.       },
  60.       {
  61.         fieldtype: 'Column Break'
  62.       },
  63.       {
  64.         label: __("Priority"),
  65.         fieldtype: 'Select',
  66.         fieldname: 'priority',
  67.         options: [
  68.           {
  69.             value: 'Low',
  70.             label: __('Low')
  71.           },
  72.           {
  73.             value: 'Medium',
  74.             label: __('Medium')
  75.           },
  76.           {
  77.             value: 'High',
  78.             label: __('High')
  79.           }
  80.         ],
  81.         // Pick up priority from the source document, if it exists and is available in ToDo
  82.         default: 'Medium',
  83.       },
  84.       {
  85.         fieldtype: 'Section Break'
  86.       },
  87.       {
  88.         label: __("Comment"),
  89.         fieldtype: 'Small Text',
  90.         fieldname: 'description'
  91.       },
  92.     ],
  93.     primary_action_label: 'Submit',
  94.     primary_action(values) {
  95.       set_assign_to(values, docnames, listview)
  96.       d.hide();
  97.     }
  98.   });
  99.   d.show();
  100. }
  101.  
  102. let set_assign_to = function (values, docnames, listview) {
  103.   frappe.call({
  104.     method: "idms.idms.doc_events.opportunity.set_assign_to",
  105.     args: {
  106.       'docnames': docnames,
  107.       'user':values.user,
  108.       'priority':values.priority,
  109.       'date':values.date,
  110.       'description':values.description
  111.     },
  112.     callback: function(r) {
  113.         listview.refresh()
  114.     }
  115.   })
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement