Merge branch 'responsive' of github.com:webnotes/erpnext into responsive

This commit is contained in:
Anand Doshi
2013-07-15 18:30:02 +05:30
21 changed files with 175 additions and 182 deletions

View File

@@ -20,6 +20,67 @@ cur_frm.cscript.fname = "installed_item_details";
wn.provide("erpnext.selling");
// TODO commonify this code
erpnext.selling.InstallationNote = wn.ui.form.Controller.extend({
onload: function() {
if(!this.frm.doc.status) set_multiple(dt,dn,{ status:'Draft'});
if(this.frm.doc.__islocal) set_multiple(this.frm.doc.doctype, this.frm.doc.name,
{inst_date: get_today()});
fields = ['customer_address', 'contact_person','customer_name', 'address_display',
'contact_display', 'contact_mobile', 'contact_email', 'territory', 'customer_group']
if(this.frm.doc.customer) unhide_field(fields);
else hide_field(fields)
this.setup_queries();
},
setup_queries: function() {
var me = this;
this.frm.set_query("customer_address", function() {
return {
filters: {'customer': me.frm.doc.customer }
}
});
this.frm.set_query("contact_person", function() {
return {
filters: {'customer': me.frm.doc.customer }
}
});
this.frm.set_query("territory", function() {
return {
filters: {'is_group': "No" }
}
});
this.frm.set_query("customer", function() {
return {
query: "controllers.queries.customer_query"
}
});
},
refresh: function() {
if (this.frm.doc.docstatus===0) {
cur_frm.add_custom_button(wn._('From Delivery Note'),
function() {
wn.model.map_current_doc({
method: "stock.doctype.delivery_note.delivery_note.make_installation_note",
source_doctype: "Delivery Note",
get_query_filters: {
docstatus: 1,
status: ["!=", "Stopped"],
per_installed: ["<", 99.99],
customer: cur_frm.doc.customer || undefined,
company: cur_frm.doc.company
}
})
}
);
}
},
customer: function() {
var me = this;
if(this.frm.doc.customer) {
@@ -37,65 +98,29 @@ erpnext.selling.InstallationNote = wn.ui.form.Controller.extend({
'territory', 'customer_group']);
}
},
get_items: function() {
wn.model.map_current_doc({
method: "stock.doctype.delivery_note.delivery_note.make_installation_note",
source_name: cur_frm.doc.delivery_note_no,
})
unhide_field(['customer_address', 'contact_person', 'customer_name', 'address_display',
'contact_display', 'contact_mobile', 'contact_email', 'territory', 'customer_group']);
}
customer_address: function() {
var me = this;
if(this.frm.doc.customer) {
this.frm.call({
doc: this.frm.doc,
args: {
customer: this.frm.doc.customer,
address: this.frm.doc.customer_address,
contact: this.frm.doc.contact_person
},
method: "get_customer_address",
freeze: true,
callback: function(r) {
me.frm.refresh_fields();
}
});
}
},
contact_person: function() {
this.customer_address();
},
});
$.extend(cur_frm.cscript, new erpnext.selling.InstallationNote({frm: cur_frm}));
cur_frm.cscript.onload = function(doc, dt, dn) {
if(!doc.status) set_multiple(dt,dn,{status:'Draft'});
if(doc.__islocal){
set_multiple(dt,dn,{inst_date:get_today()});
hide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
}
if (doc.customer) {
unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
}
}
cur_frm.fields_dict['delivery_note_no'].get_query = function(doc) {
doc = locals[this.doctype][this.docname];
var filter = {
'company': doc.company,
'docstatus': 1,
'per_installed': 99.99
};
if(doc.customer) filter['customer'] = doc.customer;
return { filters: filter }
}
cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
return{
filters: { 'is_group': "No" }
}
}
cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {
if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({customer: doc.customer, address: doc.customer_address, contact: doc.contact_person}),'', doc, dt, dn, 1);
}
cur_frm.fields_dict['customer_address'].get_query = function(doc, cdt, cdn) {
return{
filters: { 'customer': doc.customer }
}
}
cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
return{
filters: { 'customer': doc.customer }
}
}
cur_frm.fields_dict.customer.get_query = function(doc,cdt,cdn) {
return{
query:"controllers.queries.customer_query"
}
}
$.extend(cur_frm.cscript, new erpnext.selling.InstallationNote({frm: cur_frm}));

View File

