[minor] merged with master branch

This commit is contained in:
Nabin Hait
2013-09-17 10:30:24 +05:30
134 changed files with 5280 additions and 549 deletions

View File

@@ -126,14 +126,10 @@ class DocType(TransactionBase):
webnotes.conn.sql("""delete from `tabAddress` where name=%s""", name)
def delete_customer_contact(self):
for rec in sql("select * from `tabContact` where customer=%s", (self.doc.name,), as_dict=1):
sql("delete from `tabContact` where name=%s",(rec['name']))
for contact in webnotes.conn.sql_list("""select name from `tabContact`
where customer=%s""", self.doc.name):
webnotes.delete_doc("Contact", contact)
def delete_customer_communication(self):
webnotes.conn.sql("""\
delete from `tabCommunication`
where customer = %s and supplier is null""", self.doc.name)
def delete_customer_account(self):
"""delete customer's ledger if exist and check balance before deletion"""
acc = sql("select name from `tabAccount` where master_type = 'Customer' \
@@ -145,7 +141,6 @@ class DocType(TransactionBase):
def on_trash(self):
self.delete_customer_address()
self.delete_customer_contact()
self.delete_customer_communication()
self.delete_customer_account()
if self.doc.lead_name:
sql("update `tabLead` set status='Interested' where name=%s",self.doc.lead_name)

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-06-11 14:26:44",
"docstatus": 0,
"modified": "2013-09-02 16:25:13",
"modified": "2013-09-10 10:50:50",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -195,14 +195,16 @@
"fieldtype": "Section Break",
"label": "Communication History",
"options": "icon-comments",
"permlevel": 0
"permlevel": 0,
"print_hide": 1
},
{
"doctype": "DocField",
"fieldname": "communication_html",
"fieldtype": "HTML",
"label": "Communication HTML",
"permlevel": 0
"permlevel": 0,
"print_hide": 1
},
{
"doctype": "DocField",
@@ -355,7 +357,8 @@
"hidden": 1,
"label": "Communications",
"options": "Communication",
"permlevel": 0
"permlevel": 0,
"print_hide": 1
},
{
"amend": 0,

View File

@@ -80,7 +80,6 @@ class DocType(SellingController):
return webnotes.conn.get_value('Sales Email Settings',None,'email_id')
def on_trash(self):
webnotes.conn.sql("""update tabCommunication set lead=null where lead=%s""", self.doc.name)
webnotes.conn.sql("""update `tabSupport Ticket` set lead='' where lead=%s""",
self.doc.name)

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-04-10 11:45:37",
"docstatus": 0,
"modified": "2013-09-02 17:25:59",
"modified": "2013-09-10 10:52:20",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -159,7 +159,8 @@
"fieldname": "communication_history",
"fieldtype": "Section Break",
"label": "Communication History",
"options": "icon-comments"
"options": "icon-comments",
"print_hide": 1
},
{
"allow_on_submit": 0,
@@ -168,7 +169,8 @@
"fieldtype": "HTML",
"label": "Communication HTML",
"oldfieldname": "follow_up",
"oldfieldtype": "Table"
"oldfieldtype": "Table",
"print_hide": 1
},
{
"doctype": "DocField",
@@ -416,7 +418,8 @@
"fieldtype": "Table",
"hidden": 1,
"label": "Communications",
"options": "Communication"
"options": "Communication",
"print_hide": 1
},
{
"cancel": 1,

View File

@@ -160,6 +160,11 @@ class DocType(TransactionBase):
def make_quotation(source_name, target_doclist=None):
from webnotes.model.mapper import get_mapped_doclist
def set_missing_values(source, target):
quotation = webnotes.bean(target)
quotation.run_method("onload_post_render")
quotation.run_method("calculate_taxes_and_totals")
doclist = get_mapped_doclist("Opportunity", source_name, {
"Opportunity": {
"doctype": "Quotation",
@@ -181,6 +186,6 @@ def make_quotation(source_name, target_doclist=None):
},
"add_if_empty": True
}
}, target_doclist)
}, target_doclist, set_missing_values)
return [d.fields for d in doclist]

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-03-07 18:50:30",
"docstatus": 0,
"modified": "2013-09-02 16:27:33",
"modified": "2013-09-10 10:52:49",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -168,6 +168,7 @@
"label": "Communication History",
"oldfieldtype": "Section Break",
"options": "icon-comments",
"print_hide": 1,
"read_only": 0
},
{
@@ -178,6 +179,7 @@
"label": "Communication HTML",
"oldfieldname": "follow_up",
"oldfieldtype": "Table",
"print_hide": 1,
"read_only": 0
},
{
@@ -448,7 +450,8 @@
"fieldtype": "Table",
"hidden": 1,
"label": "Communications",
"options": "Communication"
"options": "Communication",
"print_hide": 1
},
{
"doctype": "DocPerm",

View File

@@ -204,11 +204,6 @@ class DocType(SellingController):
print_lst.append(lst1)
return print_lst
def update_followup_details(self):
sql("delete from `tabCommunication Log` where parent = '%s'"%self.doc.name)
for d in getlist(self.doclist, 'follow_up'):
d.save()
@webnotes.whitelist()
def make_sales_order(source_name, target_doclist=None):
return _make_sales_order(source_name, target_doclist)

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-05-24 19:29:08",
"docstatus": 0,
"modified": "2013-09-02 16:25:01",
"modified": "2013-09-10 10:46:33",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -841,7 +841,8 @@
"fieldtype": "Table",
"hidden": 1,
"label": "Communications",
"options": "Communication"
"options": "Communication",
"print_hide": 1
},
{
"amend": 1,

View File

@@ -432,14 +432,16 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
calculate_outstanding_amount: function() {
// NOTE:
// write_off_amount is only for POS Invoice
// paid_amount and write_off_amount is only for POS Invoice
// total_advance is only for non POS Invoice
if(this.frm.doc.doctype == "Sales Invoice" && this.frm.doc.docstatus==0) {
wn.model.round_floats_in(this.frm.doc, ["grand_total", "total_advance", "write_off_amount",
"paid_amount"]);
var total_amount_to_pay = this.frm.doc.grand_total - this.frm.doc.write_off_amount;
this.frm.doc.outstanding_amount = flt(total_amount_to_pay - this.frm.doc.total_advance -
this.frm.doc.paid_amount, precision("outstanding_amount"));
var total_amount_to_pay = this.frm.doc.grand_total - this.frm.doc.write_off_amount - this.frm.doc.total_advance;
this.frm.doc.paid_amount = this.frm.doc.is_pos? flt(total_amount_to_pay): 0.0;
this.frm.doc.outstanding_amount = flt(total_amount_to_pay - this.frm.doc.paid_amount,
precision("outstanding_amount"));
}
},

View File

@@ -4,7 +4,6 @@
from __future__ import unicode_literals
import webnotes
import webnotes.utils
import json
from webnotes.utils import cstr, flt, getdate
from webnotes.model.bean import getlist
@@ -289,55 +288,6 @@ class DocType(SellingController):
def on_update(self):
pass
@webnotes.whitelist()
def get_orders():
# find customer id
customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user},
"customer")
if customer:
orders = webnotes.conn.sql("""select
name, creation, currency from `tabSales Order`
where customer=%s
and docstatus=1
order by creation desc
limit 20
""", customer, as_dict=1)
for order in orders:
order.items = webnotes.conn.sql("""select
item_name, qty, export_rate, export_amount, delivered_qty, stock_uom
from `tabSales Order Item`
where parent=%s
order by idx""", order.name, as_dict=1)
return orders
else:
return []
def get_website_args():
customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user},
"customer")
bean = webnotes.bean("Sales Order", webnotes.form_dict.name)
if bean.doc.customer != customer:
return {
"doc": {"name": "Not Allowed"}
}
else:
return {
"doc": bean.doc,
"doclist": bean.doclist,
"webnotes": webnotes,
"utils": webnotes.utils
}
def get_currency_and_number_format():
return {
"global_number_format": webnotes.conn.get_default("number_format") or "#,###.##",
"currency": webnotes.conn.get_default("currency"),
"currency_symbols": json.dumps(dict(webnotes.conn.sql("""select name, symbol
from tabCurrency where ifnull(enabled,0)=1""")))
}
def set_missing_values(source, target):
bean = webnotes.bean(target)
bean.run_method("onload_post_render")
@@ -409,7 +359,12 @@ def make_delivery_note(source_name, target_doclist=None):
return [d.fields for d in doclist]
@webnotes.whitelist()
def make_sales_invoice(source_name, target_doclist=None):
def make_sales_invoice(source_name, target_doclist=None):
def set_missing_values(source, target):
bean = webnotes.bean(target)
bean.doc.is_pos = 0
bean.run_method("onload_post_render")
def update_item(obj, target, source_parent):
target.export_amount = flt(obj.export_amount) - flt(obj.billed_amt)
target.amount = target.export_amount * flt(source_parent.conversion_rate)