[cleanup] item grid views, removed desc etc

This commit is contained in:
Rushabh Mehta 2015-02-19 20:05:45 +05:30
parent c7a11cc451
commit 50dc4e90e3
17 changed files with 915 additions and 897 deletions

View File

@ -81,7 +81,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.add_custom_button(__('Opportunity Lost'),
cur_frm.cscript['Declare Opportunity Lost'], "icon-remove", "btn-default");
}
}
@ -94,7 +94,7 @@ cur_frm.cscript.item_code = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if (d.item_code) {
return frappe.call({
method: "erpnext.selling.doctype.opportunity.opportunity.get_item_details",
method: "erpnext.crm.doctype.opportunity.opportunity.get_item_details",
args: {"item_code":d.item_code},
callback: function(r, rt) {
if(r.message) {

View File

@ -58,7 +58,10 @@ class Opportunity(TransactionBase):
where q.name = qi.parent and q.docstatus=1 and qi.prevdoc_docname =%s and q.status = 'Ordered'""", self.name)
def validate_cust_name(self):
self.customer_name = self.customer or self.lead
if self.customer:
self.customer_name = frappe.db.get_value("Customer", self.customer, "customer_name")
elif self.lead:
self.customer_name = frappe.db.get_value("Lead", self.lead, "lead_name")
def get_cust_address(self,name):
details = frappe.db.sql("""select customer_name, address, territory, customer_group

View File

@ -20,14 +20,6 @@
"permlevel": 0,
"width": "50%"
},
{
"fieldname": "image_view",
"fieldtype": "Image",
"in_list_view": 0,
"label": "Image View",
"options": "image",
"permlevel": 0
},
{
"fieldname": "employee",
"fieldtype": "Data",
@ -71,9 +63,17 @@
},
{
"fieldname": "image",
"fieldtype": "Select",
"fieldtype": "Attach",
"label": "Image",
"options": "attach_files:",
"options": "",
"permlevel": 0
},
{
"fieldname": "image_view",
"fieldtype": "Image",
"in_list_view": 0,
"label": "Image View",
"options": "image",
"permlevel": 0
},
{
@ -674,7 +674,7 @@
],
"icon": "icon-user",
"idx": 1,
"modified": "2015-02-05 05:11:38.234802",
"modified": "2015-02-19 09:28:40.628101",
"modified_by": "Administrator",
"module": "HR",
"name": "Employee",

View File

@ -53,7 +53,7 @@
},
{
"depends_on": "",
"description": "Bill of Material to be considered for manufacturing",
"description": "",
"fieldname": "bom_no",
"fieldtype": "Link",
"in_list_view": 0,
@ -94,7 +94,7 @@
"reqd": 1
},
{
"description": "Automatically updated via Stock Entry",
"description": "",
"fieldname": "material_transferred_for_qty",
"fieldtype": "Int",
"label": "Material Transferred for Qty",
@ -105,7 +105,7 @@
{
"default": "0",
"depends_on": "eval:doc.docstatus==1",
"description": "Automatically updated via Stock Entry of type Manufacture or Repack",
"description": "",
"fieldname": "produced_qty",
"fieldtype": "Float",
"label": "Manufactured Qty",
@ -360,7 +360,7 @@
"idx": 1,
"in_create": 0,
"is_submittable": 1,
"modified": "2015-02-19 03:58:23.460022",
"modified": "2015-02-19 06:00:33.277637",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "Production Order",

View File

@ -12,10 +12,10 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend(
if(doc.docstatus==1) {
if(doc.status != 'Stopped') {
cur_frm.dashboard.add_progress(cint(doc.per_delivered) + __("% Delivered"),
doc.per_delivered);
cur_frm.dashboard.add_progress(cint(doc.per_billed) + __("% Billed"),
doc.per_billed);
// cur_frm.dashboard.add_progress(cint(doc.per_delivered) + __("% Delivered"),
// doc.per_delivered);
// cur_frm.dashboard.add_progress(cint(doc.per_billed) + __("% Billed"),
// doc.per_billed);
// delivery note
if(flt(doc.per_delivered, 2) < 100 && ["Sales", "Shopping Cart"].indexOf(doc.order_type)!==-1)

View File

@ -147,9 +147,9 @@
},
{
"fieldname": "logo",
"fieldtype": "Select",
"fieldtype": "Attach",
"label": "Logo",
"options": "attach_files:",
"options": "",
"permlevel": 0
},
{
@ -200,7 +200,7 @@
"icon": "icon-user",
"idx": 1,
"in_create": 0,
"modified": "2015-02-05 05:11:46.087123",
"modified": "2015-02-19 09:26:41.397649",
"modified_by": "Administrator",
"module": "Setup",
"name": "Sales Partner",

View File

@ -37,7 +37,8 @@ class Bin(Document):
"item_code": self.item_code,
"warehouse": self.warehouse,
"posting_date": args.get("posting_date"),
"posting_time": args.get("posting_time")
"posting_time": args.get("posting_time"),
"voucher_no": args.get("voucher_no")
}, allow_negative_stock=allow_negative_stock)
def update_qty(self, args):

View File

@ -72,8 +72,17 @@ frappe.ui.form.on("Item", "onload", function(frm) {
response($.map(r.message, function(d) { return d.attribute_value; }));
}
});
}
})
},
select: function(event, ui) {
field.$input.val(ui.item.value);
field.$input.trigger("change");
},
focus: function( event, ui ) {
if(ui.item.action) {
return false;
}
},
});
}
});