@@ -52,12 +52,6 @@ class DocType(TransactionBase):
sales_com_obj = get_obj(dt = 'Sales Common')
sales_com_obj.check_active_sales_items(self)
sales_com_obj.get_prevdoc_date(self)
def validate_prev_docname(self):
for d in getlist(self.doclist, 'installed_item_details'):
if self.doc.delivery_note_no == d.prevdoc_docname:
msgprint(cstr(self.doc.delivery_note_no) +
" delivery note details have already been pulled", raise_exception=1)
def validate_fiscal_year(self):
from accounts.utils import validate_fiscal_year

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-04-30 13:13:06",
"docstatus": 0,
"modified": "2013-07-07 18:10:24",
"modified": "2013-07-15 17:09:08",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -240,28 +240,6 @@
"oldfieldtype": "Section Break",
"options": "Simple"
},
{
"doctype": "DocField",
"fieldname": "delivery_note_no",
"fieldtype": "Link",
"label": "Delivery Note No",
"no_copy": 1,
"oldfieldname": "delivery_note_no",
"oldfieldtype": "Link",
"options": "Delivery Note",
"print_hide": 0,
"reqd": 1,
"search_index": 1
},
{
"doctype": "DocField",
"fieldname": "get_items",
"fieldtype": "Button",
"hidden": 0,
"label": "Get Items",
"oldfieldtype": "Button",
"print_hide": 1
},
{
"doctype": "DocField",
"fieldname": "installed_item_details",

View File

@@ -192,7 +192,8 @@ def make_quotation(source_name, target_doclist=None):
"parent": "prevdoc_docname",
"parenttype": "prevdoc_doctype",
"uom": "stock_uom"
}
},
"add_if_empty": True
}
}, target_doclist)

View File

@@ -235,7 +235,10 @@ def _make_sales_order(source_name, target_doclist=None, ignore_permissions=False
if customer:
target[0].customer = customer.doc.name
target[0].customer_name = customer.doc.customer_name
si = webnotes.bean(target)
si.run_method("onload_post_render")
doclist = get_mapped_doclist("Quotation", source_name, {
"Quotation": {
"doctype": "Sales Order",
@@ -247,13 +250,16 @@ def _make_sales_order(source_name, target_doclist=None, ignore_permissions=False
"doctype": "Sales Order Item",
"field_map": {
"parent": "prevdoc_docname"
}
},
"add_if_empty": True
},
"Sales Taxes and Charges": {
"doctype": "Sales Taxes and Charges",
"add_if_empty": True
},
"Sales Team": {
"doctype": "Sales Team",
"add_if_empty": True
}
}, target_doclist, set_missing_values, ignore_permissions=ignore_permissions)

View File

@@ -330,11 +330,13 @@ class DocType(TransactionBase):
def get_prevdoc_date(self, obj):
for d in getlist(obj.doclist, obj.fname):
if d.prevdoc_doctype and d.prevdoc_docname:
if d.prevdoc_doctype == 'Sales Invoice':
dt = webnotes.conn.sql("select posting_date from `tab%s` where name = '%s'" % (d.prevdoc_doctype, d.prevdoc_docname))
if d.prevdoc_doctype in ["Sales Invoice", "Delivery Note"]:
date_field = "posting_date"
else:
dt = webnotes.conn.sql("select transaction_date from `tab%s` where name = '%s'" % (d.prevdoc_doctype, d.prevdoc_docname))
d.prevdoc_date = (dt and dt[0][0]) and dt[0][0].strftime('%Y-%m-%d') or ''
date_field = "transaction_date"
d.prevdoc_date = webnotes.conn.get_value(d.prevdoc_doctype,
d.prevdoc_docname, date_field)
def get_batch_no(doctype, txt, searchfield, start, page_len, filters):
from controllers.queries import get_match_cond

View File

@@ -340,6 +340,10 @@ def get_currency_and_number_format():
from tabCurrency where ifnull(enabled,0)=1""")))
}
def set_missing_values(source, target):
bean = webnotes.bean(target)
bean.run_method("onload_post_render")
@webnotes.whitelist()
def make_material_request(source_name, target_doclist=None):
def postprocess(source, doclist):
@@ -395,11 +399,13 @@ def make_delivery_note(source_name, target_doclist=None):
},
"Sales Taxes and Charges": {
"doctype": "Sales Taxes and Charges",
"add_if_empty": True
},
"Sales Team": {
"doctype": "Sales Team",
"doctype": "Sales Team",
"add_if_empty": True
}
}, target_doclist)
}, target_doclist, set_missing_values)
return [d.fields for d in doclist]
@@ -409,10 +415,6 @@ def make_sales_invoice(source_name, target_doclist=None):
target.export_amount = flt(obj.amount) - flt(obj.billed_amt)
target.amount = target.export_amount / flt(source_parent.conversion_rate)
target.qty = obj.basic_rate and target.amount / flt(obj.basic_rate) or obj.qty
def update_accounts(source, target):
si = webnotes.bean(target)
si.run_method("update_accounts")
doclist = get_mapped_doclist("Sales Order", source_name, {
"Sales Order": {
@@ -433,11 +435,13 @@ def make_sales_invoice(source_name, target_doclist=None):
},
"Sales Taxes and Charges": {
"doctype": "Sales Taxes and Charges",
"add_if_empty": True
},
"Sales Team": {
"doctype": "Sales Team",
"add_if_empty": True
}
}, target_doclist, update_accounts)
}, target_doclist, set_missing_values)
return [d.fields for d in doclist]
@@ -462,7 +466,8 @@ def make_maintenance_schedule(source_name, target_doclist=None):
"doctype": "Maintenance Schedule Item",
"field_map": {
"parent": "prevdoc_docname"
}
},
"add_if_empty": True
}
}, target_doclist)
@@ -491,7 +496,8 @@ def make_maintenance_visit(source_name, target_doclist=None):
"field_map": {
"parent": "prevdoc_docname",
"parenttype": "prevdoc_doctype"
}
},
"add_if_empty": True
}
}, target_doclist)