File diff suppressed because it is too large Load Diff

View File

@ -246,8 +246,6 @@ class Item(WebsiteGenerator):
for attr in template.variant_attributes[variant.item_code]:
variant.description += "\n" + attr[0] + ": " + attr[1]
if variant.description_html:
variant.description_html += "<div style='margin-top: 4px; font-size: 80%'>" + attr[0] + ": " + attr[1] + "</div>"
variant.variant_of = template.name
variant.has_variants = 0
variant.show_in_website = 0

View File

@ -1,3 +1,10 @@
frappe.listview_settings['Item'] = {
add_fields: ["item_name", "stock_uom", "item_group", "image"]
add_fields: ["item_name", "stock_uom", "item_group", "image", "variant_of", "has_variants"],
get_indicator: function(doc) {
if(doc.has_variants) {
return [__("Template"), "blue", "has_variant,=,1"]
} else if(doc.variant_of) {
return [__("Variant"), "green", "variant_of,=," + doc.variant_of]
}
}
};

View File

@ -63,6 +63,7 @@ class StockEntry(StockController):
self.validate_return_reference_doc()
self.validate_with_material_request()
#self.validate_valuation_rate()
self.set_total_incoming_outgoing_value()
self.set_total_amount()
def on_submit(self):

View File

@ -106,6 +106,7 @@ class update_entries_after(object):
self.build()
def build(self):
# includes current entry!
entries_to_fix = self.get_sle_after_datetime()
for sle in entries_to_fix:
@ -169,7 +170,6 @@ class update_entries_after(object):
self.qty_after_transaction += flt(sle.actual_qty)
self.stock_value = sum((flt(batch[0]) * flt(batch[1]) for batch in self.stock_queue))
# rounding as per precision
self.stock_value = flt(self.stock_value, self.precision)
@ -179,6 +179,7 @@ class update_entries_after(object):
# update current sle
sle.qty_after_transaction = self.qty_after_transaction
sle.valuation_rate = self.valuation_rate
sle.stock_value = self.stock_value
sle.stock_queue = json.dumps(self.stock_queue)
sle.stock_value_difference = stock_value_difference
sle.doctype="Stock Ledger Entry"
@ -252,14 +253,18 @@ class update_entries_after(object):
if not self.stock_queue:
self.stock_queue.append([0, 0])
if self.stock_queue[-1][0] > 0:
self.stock_queue.append([actual_qty, incoming_rate])
# last row has the same rate, just updated the qty
if self.stock_queue[-1][1]==incoming_rate:
self.stock_queue[-1][0] += actual_qty
else:
qty = self.stock_queue[-1][0] + actual_qty
if qty == 0:
self.stock_queue.pop(-1)
if self.stock_queue[-1][0] > 0:
self.stock_queue.append([actual_qty, incoming_rate])
else:
self.stock_queue[-1] = [qty, incoming_rate]
qty = self.stock_queue[-1][0] + actual_qty
if qty == 0:
self.stock_queue.pop(-1)
else:
self.stock_queue[-1] = [qty, incoming_rate]
else:
qty_to_pop = abs(actual_qty)
while qty_to_pop:
@ -299,7 +304,9 @@ class update_entries_after(object):
def get_sle_after_datetime(self):
"""get Stock Ledger Entries after a particular datetime, for reposting"""
return get_stock_ledger_entries(self.previous_sle or self.args, ">", "asc", for_update=True)
return get_stock_ledger_entries(self.previous_sle or frappe._dict({
"item_code": self.args.get("item_code"), "warehouse": self.args.get("warehouse") }),
">", "asc", for_update=True)
def raise_exceptions(self):
deficiency = min(e["diff"] for e in self.exceptions)
@ -329,7 +336,7 @@ def get_previous_sle(args, for_update=False):
sle = get_stock_ledger_entries(args, "<=", "desc", "limit 1", for_update=for_update)
return sle and sle[0] or {}
def get_stock_ledger_entries(previous_sle, operator=None, order="desc", limit=None, for_update=False):
def get_stock_ledger_entries(previous_sle, operator=None, order="desc", limit=None, for_update=False, debug=False):
"""get stock ledger entries filtered by specific posting datetime conditions"""
conditions = "timestamp(posting_date, posting_time) {0} timestamp(%(posting_date)s, %(posting_time)s)".format(operator)
if not previous_sle.get("posting_date"):
@ -351,7 +358,7 @@ def get_stock_ledger_entries(previous_sle, operator=None, order="desc", limit=No
"limit": limit or "",
"for_update": for_update and "for update" or "",
"order": order
}, previous_sle, as_dict=1)
}, previous_sle, as_dict=1, debug=debug)
def get_valuation_rate(item_code, warehouse, allow_zero_rate=False):
last_valuation_rate = frappe.db.sql("""select valuation_rate

View File

@ -9,43 +9,57 @@
</div>
{% } else { %}
<div class="row">
<div class="col-sm-6 col-xs-8"><strong>{%= doc.item_code %}</strong>
{% if(doc.item_name != doc.item_code) { %}
<br>{%= doc.item_name %}{% } %}
{% if(doc.item_name != doc.description) { %}
<p>{%= doc.description %}</p>{% } %}
<p>
{% if(doc.sales_order || doc.against_sales_order) { %}
<span class="label label-default" style="margin-right: 10px;"
title="{%= __("Sales Order") %}">
<i class="icon-file"></i>
{%= doc.sales_order || doc.against_sales_order %}
</span>
{% } %}
{% if(doc.warehouse) {
var label_class = "label-default",
title = "Warehouse",
actual_qty = (doc.doctype==="Sales Order"
? doc.projected_qty : doc.actual_qty);
<div class="col-sm-6 col-xs-8">
{% if(doc.warehouse) {
var label_class = "label-default",
title = "Warehouse",
actual_qty = (frm.doc.doctype==="Sales Order"
? doc.projected_qty : doc.actual_qty);
if(flt(frm.doc.per_delivered) < 100
&& in_list(["Sales Order Item", "Delivery Note Item"], doc.doctype)) {
if(actual_qty != undefined) {
if(actual_qty > doc.qty) {
var label_class = "label-success";
var title = "In Stock"
} else {
var label_class = "label-danger";
var title = "Not In Stock"
}
}
%}
<span style="margin-right: 10px;"
title="{%= title %}">
<span class="label {%= label_class %}">
{%= doc.warehouse %}
</span>
</span>
{% } %}
</p>
} %}
<span class="pull-right" title="{%= title %}">
<span class="label {%= label_class %}">
{%= doc.warehouse %}
</span>
</span>
{% } %}
{% if(in_list(["Sales Order Item", "Purchase Order Item"],
doc.doctype) && frm.doc.docstatus===1) {
var delivered = doc.doctype==="Sales Order Item" ?
doc.delivered_qty : doc.received_qty,
pending = flt(doc.qty) - flt(delivered);
%}
<span class="indicator {%= pending ? "orange" : "green" %}">{%= doc.item_code %}</span>
{% } else { %}
<strong>{%= doc.item_code %}</strong>
{% } %}
{% if(doc.item_name != doc.item_code) { %}
<br>{%= doc.item_name %}{% } %}
<!-- {% if(doc.item_name != doc.description) { %}
<p>{%= doc.description %}</p>{% } %} -->
<!-- <p>
{% if(doc.sales_order || doc.against_sales_order) { %}
<span class="label label-default" style="margin-right: 10px;"
title="{%= __("Sales Order") %}">
<i class="icon-file"></i>
{%= doc.sales_order || doc.against_sales_order %}
</span>
{% } %}
</p> -->
{% include "templates/form_grid/includes/visible_cols.html" %}
{% if(doc.schedule_date) { %}
<!-- {% if(doc.schedule_date) { %}
<div class="clearfix"></div>
<div>
{% if(frappe.datetime.get_diff(doc.schedule_date) < 1 && doc.received_qty < doc.qty) { %}
@ -58,23 +72,13 @@
</span>
{% } %}
</div>
{% } %}
{% } %} -->
</div>
<!-- qty -->
<div class="col-sm-2 hidden-xs text-right">
{%= doc.get_formatted("qty") %}
<br><small>{%= doc.uom || doc.stock_uom %}</small>
{% if(in_list(["Sales Order Item", "Purchase Order Item"],
doc.doctype) && frm.doc.docstatus===1) {
var delivered = doc.doctype==="Sales Order Item" ?
doc.delivered_qty : doc.received_qty,
completed =
100 - cint((flt(doc.qty) - flt(delivered)) * 100 / flt(doc.qty)),
title = __("Delivered");
%}
{% include "templates/form_grid/includes/progress.html" %}
{% } %}
<span class="small">{%= doc.uom || doc.stock_uom %}</span>
</div>
<!-- rate -->
@ -99,16 +103,6 @@
{%= doc.get_formatted("amount") %}
{% } %}
{% if(in_list(["Sales Order Item", "Purchase Order Item"],
doc.doctype) && frm.doc.docstatus===1 && doc.amount) {
var completed =
100 - cint((flt(doc.amount) - flt(doc.billed_amt)) * 100 / flt(doc.amount)),
title = __("Billed");
%}
<br><small>&nbsp;</small>
{% include "templates/form_grid/includes/progress.html" %}
{% } %}
{% if (frappe.perm.is_visible("rate", doc, frm.perm)) { %}
<div class="visible-xs text-muted">
{%= doc.get_formatted("qty") %} <small>{%= doc.uom || doc.stock_uom %}</small>

View File

@ -3,43 +3,47 @@
{% if(!doc) { %}
<div class="row">
<div class="col-sm-9">{%= __("Item") %}</div>
<div class="col-sm-3 text-right">{%= __("Qty") %}</div>
<div class="col-sm-4">{%= __("Item") %}</div>
<div class="col-sm-3">{%= __("Required On") %}</div>
<div class="col-sm-3">{%= __("Warehouse") %}</div>
<div class="col-sm-2 text-right">{%= __("Qty") %}</div>
</div>
{% } else { %}
<div class="row">
<div class="col-sm-9"><strong>{%= doc.item_code %}</strong>
<div class="col-sm-4">
<span class="indicator {%= (doc.qty==doc.ordered_qty) ? "green" : "orange" %}">{%= doc.item_code %}</strong>
{% if(doc.item_name != doc.item_code) { %}
<br>{%= doc.item_name %}{% } %}
{% if(doc.item_name != doc.description) { %}
<p>{%= doc.description %}</p>{% } %}
<div>
<!-- {% if(doc.item_name != doc.description) { %}
<p>{%= doc.description %}</p>{% } %} -->
{% include "templates/form_grid/includes/visible_cols.html" %}
</div>
<div class="col-sm-3">
{% if(doc.schedule_date) { %}
<span title="{%= __("Reqd By Date") %}" class="{%=
(frappe.datetime.get_diff(doc.schedule_date, frappe.datetime.get_today()) < 0
&& doc.ordered_qty < doc.qty)
? "text-danger" : "text-muted" %}">
{%= doc.get_formatted("schedule_date") %}</span>
{% } %}
</div>
<!-- warehouse -->
<div class="col-sm-3">
{% if(doc.warehouse) { %}
<span class="label label-default" title="{%= __("For Warehouse") %}"
style="margin-right: 10px;">
{%= doc.warehouse %}
</span>
{% } %}
{% if(doc.schedule_date) { %}
<span title="{%= __("Reqd By Date") %}" class="label {%=
(frappe.datetime.get_diff(doc.schedule_date, frappe.datetime.get_today()) < 0
&& doc.ordered_qty < doc.qty)
? "label-danger" : "label-default" %}">
{%= doc.get_formatted("schedule_date") %}</span>
{% } %}
</div>
{% include "templates/form_grid/includes/visible_cols.html" %}
</div>
</div>
<!-- qty -->
<div class="col-sm-3 text-right">
<div class="col-sm-2 text-right">
{%= doc.get_formatted("qty") %}
<div class="small">{%= doc.uom || doc.stock_uom %}</div>
{% if(doc.qty == doc.ordered_qty) { %}
<div class="small text-success">{%= __("Ordered") %}</div>
{% } else { %}
<div class="small text-muted">{%= __("{0} Ordered", doc.ordered_qty) %}</div>
{% } %}
<span class="small">{%= doc.uom || doc.stock_uom %}</span>
</div>
</div>
{% } %}

View File

@ -15,8 +15,8 @@
<div class="col-sm-5 col-xs-4"><strong>{%= doc.item_code %}</strong>
{% if(doc.item_name != doc.item_code) { %}
<br>{%= doc.item_name %}{% } %}
{% if(doc.item_name != doc.description) { %}
<p>{%= doc.description %}</p>{% } %}
<!-- {% if(doc.item_name != doc.description) { %}
<p>{%= doc.description %}</p>{% } %} -->
{% include "templates/form_grid/includes/visible_cols.html" %}
{% if(frm.doc.docstatus==0 && doc.s_warehouse && doc.actual_qty < doc.qty) { %}
<span class="text-danger small" style="margin-left: 15px;">
@ -28,10 +28,10 @@
<!-- warehouse -->
<div class="col-sm-3 col-xs-4">
{% if(doc.s_warehouse) { %}
<span class="label label-default" title="{% __("Source" )%}">
<span class="label label-default grid-label" title="{% __("Source" )%}">
{%= doc.s_warehouse || "" %}</span>
{% } %}
{% if(doc.t_warehouse) { %}<span class="label label-primary" title="{% __("Target" )%}">
{% if(doc.t_warehouse) { %}<span class="label label-primary grid-label" title="{% __("Target" )%}">
{%= doc.t_warehouse || "" %}</span>{% } %}
</div>

View File

@ -49,7 +49,7 @@ class TransactionBase(StatusUpdater):
})
if frappe.db.exists("User", self.contact_by):
frappe.share("Event", event.name, self.contact_by)
frappe.share.add("Event", event.name, self.contact_by)
event.insert(ignore_permissions=True)