Merge branch 'website-wip'

This commit is contained in:
Anand Doshi 2013-09-19 12:27:11 +05:30
commit 12144f339e
253 changed files with 1310 additions and 5414 deletions

View File

@ -79,6 +79,10 @@ cur_frm.cscript.refresh = function(doc) {
} }
} }
cur_frm.cscript.company = function(doc, cdt, cdn) {
cur_frm.refresh_fields();
}
cur_frm.cscript.is_opening = function(doc, cdt, cdn) { cur_frm.cscript.is_opening = function(doc, cdt, cdn) {
hide_field('aging_date'); hide_field('aging_date');
if (doc.is_opening == 'Yes') unhide_field('aging_date'); if (doc.is_opening == 'Yes') unhide_field('aging_date');

View File

@ -178,7 +178,7 @@ class DocType(AccountsController):
if account_type == 'Bank or Cash': if account_type == 'Bank or Cash':
company_currency = get_company_currency(self.doc.company) company_currency = get_company_currency(self.doc.company)
amt = flt(d.debit) and d.debit or d.credit amt = flt(d.debit) and d.debit or d.credit
self.doc.total_amount = company_currency +' '+ cstr(amt) self.doc.total_amount = company_currency + ' ' + cstr(amt)
from webnotes.utils import money_in_words from webnotes.utils import money_in_words
self.doc.total_amount_in_words = money_in_words(amt, company_currency) self.doc.total_amount_in_words = money_in_words(amt, company_currency)

View File

@ -193,7 +193,7 @@ erpnext.POS = Class.extend({
</div>', </div>',
{ {
item_code: obj.name, item_code: obj.name,
item_price: format_currency(obj.ref_rate, obj.ref_currency), item_price: format_currency(obj.ref_rate, obj.currency),
item_name: obj.name===obj.item_name ? "" : obj.item_name, item_name: obj.name===obj.item_name ? "" : obj.item_name,
item_image: image item_image: image
})).appendTo($wrap); })).appendTo($wrap);

View File

@ -15,11 +15,14 @@ def get_items(price_list, item=None, item_group=None):
if item: if item:
condition = "and i.name='%s'" % item condition = "and i.name='%s'" % item
return webnotes.conn.sql("""select return webnotes.conn.sql("""select i.name, i.item_name, i.image,
i.name, i.item_name, i.image, ip.ref_rate, ip.ref_currency pl_items.ref_rate, pl_items.currency
from `tabItem` i LEFT JOIN `tabItem Price` ip from `tabItem` i LEFT JOIN
ON ip.parent=i.name (select ip.item_code, ip.ref_rate, pl.currency from
and ip.price_list=%s `tabItem Price` ip, `tabPrice List` pl
where ip.parent=%s and ip.parent = pl.name) pl_items
ON
pl_items.item_code=i.name
where where
i.is_sales_item='Yes'%s""" % ('%s', condition), (price_list), as_dict=1) i.is_sales_item='Yes'%s""" % ('%s', condition), (price_list), as_dict=1)

View File

@ -73,45 +73,14 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
if(!from_delivery_note) if(!from_delivery_note)
cur_frm.add_custom_button('Make Delivery', cur_frm.cscript['Make Delivery Note']); cur_frm.add_custom_button('Make Delivery', cur_frm.cscript['Make Delivery Note']);
} }
if(doc.outstanding_amount!=0) if(doc.outstanding_amount!=0)
cur_frm.add_custom_button('Make Payment Entry', cur_frm.cscript.make_bank_voucher); cur_frm.add_custom_button('Make Payment Entry', cur_frm.cscript.make_bank_voucher);
} }
if (doc.docstatus===0) { if (doc.docstatus===0) {
cur_frm.add_custom_button(wn._('From Sales Order'), cur_frm.cscript.sales_order_btn();
function() { cur_frm.cscript.delivery_note_btn();
wn.model.map_current_doc({
method: "selling.doctype.sales_order.sales_order.make_sales_invoice",
source_doctype: "Sales Order",
get_query_filters: {
docstatus: 1,
status: ["!=", "Stopped"],
per_billed: ["<", 99.99],
customer: cur_frm.doc.customer || undefined,
company: cur_frm.doc.company
}
})
});
cur_frm.add_custom_button(wn._('From Delivery Note'),
function() {
wn.model.map_current_doc({
method: "stock.doctype.delivery_note.delivery_note.make_sales_invoice",
source_doctype: "Delivery Note",
get_query: function() {
var filters = {
company: cur_frm.doc.company
};
if(cur_frm.doc.customer) filters["customer"] = cur_frm.doc.customer;
return {
query: "controllers.queries.get_delivery_notes_to_be_billed",
filters: filters
};
}
});
});
} }
// Show POS button only if it enabled from features setup // Show POS button only if it enabled from features setup
@ -119,6 +88,43 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
cur_frm.cscript.pos_btn(); cur_frm.cscript.pos_btn();
}, },
sales_order_btn: function() {
this.$sales_order_btn = cur_frm.add_custom_button(wn._('From Sales Order'),
function() {
wn.model.map_current_doc({
method: "selling.doctype.sales_order.sales_order.make_sales_invoice",
source_doctype: "Sales Order",
get_query_filters: {
docstatus: 1,
status: ["!=", "Stopped"],
per_billed: ["<", 99.99],
customer: cur_frm.doc.customer || undefined,
company: cur_frm.doc.company
}
})
});
},
delivery_note_btn: function() {
this.$delivery_note_btn = cur_frm.add_custom_button(wn._('From Delivery Note'),
function() {
wn.model.map_current_doc({
method: "stock.doctype.delivery_note.delivery_note.make_sales_invoice",
source_doctype: "Delivery Note",
get_query: function() {
var filters = {
company: cur_frm.doc.company
};
if(cur_frm.doc.customer) filters["customer"] = cur_frm.doc.customer;
return {
query: "controllers.queries.get_delivery_notes_to_be_billed",
filters: filters
};
}
});
});
},
pos_btn: function() { pos_btn: function() {
if(cur_frm.$pos_btn) if(cur_frm.$pos_btn)
cur_frm.$pos_btn.remove(); cur_frm.$pos_btn.remove();
@ -126,9 +132,17 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
if(!cur_frm.pos_active) { if(!cur_frm.pos_active) {
var btn_label = wn._("POS View"), var btn_label = wn._("POS View"),
icon = "icon-desktop"; icon = "icon-desktop";
cur_frm.cscript.sales_order_btn();
cur_frm.cscript.delivery_note_btn();
} else { } else {
var btn_label = wn._("Invoice View"), var btn_label = wn._("Invoice View"),
icon = "icon-file-text"; icon = "icon-file-text";
if (cur_frm.doc.docstatus===0) {
this.$delivery_note_btn.remove();
this.$sales_order_btn.remove();
}
} }
cur_frm.$pos_btn = cur_frm.add_custom_button(btn_label, function() { cur_frm.$pos_btn = cur_frm.add_custom_button(btn_label, function() {

View File

@ -9,7 +9,7 @@ from webnotes.utils import add_days, cint, cstr, date_diff, flt, getdate, nowdat
get_first_day, get_last_day get_first_day, get_last_day
from webnotes.utils.email_lib import sendmail from webnotes.utils.email_lib import sendmail
from webnotes.utils import comma_and from webnotes.utils import comma_and, get_url
from webnotes.model.doc import make_autoname from webnotes.model.doc import make_autoname
from webnotes.model.bean import getlist from webnotes.model.bean import getlist
from webnotes.model.code import get_obj from webnotes.model.code import get_obj
@ -148,6 +148,9 @@ class DocType(SellingController):
self.validate_recurring_invoice() self.validate_recurring_invoice()
self.convert_to_recurring() self.convert_to_recurring()
def get_portal_page(self):
return "invoice" if self.doc.docstatus==1 else None
def set_missing_values(self, for_validate=False): def set_missing_values(self, for_validate=False):
self.set_pos_fields(for_validate) self.set_pos_fields(for_validate)
@ -916,7 +919,7 @@ def notify_errors(inv, owner):
Regards, Regards,
Administrator Administrator
""" % (inv, website.get_site_address(), inv) """ % (inv, get_url(), inv)
subj = "[Urgent] Error while creating recurring invoice from %s" % inv subj = "[Urgent] Error while creating recurring invoice from %s" % inv
from webnotes.profile import get_system_managers from webnotes.profile import get_system_managers

View File

@ -0,0 +1,5 @@
{% extends "app/portal/templates/sale.html" %}
{% block status -%}
{% if doc.status %}{{ doc.status }}{% endif %}
{%- endblock %}

View File

@ -0,0 +1,30 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes import _
from webnotes.utils import flt, fmt_money
no_cache = True
def get_context():
from portal.utils import get_transaction_context
context = get_transaction_context("Sales Invoice", webnotes.form_dict.name)
modify_status(context.get("doc"))
context.update({
"parent_link": "invoices",
"parent_title": "Invoices"
})
return context
def modify_status(doc):
doc.status = ""
if flt(doc.outstanding_amount):
doc.status = '<span class="label %s"><i class="icon-fixed-width %s"></i> %s</span>' % \
("label-warning", "icon-exclamation-sign",
_("To Pay") + " = " + fmt_money(doc.outstanding_amount, currency=doc.currency))
else:
doc.status = '<span class="label %s"><i class="icon-fixed-width %s"></i> %s</span>' % \
("label-success", "icon-ok", _("Paid"))

View File

@ -0,0 +1 @@
{% extends "app/portal/templates/sales_transactions.html" %}

View File

@ -0,0 +1,28 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
no_cache = True
def get_context():
from portal.utils import get_currency_context
context = get_currency_context()
context.update({
"title": "Invoices",
"method": "accounts.doctype.sales_invoice.templates.pages.invoices.get_invoices",
"icon": "icon-file-text",
"empty_list_message": "No Invoices Found",
"page": "invoice"
})
return context
@webnotes.whitelist()
def get_invoices(start=0):
from portal.utils import get_transaction_list
from accounts.doctype.sales_invoice.templates.pages.invoice import modify_status
invoices = get_transaction_list("Sales Invoice", start, ["outstanding_amount"])
for d in invoices:
modify_status(d)
return invoices

View File

@ -24,16 +24,6 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
filters: { 'buying_or_selling': "Buying" } filters: { 'buying_or_selling': "Buying" }
} }
}); });
this.frm.set_query("price_list_currency", function() {
return{
query: "controllers.queries.get_price_list_currency",
filters: {
'price_list': me.frm.doc.buying_price_list,
'buying_or_selling': "Buying"
}
}
});
} }
$.each([["supplier", "supplier"], $.each([["supplier", "supplier"],
@ -152,7 +142,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
}, },
buying_price_list: function() { buying_price_list: function() {
this.get_price_list_currency("buying"); this.get_price_list_currency("Buying");
}, },
import_ref_rate: function(doc, cdt, cdn) { import_ref_rate: function(doc, cdt, cdn) {

View File

@ -147,7 +147,6 @@ class DocType(TransactionBase):
def on_trash(self): def on_trash(self):
self.delete_supplier_address() self.delete_supplier_address()
self.delete_supplier_contact() self.delete_supplier_contact()
self.delete_supplier_communication()
self.delete_supplier_account() self.delete_supplier_account()
def on_rename(self, new, old, merge=False): def on_rename(self, new, old, merge=False):

View File

@ -89,12 +89,15 @@ def _get_price_list_rate(args, item_bean, meta):
# try fetching from price list # try fetching from price list
if args.buying_price_list and args.price_list_currency: if args.buying_price_list and args.price_list_currency:
price_list_rate = item_bean.doclist.get({ price_list_rate = webnotes.conn.sql("""select ip.ref_rate from `tabItem Price` ip,
"parentfield": "ref_rate_details", `tabPrice List` pl where ip.parent = pl.name and ip.parent=%s and
"price_list": args.buying_price_list, ip.item_code=%s and pl.buying_or_selling='Buying'""",
"ref_currency": args.price_list_currency, (args.buying_price_list, args.item_code), as_dict=1)
"buying_or_selling": "Buying"})
if price_list_rate: if price_list_rate:
from utilities.transaction_base import validate_currency
validate_currency(args, item_bean.doc, meta)
out.import_ref_rate = \ out.import_ref_rate = \
flt(price_list_rate[0].ref_rate * args.plc_conversion_rate / args.conversion_rate) flt(price_list_rate[0].ref_rate * args.plc_conversion_rate / args.conversion_rate)

View File

@ -1,5 +1,6 @@
{ {
"app_name": "ERPNext", "app_name": "ERPNext",
"base_template": "app/portal/templates/base.html",
"modules": { "modules": {
"Selling": { "Selling": {
"link": "selling-home", "link": "selling-home",
@ -43,12 +44,6 @@
"color": "#7f8c8d", "color": "#7f8c8d",
"icon": "icon-cogs" "icon": "icon-cogs"
}, },
"Website": {
"type": "module",
"link": "website-home",
"color": "#16a085",
"icon": "icon-globe"
},
"HR": { "HR": {
"type": "module", "type": "module",
"link": "hr-home", "link": "hr-home",
@ -77,138 +72,5 @@
"label": "Notes", "label": "Notes",
"icon": "icon-file-alt" "icon": "icon-file-alt"
} }
},
"web": {
"pages": {
"about": {
"template": "app/website/templates/pages/about",
"args_method": "website.doctype.about_us_settings.about_us_settings.get_args"
},
"account": {
"no_cache": true,
"template": "app/website/templates/pages/account"
},
"blog": {
"template": "app/website/templates/pages/blog",
"args_method": "website.helpers.blog.get_blog_template_args"
},
"contact": {
"template": "app/website/templates/pages/contact",
"args_doctype": "Contact Us Settings"
},
"index": {
"template": "app/website/templates/pages/index"
},
"order": {
"no_cache": true,
"template": "app/website/templates/pages/sale",
"args_method": "website.helpers.transaction.get_order_args",
"portal": {
"doctype": "Sales Order",
"conditions": {
"docstatus": 1
}
}
},
"orders": {
"no_cache": true,
"template": "app/website/templates/pages/sales_transactions",
"args_method": "website.helpers.transaction.order_list_args"
},
"invoice": {
"no_cache": true,
"template": "app/website/templates/pages/sale",
"args_method": "website.helpers.transaction.get_invoice_args",
"portal": {
"doctype": "Sales Invoice",
"conditions": {
"docstatus": 1
}
}
},
"invoices": {
"no_cache": true,
"template": "app/website/templates/pages/sales_transactions",
"args_method": "website.helpers.transaction.invoice_list_args"
},
"shipment": {
"no_cache": true,
"template": "app/website/templates/pages/sale",
"args_method": "website.helpers.transaction.get_shipment_args",
"portal": {
"doctype": "Delivery Note",
"conditions": {
"docstatus": 1
}
}
},
"shipments": {
"no_cache": true,
"template": "app/website/templates/pages/sales_transactions",
"args_method": "website.helpers.transaction.shipment_list_args"
},
"product_search": {
"template": "app/website/templates/pages/product_search"
},
"ticket": {
"no_cache": true,
"template": "app/website/templates/pages/ticket",
"args_method": "support.doctype.support_ticket.support_ticket.get_website_args",
"portal": {
"doctype": "Support Ticket"
}
},
"tickets": {
"template": "app/website/templates/pages/tickets",
"args_method": "website.helpers.transaction.ticket_list_args"
},
"address": {
"no_cache": true,
"template": "app/website/templates/pages/address",
"args_method": "utilities.doctype.address.address.get_website_args"
},
"addresses": {
"template": "app/website/templates/pages/addresses"
},
"writers": {
"template": "app/website/templates/pages/writers",
"args_method": "website.doctype.blogger.blogger.get_writers_args"
},
"profile": {
"no_cache": true,
"template": "app/website/templates/pages/profile",
"args_method": "startup.webutils.get_profile_args"
},
"cart": {
"no_cache": true,
"template": "app/website/templates/pages/cart.html"
},
"partners": {
"template": "app/website/templates/pages/partners",
"args_method": "website.helpers.partner.get_partner_args"
}
},
"generators": {
"Web Page": {
"template": "app/website/templates/html/web_page.html",
"condition_field": "published"
},
"Blog Post": {
"template": "app/website/templates/html/blog_page.html",
"condition_field": "published"
},
"Item": {
"template": "app/website/templates/html/product_page.html",
"condition_field": "show_in_website"
},
"Item Group":{
"template": "app/website/templates/html/product_group.html",
"condition_field": "show_in_website"
},
"Sales Partner": {
"template": "app/website/templates/html/partner_page.html",
"condition_field": "show_in_website"
}
}
} }
} }

View File

@ -59,13 +59,13 @@ class AccountsController(TransactionBase):
# TODO - change this, since price list now has only one currency allowed # TODO - change this, since price list now has only one currency allowed
if self.meta.get_field(fieldname) and self.doc.fields.get(fieldname): if self.meta.get_field(fieldname) and self.doc.fields.get(fieldname):
if not self.doc.price_list_currency: self.doc.fields.update(get_price_list_currency(self.doc.fields.get(fieldname)))
self.doc.fields.update(get_price_list_currency(self.doc.fields.get(fieldname)))
if self.doc.price_list_currency: if self.doc.price_list_currency:
if self.doc.price_list_currency == company_currency: if self.doc.price_list_currency == company_currency:
self.doc.plc_conversion_rate = 1.0 self.doc.plc_conversion_rate = 1.0
elif not self.doc.plc_conversion_rate: elif not self.doc.plc_conversion_rate or \
(flt(self.doc.plc_conversion_rate)==1 and company_currency!= self.doc.price_list_currency):
exchange = self.doc.price_list_currency + "-" + company_currency exchange = self.doc.price_list_currency + "-" + company_currency
self.doc.plc_conversion_rate = flt(webnotes.conn.get_value("Currency Exchange", self.doc.plc_conversion_rate = flt(webnotes.conn.get_value("Currency Exchange",
exchange, "exchange_rate")) exchange, "exchange_rate"))

View File

@ -157,14 +157,6 @@ def get_project_name(doctype, txt, searchfield, start, page_len, filters):
order by `tabProject`.name asc order by `tabProject`.name asc
limit %(start)s, %(page_len)s """ % {'cond': cond,'txt': "%%%s%%" % txt, limit %(start)s, %(page_len)s """ % {'cond': cond,'txt': "%%%s%%" % txt,
'mcond':get_match_cond(doctype, searchfield),'start': start, 'page_len': page_len}) 'mcond':get_match_cond(doctype, searchfield),'start': start, 'page_len': page_len})
def get_price_list_currency(doctype, txt, searchfield, start, page_len, filters):
return webnotes.conn.sql("""select ref_currency from `tabItem Price`
where price_list = %s and buying_or_selling = %s
and `%s` like %s order by ref_currency asc limit %s, %s""" %
("%s", "%s", searchfield, "%s", "%s", "%s"),
(filters["price_list"], filters['buying_or_selling'], "%%%s%%" % txt,
start, page_len))
def get_delivery_notes_to_be_billed(doctype, txt, searchfield, start, page_len, filters): def get_delivery_notes_to_be_billed(doctype, txt, searchfield, start, page_len, filters):
return webnotes.conn.sql("""select `tabDelivery Note`.name, `tabDelivery Note`.customer_name return webnotes.conn.sql("""select `tabDelivery Note`.name, `tabDelivery Note`.customer_name

View File

@ -106,13 +106,12 @@ class TestLeaveApplication(unittest.TestCase):
add_role("test1@example.com", "Leave Approver") add_role("test1@example.com", "Leave Approver")
add_role("test2@example.com", "Leave Approver") add_role("test2@example.com", "Leave Approver")
self._test_leave_approval_basic_case_1() self._test_leave_approval_basic_case()
self._test_leave_approval_basic_case_2()
self._test_leave_approval_invalid_leave_approver_insert() self._test_leave_approval_invalid_leave_approver_insert()
self._test_leave_approval_invalid_leave_approver_submit() self._test_leave_approval_invalid_leave_approver_submit()
self._test_leave_approval_valid_leave_approver_insert() self._test_leave_approval_valid_leave_approver_insert()
def _test_leave_approval_basic_case_1(self): def _test_leave_approval_basic_case(self):
self._clear_applications() self._clear_applications()
# create leave application as Employee # create leave application as Employee
@ -128,19 +127,6 @@ class TestLeaveApplication(unittest.TestCase):
self.assertEqual(webnotes.conn.get_value("Leave Application", application.doc.name, self.assertEqual(webnotes.conn.get_value("Leave Application", application.doc.name,
"docstatus"), 1) "docstatus"), 1)
def _test_leave_approval_basic_case_2(self):
self._clear_applications()
# create leave application by any leave approver,
# when no leave approver specified in employee's leave approvers list
application = self.get_application(test_records[1])
application.doc.leave_approver = "test1@example.com"
application.insert()
application.doc.status = "Approved"
application.submit()
self.assertEqual(webnotes.conn.get_value("Leave Application", application.doc.name,
"docstatus"), 1)
def _test_leave_approval_invalid_leave_approver_insert(self): def _test_leave_approval_invalid_leave_approver_insert(self):
from hr.doctype.leave_application.leave_application import InvalidLeaveApproverError from hr.doctype.leave_application.leave_application import InvalidLeaveApproverError
@ -186,11 +172,13 @@ class TestLeaveApplication(unittest.TestCase):
original_department = webnotes.conn.get_value("Employee", "_T-Employee-0001", "department") original_department = webnotes.conn.get_value("Employee", "_T-Employee-0001", "department")
webnotes.conn.set_value("Employee", "_T-Employee-0001", "department", None) webnotes.conn.set_value("Employee", "_T-Employee-0001", "department", None)
# change to valid leave approver and try to create and submit leave application webnotes.session.user = "test@example.com"
webnotes.session.user = "test2@example.com"
application = self.get_application(test_records[1]) application = self.get_application(test_records[1])
application.doc.leave_approver = "test2@example.com" application.doc.leave_approver = "test2@example.com"
application.insert() application.insert()
# change to valid leave approver and try to submit leave application
webnotes.session.user = "test2@example.com"
application.doc.status = "Approved" application.doc.status = "Approved"
application.submit() application.submit()
self.assertEqual(webnotes.conn.get_value("Leave Application", application.doc.name, self.assertEqual(webnotes.conn.get_value("Leave Application", application.doc.name,

View File

@ -289,7 +289,7 @@ NameVirtualHost *:8080
RewriteCond %%{REQUEST_FILENAME} !-f RewriteCond %%{REQUEST_FILENAME} !-f
RewriteCond %%{REQUEST_FILENAME} !-d RewriteCond %%{REQUEST_FILENAME} !-d
RewriteCond %%{REQUEST_FILENAME} !-l RewriteCond %%{REQUEST_FILENAME} !-l
RewriteRule ^([^/]+)$ /web.py?page=$1 [QSA,L] RewriteRule ^([^/]+)$ /web.py?page=$1 [QSA,L]
</Directory> </Directory>
</VirtualHost>""" % (install_path, install_path) </VirtualHost>""" % (install_path, install_path)

View File

@ -121,8 +121,8 @@ class DocType:
elif self.doc.rm_cost_as_per == "Price List": elif self.doc.rm_cost_as_per == "Price List":
if not self.doc.buying_price_list: if not self.doc.buying_price_list:
webnotes.throw(_("Please select Price List")) webnotes.throw(_("Please select Price List"))
rate = webnotes.conn.get_value("Item Price", {"price_list": self.doc.buying_price_list, rate = webnotes.conn.get_value("Item Price", {"parent": self.doc.buying_price_list,
"parent": arg["item_code"]}, "ref_rate") or 0 "item_code": arg["item_code"]}, "ref_rate") or 0
elif self.doc.rm_cost_as_per == 'Standard Rate': elif self.doc.rm_cost_as_per == 'Standard Rate':
rate = arg['standard_rate'] rate = arg['standard_rate']

View File

@ -1,12 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
import webnotes
def execute():
webnotes.reload_doc("stock", "doctype", "item_price")
# check for selling
webnotes.conn.sql("""update `tabItem Price` set buying_or_selling = "Selling"
where ifnull(buying_or_selling, '')=''""")

View File

@ -8,7 +8,7 @@ import MySQLdb
def execute(): def execute():
webnotes.reload_doc("setup", "doctype", "price_list") webnotes.reload_doc("setup", "doctype", "price_list")
webnotes.reload_doc("stock", "doctype", "item_price") webnotes.reload_doc("setup", "doctype", "item_price")
try: try:
for price_list in webnotes.conn.sql_list("""select name from `tabPrice List`"""): for price_list in webnotes.conn.sql_list("""select name from `tabPrice List`"""):
@ -20,10 +20,9 @@ def execute():
buying_or_selling = "Selling" if selling else "Buying" buying_or_selling = "Selling" if selling else "Buying"
webnotes.conn.set_value("Price List", price_list, "buying_or_selling", buying_or_selling) webnotes.conn.set_value("Price List", price_list, "buying_or_selling", buying_or_selling)
webnotes.conn.sql("""update `tabItem Price` set buying_or_selling=%s
where price_list_name=%s""", (buying_or_selling, price_list))
except MySQLdb.OperationalError, e: except MySQLdb.OperationalError, e:
if e.args[0] == 1054: if e.args[0] == 1054:
webnotes.conn.sql("""update `tabItem Price` set buying_or_selling="Selling" """) webnotes.conn.sql("""update `tabPrice List` set buying_or_selling='Selling'
where ifnull(buying_or_selling, '')='' """)
else: else:
raise e raise e

View File

@ -121,7 +121,6 @@ patch_list = [
"patches.january_2013.update_country_info", "patches.january_2013.update_country_info",
"patches.january_2013.remove_tds_entry_from_gl_mapper", "patches.january_2013.remove_tds_entry_from_gl_mapper",
"patches.january_2013.update_number_format", "patches.january_2013.update_number_format",
"patches.january_2013.purchase_price_list",
"execute:webnotes.reload_doc('core', 'doctype', 'print_format') #2013-01", "execute:webnotes.reload_doc('core', 'doctype', 'print_format') #2013-01",
"execute:webnotes.reload_doc('accounts','Print Format','Payment Receipt Voucher')", "execute:webnotes.reload_doc('accounts','Print Format','Payment Receipt Voucher')",
"patches.january_2013.update_fraction_for_usd", "patches.january_2013.update_fraction_for_usd",
@ -263,5 +262,7 @@ patch_list = [
"patches.september_2013.p01_update_communication", "patches.september_2013.p01_update_communication",
"execute:webnotes.reload_doc('setup', 'doctype', 'features_setup') # 2013-09-05", "execute:webnotes.reload_doc('setup', 'doctype', 'features_setup') # 2013-09-05",
"patches.september_2013.p02_fix_serial_no_status", "patches.september_2013.p02_fix_serial_no_status",
"patches.september_2013.p03_modify_item_price_include_in_price_list",
"patches.september_2013.p03_update_stock_uom_in_sle", "patches.september_2013.p03_update_stock_uom_in_sle",
"patches.september_2013.p03_move_website_to_framework",
] ]

View File

@ -0,0 +1,20 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
def execute():
webnotes.reload_doc("setup", "doctype", "price_list")
webnotes.reload_doc("setup", "doctype", "item_price")
webnotes.reload_doc("stock", "doctype", "item")
webnotes.conn.sql("""update `tabItem Price` set parenttype='Price List',
parentfield='item_prices', `item_code`=`parent`""")
# re-arranging idx of items
webnotes.conn.sql("""update `tabItem Price` set `parent`=`price_list`, idx=0""")
for pl in webnotes.conn.sql("""select name from `tabPrice List`"""):
webnotes.conn.sql("""set @name=0""")
webnotes.conn.sql("""update `tabItem Price` set idx = @name := IF(ISNULL( @name ), 0, @name + 1)
where idx=0 and parent=%s""", pl[0])

View File

@ -0,0 +1,17 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes.utils import get_base_path
import os, shutil
def execute():
# remove pyc files
utils_pyc = os.path.join(get_base_path(), "app", "selling", "utils.pyc")
if os.path.exists(utils_pyc):
os.remove(utils_pyc)
old_path = os.path.join(get_base_path(), "app", "website")
if os.path.exists(old_path):
shutil.rmtree(old_path)

View File

@ -0,0 +1,3 @@
{% extends "lib/website/templates/base.html" %}
{% block footer %}{% include "app/portal/templates/includes/footer.html" %}{% endblock %}

View File

@ -4,33 +4,33 @@
// js inside blog page // js inside blog page
$(document).ready(function() { $(document).ready(function() {
wn.cart.bind_events(); erpnext.cart.bind_events();
return wn.call({ return wn.call({
type: "POST", type: "POST",
method: "website.helpers.cart.get_cart_quotation", method: "selling.utils.cart.get_cart_quotation",
callback: function(r) { callback: function(r) {
console.log(r); console.log(r);
$("#cart-container").removeClass("hide"); $("#cart-container").removeClass("hide");
$(".progress").remove(); $(".progress").remove();
if(r.exc) { if(r.exc) {
if(r.exc.indexOf("WebsitePriceListMissingError")!==-1) { if(r.exc.indexOf("WebsitePriceListMissingError")!==-1) {
wn.cart.show_error("Oops!", "Price List not configured."); erpnext.cart.show_error("Oops!", "Price List not configured.");
} else if(r["403"]) { } else if(r["403"]) {
wn.cart.show_error("Hey!", "You need to be logged in to view your cart."); erpnext.cart.show_error("Hey!", "You need to be logged in to view your cart.");
} else { } else {
wn.cart.show_error("Oops!", "Something went wrong."); erpnext.cart.show_error("Oops!", "Something went wrong.");
} }
} else { } else {
wn.cart.set_cart_count(); erpnext.cart.set_cart_count();
wn.cart.render(r.message); erpnext.cart.render(r.message);
} }
} }
}); });
}); });
// shopping cart // shopping cart
if(!wn.cart) wn.cart = {}; if(!erpnext.cart) erpnext.cart = {};
$.extend(wn.cart, { $.extend(erpnext.cart, {
show_error: function(title, text) { show_error: function(title, text) {
$("#cart-container").html('<div class="well"><h4>' + title + '</h4> ' + text + '</div>'); $("#cart-container").html('<div class="well"><h4>' + title + '</h4> ' + text + '</div>');
}, },
@ -39,14 +39,14 @@ $.extend(wn.cart, {
// bind update button // bind update button
$(document).on("click", ".item-update-cart button", function() { $(document).on("click", ".item-update-cart button", function() {
var item_code = $(this).attr("data-item-code"); var item_code = $(this).attr("data-item-code");
wn.cart.update_cart({ erpnext.cart.update_cart({
item_code: item_code, item_code: item_code,
qty: $('input[data-item-code="'+item_code+'"]').val(), qty: $('input[data-item-code="'+item_code+'"]').val(),
with_doclist: 1, with_doclist: 1,
btn: this, btn: this,
callback: function(r) { callback: function(r) {
if(!r.exc) { if(!r.exc) {
wn.cart.render(r.message); erpnext.cart.render(r.message);
var $button = $('button[data-item-code="'+item_code+'"]').addClass("btn-success"); var $button = $('button[data-item-code="'+item_code+'"]').addClass("btn-success");
setTimeout(function() { $button.removeClass("btn-success"); }, 1000); setTimeout(function() { $button.removeClass("btn-success"); }, 1000);
} }
@ -63,7 +63,7 @@ $.extend(wn.cart, {
}); });
$(".btn-place-order").on("click", function() { $(".btn-place-order").on("click", function() {
wn.cart.place_order(); erpnext.cart.place_order(this);
}); });
}, },
@ -79,7 +79,7 @@ $.extend(wn.cart, {
var no_items = $.map(doclist, function(d) { return d.item_code || null;}).length===0; var no_items = $.map(doclist, function(d) { return d.item_code || null;}).length===0;
if(no_items) { if(no_items) {
wn.cart.show_error("Empty :-(", "Go ahead and add something to your cart."); erpnext.cart.show_error("Empty :-(", "Go ahead and add something to your cart.");
$("#cart-addresses").toggle(false); $("#cart-addresses").toggle(false);
return; return;
} }
@ -89,14 +89,14 @@ $.extend(wn.cart, {
var shipping_rule_labels = $.map(out.shipping_rules || [], function(rule) { return rule[1]; }); var shipping_rule_labels = $.map(out.shipping_rules || [], function(rule) { return rule[1]; });
$.each(doclist, function(i, doc) { $.each(doclist, function(i, doc) {
if(doc.doctype === "Quotation Item") { if(doc.doctype === "Quotation Item") {
wn.cart.render_item_row($cart_items, doc); erpnext.cart.render_item_row($cart_items, doc);
} else if (doc.doctype === "Sales Taxes and Charges") { } else if (doc.doctype === "Sales Taxes and Charges") {
if(out.shipping_rules && out.shipping_rules.length && if(out.shipping_rules && out.shipping_rules.length &&
shipping_rule_labels.indexOf(doc.description)!==-1) { shipping_rule_labels.indexOf(doc.description)!==-1) {
shipping_rule_added = true; shipping_rule_added = true;
wn.cart.render_tax_row($cart_taxes, doc, out.shipping_rules); erpnext.cart.render_tax_row($cart_taxes, doc, out.shipping_rules);
} else { } else {
wn.cart.render_tax_row($cart_taxes, doc); erpnext.cart.render_tax_row($cart_taxes, doc);
} }
taxes_exist = true; taxes_exist = true;
@ -104,7 +104,7 @@ $.extend(wn.cart, {
}); });
if(out.shipping_rules && out.shipping_rules.length && !shipping_rule_added) { if(out.shipping_rules && out.shipping_rules.length && !shipping_rule_added) {
wn.cart.render_tax_row($cart_taxes, {description: "", formatted_tax_amount: ""}, erpnext.cart.render_tax_row($cart_taxes, {description: "", formatted_tax_amount: ""},
out.shipping_rules); out.shipping_rules);
taxes_exist = true; taxes_exist = true;
} }
@ -112,7 +112,7 @@ $.extend(wn.cart, {
if(taxes_exist) if(taxes_exist)
$('<hr>').appendTo($cart_taxes); $('<hr>').appendTo($cart_taxes);
wn.cart.render_tax_row($cart_totals, { erpnext.cart.render_tax_row($cart_totals, {
description: "<strong>Total</strong>", description: "<strong>Total</strong>",
formatted_tax_amount: "<strong>" + doclist[0].formatted_grand_total_export + "</strong>" formatted_tax_amount: "<strong>" + doclist[0].formatted_grand_total_export + "</strong>"
}); });
@ -120,15 +120,15 @@ $.extend(wn.cart, {
if(!(addresses && addresses.length)) { if(!(addresses && addresses.length)) {
$cart_shipping_address.html('<div class="well">Hey! Go ahead and add an address</div>'); $cart_shipping_address.html('<div class="well">Hey! Go ahead and add an address</div>');
} else { } else {
wn.cart.render_address($cart_shipping_address, addresses, doclist[0].shipping_address_name); erpnext.cart.render_address($cart_shipping_address, addresses, doclist[0].shipping_address_name);
wn.cart.render_address($cart_billing_address, addresses, doclist[0].customer_address); erpnext.cart.render_address($cart_billing_address, addresses, doclist[0].customer_address);
} }
}, },
render_item_row: function($cart_items, doc) { render_item_row: function($cart_items, doc) {
doc.image_html = doc.image ? doc.image_html = doc.image ?
'<div style="height: 120px; overflow: hidden;"><img src="' + doc.image + '" /></div>' : '<div style="height: 120px; overflow: hidden;"><img src="' + doc.image + '" /></div>' :
'{% include "app/website/templates/html/product_missing_image.html" %}'; '{% include "app/stock/doctype/item/templates/includes/product_missing_image.html" %}';
if(doc.description === doc.item_name) doc.description = ""; if(doc.description === doc.item_name) doc.description = "";
@ -185,7 +185,7 @@ $.extend(wn.cart, {
} }
}); });
$tax_row.find('select').on("change", function() { $tax_row.find('select').on("change", function() {
wn.cart.apply_shipping_rule($(this).val(), this); erpnext.cart.apply_shipping_rule($(this).val(), this);
}); });
} }
}, },
@ -194,11 +194,11 @@ $.extend(wn.cart, {
return wn.call({ return wn.call({
btn: btn, btn: btn,
type: "POST", type: "POST",
method: "website.helpers.cart.apply_shipping_rule", method: "selling.utils.cart.apply_shipping_rule",
args: { shipping_rule: rule }, args: { shipping_rule: rule },
callback: function(r) { callback: function(r) {
if(!r.exc) { if(!r.exc) {
wn.cart.render(r.message); erpnext.cart.render(r.message);
} }
} }
}); });
@ -242,14 +242,14 @@ $.extend(wn.cart, {
return wn.call({ return wn.call({
type: "POST", type: "POST",
method: "website.helpers.cart.update_cart_address", method: "selling.utils.cart.update_cart_address",
args: { args: {
address_fieldname: $address_wrapper.attr("data-fieldname"), address_fieldname: $address_wrapper.attr("data-fieldname"),
address_name: $(this).attr("data-address-name") address_name: $(this).attr("data-address-name")
}, },
callback: function(r) { callback: function(r) {
if(!r.exc) { if(!r.exc) {
wn.cart.render(r.message); erpnext.cart.render(r.message);
} }
} }
}); });
@ -270,10 +270,11 @@ $.extend(wn.cart, {
.collapse("show"); .collapse("show");
}, },
place_order: function() { place_order: function(btn) {
return wn.call({ return wn.call({
type: "POST", type: "POST",
method: "website.helpers.cart.place_order", method: "selling.utils.cart.place_order",
btn: btn,
callback: function(r) { callback: function(r) {
if(r.exc) { if(r.exc) {
var msg = ""; var msg = "";

View File

@ -0,0 +1,40 @@
{% extends "lib/website/templates/includes/footer.html" %}
{% block powered %}<a style="font-size: 90%; color: #aaa;" href="http://erpnext.org">ERPNext Powered</a>{% endblock %}
{% block extension %}
<br>
<div class="input-group col-md-6 col-md-offset-3">
<input class="form-control" type="text" id="footer-subscribe-email" placeholder="Your email address...">
<span class="input-group-btn">
<button class="btn btn-default" type="button" id="footer-subscribe-button">Stay Updated</button>
</span>
</div>
<br>
<script>
$("#footer-subscribe-button").click(function() {
$("#footer-subscribe-email").attr('disabled', true);
$("#footer-subscribe-button").html("Sending...")
.attr("disabled", true);
if($("#footer-subscribe-email").val()) {
erpnext.send_message({
subject:"Subscribe me",
sender: $("#footer-subscribe-email").val(),
message: "Subscribe to newsletter (via website footer).",
callback: function(r) {
if(!r.exc) {
$("#footer-subscribe-button").html("Thank You :)")
.addClass("btn-success").attr("disabled", true);
} else {
$("#footer-subscribe-button").html("Error :( Not a valid id?")
.addClass("btn-danger").attr("disabled", false);
$("#footer-subscribe-email").val("").attr('disabled', false);
}
}
});
}
});
</script>
{% endblock %}

View File

@ -1,12 +1,13 @@
{% extends "app/website/templates/html/page.html" %} {% extends base_template %}
{% block content -%} {% block content -%}
<div class="col-md-12"> <div class="col-md-12">
<ul class="breadcrumb"> <ul class="breadcrumb">
<li><a href="index">Home</a></li> <li><a href="index">Home</a></li>
<li><a href="account">My Account</a></li>
<li class="active"><i class="{{ icon }} icon-fixed-width"></i> {{ title }}</li> <li class="active"><i class="{{ icon }} icon-fixed-width"></i> {{ title }}</li>
</ul> </ul>
<p id="msgprint-alert" class="alert alert-danger"
style="display: none;">&nbsp;</p>
<div class="list-group transaction-list"> <div class="list-group transaction-list">
<div class="progress progress-striped active"> <div class="progress progress-striped active">
<div class="progress-bar progress-bar-info" style="width: 100%;"></div> <div class="progress-bar progress-bar-info" style="width: 100%;"></div>
@ -19,6 +20,7 @@
{%- endblock %} {%- endblock %}
{% block javascript -%} {% block javascript -%}
<script>
$(document).ready(function() { $(document).ready(function() {
window.start = 0; window.start = 0;
window.$list = $(".transaction-list"); window.$list = $(".transaction-list");
@ -35,7 +37,6 @@ var get_transactions = function(btn) {
callback: function(r) { callback: function(r) {
$list.find(".progress").remove(); $list.find(".progress").remove();
$show_more.toggleClass("hide", !(r.message && r.message.length===20)); $show_more.toggleClass("hide", !(r.message && r.message.length===20));
if(!(r.message && r.message.length)) { if(!(r.message && r.message.length)) {
console.log("empty"); console.log("empty");
if(!$list.html().trim()) { if(!$list.html().trim()) {
@ -53,7 +54,7 @@ var get_transactions = function(btn) {
} }
}) })
}; };
</script>
// var render = function(doc) { }; <!-- // var render = function(doc) { }; -->
{% endblock %} {% endblock %}

View File

@ -1,7 +1,7 @@
{% extends "app/website/templates/html/page.html" %} {% extends base_template %}
{% block javascript %} {% block javascript %}
{% include "app/website/templates/js/cart.js" %} <script>{% include "app/portal/templates/includes/cart.js" %}</script>
{% endblock %} {% endblock %}
{% set title="Shopping Cart" %} {% set title="Shopping Cart" %}
@ -13,7 +13,7 @@
<div class="progress-bar progress-bar-info" style="width: 100%;"></div> <div class="progress-bar progress-bar-info" style="width: 100%;"></div>
</div> </div>
<div id="cart-container" class="hide"> <div id="cart-container" class="hide">
<button class="btn btn-success pull-right btn-place-order" type="button">Place Order</button> <p class="pull-right"><button class="btn btn-success btn-place-order" type="button">Place Order</button></p>
<div class="clearfix"></div> <div class="clearfix"></div>
<div id="cart-error" class="alert alert-danger" style="display: none;"></div> <div id="cart-error" class="alert alert-danger" style="display: none;"></div>
<hr> <hr>
@ -51,7 +51,7 @@
</div> </div>
<hr> <hr>
</div> </div>
<button class="btn btn-success pull-right btn-place-order" type="button">Place Order</button> <p class="pull-right"><button class="btn btn-success btn-place-order" type="button">Place Order</button></p>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}

View File

@ -2,8 +2,5 @@
# License: GNU General Public License v3. See license.txt # License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals from __future__ import unicode_literals
import webnotes
class DocType: no_cache = True
def __init__(self, d, dl):
self.doc, self.doclist = d, dl

View File

@ -1,4 +1,4 @@
{% extends "app/website/templates/html/page.html" %} {% extends base_template %}
{% set title="My Profile" %} {% set title="My Profile" %}
@ -6,19 +6,14 @@
<div class="col-md-12"> <div class="col-md-12">
<ul class="breadcrumb"> <ul class="breadcrumb">
<li><a href="index">Home</a></li> <li><a href="index">Home</a></li>
<li><a href="account">My Account</a></li>
<li class="active"><i class="icon-user icon-fixed-width"></i> My Profile</li> <li class="active"><i class="icon-user icon-fixed-width"></i> My Profile</li>
</ul> </ul>
<div class="alert" id="message" style="display: none;"></div> <div class="alert alert-warning" id="message" style="display: none;"></div>
<form> <form>
<fieldset> <fieldset>
<label>Full Name</label> <label>Full Name</label>
<input class="form-control" type="text" id="fullname" placeholder="Your Name"> <input class="form-control" type="text" id="fullname" placeholder="Your Name">
</fieldset> </fieldset>
<fieldset>
<label>Password</label>
<input class="form-control" type="password" id="password" placeholder="Password">
</fieldset>
<fieldset> <fieldset>
<label>Company Name</label> <label>Company Name</label>
<input class="form-control" type="text" id="company_name" placeholder="Company Name" value="{{ company_name }}"> <input class="form-control" type="text" id="company_name" placeholder="Company Name" value="{{ company_name }}">
@ -39,11 +34,10 @@ $(document).ready(function() {
$("#fullname").val(getCookie("full_name") || ""); $("#fullname").val(getCookie("full_name") || "");
$("#update_profile").click(function() { $("#update_profile").click(function() {
wn.call({ wn.call({
method: "startup.webutils.update_profile", method: "portal.templates.pages.profile.update_profile",
type: "POST", type: "POST",
args: { args: {
fullname: $("#fullname").val(), fullname: $("#fullname").val(),
password: $("#password").val(),
company_name: $("#company_name").val(), company_name: $("#company_name").val(),
mobile_no: $("#mobile_no").val(), mobile_no: $("#mobile_no").val(),
phone: $("#phone").val() phone: $("#phone").val()

View File

@ -0,0 +1,39 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes import _
from webnotes.utils import cstr
no_cache = True
def get_context():
from selling.utils.cart import get_lead_or_customer
party = get_lead_or_customer()
if party.doctype == "Lead":
mobile_no = party.mobile_no
phone = party.phone
else:
mobile_no, phone = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user,
"customer": party.name}, ["mobile_no", "phone"])
return {
"company_name": cstr(party.customer_name if party.doctype == "Customer" else party.company_name),
"mobile_no": cstr(mobile_no),
"phone": cstr(phone)
}
@webnotes.whitelist()
def update_profile(fullname, password=None, company_name=None, mobile_no=None, phone=None):
from selling.utils.cart import update_party
update_party(fullname, company_name, mobile_no, phone)
if not fullname:
return _("Name is required")
webnotes.conn.set_value("Profile", webnotes.session.user, "first_name", fullname)
webnotes.add_cookies["full_name"] = fullname
return _("Updated")

View File

@ -1,4 +1,4 @@
{% extends "app/website/templates/html/page.html" %} {% extends base_template %}
{% set title=doc.name %} {% set title=doc.name %}
@ -6,7 +6,6 @@
<div class="col-md-12"> <div class="col-md-12">
<ul class="breadcrumb"> <ul class="breadcrumb">
<li><a href="index">Home</a></li> <li><a href="index">Home</a></li>
<li><a href="account">My Account</a></li>
<li><a href="{{ parent_link }}">{{ parent_title }}</a></li> <li><a href="{{ parent_link }}">{{ parent_title }}</a></li>
<li class="active"><i class="icon-file icon-fixed-width"></i> {{ doc.name }}</li> <li class="active"><i class="icon-file icon-fixed-width"></i> {{ doc.name }}</li>
</ul> </ul>
@ -18,7 +17,7 @@
<div> <div>
<div class="row"> <div class="row">
<div class="col-xs-6"> <div class="col-xs-6">
{% if doc.status -%}<div class="label label-default">{{ doc.status }}</div>{%- endif %} {% block status -%}{%- endblock %}
</div> </div>
<div class="col-xs-6"> <div class="col-xs-6">
<span class="pull-right">{{ utils.formatdate(doc.posting_date or doc.transaction_date) }}</span> <span class="pull-right">{{ utils.formatdate(doc.posting_date or doc.transaction_date) }}</span>

View File

@ -0,0 +1,32 @@
{% extends "app/portal/templates/includes/transactions.html" %}
{% block javascript -%}
<script>
$(document).ready(function() {
global_number_format = "{{ global_number_format }}";
currency = "{{ currency }}";
wn.currency_symbols = {{ currency_symbols }};
});
</script>
{{ super() }}
<script>
var render = function(doc) {
doc.grand_total_export = format_currency(doc.grand_total_export, doc.currency);
if(!doc.status) doc.status = "";
$(repl('<a href="{{ page }}?name=%(name)s" class="list-group-item">\
<div class="row">\
<div class="col-md-6">\
<div class="row col-md-12">%(name)s</div>\
<div class="row col-md-12 text-muted">%(items)s</div>\
<div class="row col-md-12">%(status)s</div>\
</div>\
<div class="col-md-3 text-right">%(grand_total_export)s</div>\
<div class="col-md-3 text-right text-muted">%(creation)s</div>\
</div>\
</a>', doc)).appendTo($list);
};
</script>
{%- endblock %}

72
portal/utils.py Normal file
View File

@ -0,0 +1,72 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cint, formatdate
import json
def get_transaction_list(doctype, start, additional_fields=None):
# find customer id
customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user},
"customer")
if customer:
if additional_fields:
additional_fields = ", " + ", ".join(("`%s`" % f for f in additional_fields))
else:
additional_fields = ""
transactions = webnotes.conn.sql("""select name, creation, currency, grand_total_export
%s
from `tab%s` where customer=%s and docstatus=1
order by creation desc
limit %s, 20""" % (additional_fields, doctype, "%s", "%s"),
(customer, cint(start)), as_dict=True)
for doc in transactions:
items = webnotes.conn.sql_list("""select item_name
from `tab%s Item` where parent=%s limit 6""" % (doctype, "%s"), doc.name)
doc.items = ", ".join(items[:5]) + ("..." if (len(items) > 5) else "")
doc.creation = formatdate(doc.creation)
return transactions
else:
return []
def get_currency_context():
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 get_transaction_context(doctype, name):
customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user},
"customer")
bean = webnotes.bean(doctype, name)
if bean.doc.customer != customer:
return {
"doc": {"name": "Not Allowed"}
}
else:
return {
"doc": bean.doc,
"doclist": bean.doclist,
"webnotes": webnotes,
"utils": webnotes.utils
}
@webnotes.whitelist(allow_guest=True)
def send_message(subject="Website Query", message="", sender="", status="Open"):
from website.doctype.contact_us_settings.templates.pages.contact \
import send_message as website_send_message
if not website_send_message(subject, message, sender):
return
# make lead / communication
from selling.doctype.lead.get_leads import add_sales_communication
add_sales_communication(subject or "Website Query", message, sender, sender,
mail=None, status=status)

View File

@ -40,7 +40,7 @@ wn.module_page["Projects"] = [
icon: "icon-wrench", icon: "icon-wrench",
items: [ items: [
{ {
page: "Projects", route: "Gantt/Task",
label: wn._("Gantt Chart"), label: wn._("Gantt Chart"),
"description":wn._("Gantt chart of all tasks.") "description":wn._("Gantt chart of all tasks.")
}, },

View File

@ -1,7 +1,6 @@
{ {
"public/css/all-web.css": [ "public/css/all-web.css": [
"app/public/js/startup.css", "app/public/js/startup.css",
"app/website/css/website.css"
], ],
"public/css/all-app.css": [ "public/css/all-app.css": [
"app/public/js/startup.css" "app/public/js/startup.css"

View File

@ -149,6 +149,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
}, },
price_list_currency: function() { price_list_currency: function() {
var me=this;
this.set_dynamic_labels(); this.set_dynamic_labels();
var company_currency = this.get_company_currency(); var company_currency = this.get_company_currency();
@ -156,7 +157,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
this.get_exchange_rate(this.frm.doc.price_list_currency, company_currency, this.get_exchange_rate(this.frm.doc.price_list_currency, company_currency,
function(exchange_rate) { function(exchange_rate) {
if(exchange_rate) { if(exchange_rate) {
me.frm.set_value("price_list_currency", exchange_rate); me.frm.set_value("plc_conversion_rate", exchange_rate);
me.plc_conversion_rate(); me.plc_conversion_rate();
} }
}); });
@ -348,8 +349,6 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
} }
}); });
console.log(distinct_items);
var rows = $.map(distinct_items, function(item) { var rows = $.map(distinct_items, function(item) {
var item_tax_record = item_tax[item.item_code || item.item_name]; var item_tax_record = item_tax[item.item_code || item.item_name];
if(!item_tax_record) { return null; } if(!item_tax_record) { return null; }
@ -419,10 +418,10 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
(this.frm.doc.currency != company_currency && this.frm.doc.conversion_rate != 1.0)) : (this.frm.doc.currency != company_currency && this.frm.doc.conversion_rate != 1.0)) :
false; false;
if(!valid_conversion_rate) { // if(!valid_conversion_rate) {
wn.throw(wn._("Please enter valid") + " " + wn._(conversion_rate_label) + // wn.throw(wn._("Please enter valid") + " " + wn._(conversion_rate_label) +
" 1 " + this.frm.doc.currency + " = [?] " + company_currency); // " 1 " + this.frm.doc.currency + " = [?] " + company_currency);
} // }
}, },
calculate_taxes_and_totals: function() { calculate_taxes_and_totals: function() {

View File

@ -2,200 +2,40 @@
// License: GNU General Public License v3. See license.txt // License: GNU General Public License v3. See license.txt
if(!window.erpnext) erpnext = {}; if(!window.erpnext) erpnext = {};
if(!window.wn) wn = {};
// Add / update a new Lead / Communication // Add / update a new Lead / Communication
// subject, sender, description // subject, sender, description
erpnext.send_message = function(opts) { wn.send_message = function(opts, btn) {
return wn.call({ return wn.call({
type: "POST", type: "POST",
method: "website.helpers.contact.send_message", method: "portal.utils.send_message",
btn: btn,
args: opts, args: opts,
callback: opts.callback callback: opts.callback
}); });
} };
wn.call = function(opts) { // for backward compatibility
if(opts.btn) { erpnext.send_message = wn.send_message;
$(opts.btn).prop("disabled", true);
}
if(opts.msg) {
$(opts.msg).toggle(false);
}
if(!opts.args) opts.args = {};
// get or post?
if(!opts.args._type) {
opts.args._type = opts.type || "GET";
}
// method
if(opts.method) {
opts.args.cmd = opts.method;
}
// stringify
$.each(opts.args, function(key, val) {
if(typeof val != "string") {
opts.args[key] = JSON.stringify(val);
}
});
$.ajax({
type: "POST",
url: "server.py",
data: opts.args,
dataType: "json",
success: function(data) {
if(opts.btn) {
$(opts.btn).prop("disabled", false);
}
if(data.exc) {
if(opts.btn) {
$(opts.btn).addClass("btn-danger");
setTimeout(function() { $(opts.btn).removeClass("btn-danger"); }, 1000);
}
try {
var err = JSON.parse(data.exc);
if($.isArray(err)) {
err = err.join("\n");
}
console.error ? console.error(err) : console.log(err);
} catch(e) {
console.log(data.exc);
}
} else{
if(opts.btn) {
$(opts.btn).addClass("btn-success");
setTimeout(function() { $(opts.btn).removeClass("btn-success"); }, 1000);
}
}
if(opts.msg && data.message) {
$(opts.msg).html(data.message).toggle(true);
}
if(opts.callback)
opts.callback(data);
},
error: function(response) {
console.error ? console.error(response) : console.log(response);
}
});
return false;
}
// Setup the user tools // Setup the user tools
// //
$(document).ready(function() { $(document).ready(function() {
// update login // update login
var full_name = getCookie("full_name"); erpnext.cart.set_cart_count();
// update profile
if(full_name) { if(full_name) {
$("#user-tools").addClass("hide"); $('.navbar li[data-label="Profile"] a')
$("#user-tools-post-login").removeClass("hide"); .html('<i class="icon-fixed-width icon-user"></i> ' + full_name);
$("#user-full-name").text(full_name);
} }
wn.cart.set_cart_count();
$("#user-tools a").tooltip({"placement":"bottom"});
$("#user-tools-post-login a").tooltip({"placement":"bottom"});
}); });
// Utility functions
function valid_email(id) {
if(id.toLowerCase().search("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?")==-1)
return 0; else return 1; }
var validate_email = valid_email;
function get_url_arg(name) {
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if(results == null)
return "";
else
return decodeURIComponent(results[1]);
}
function make_query_string(obj) {
var query_params = [];
$.each(obj, function(k, v) { query_params.push(encodeURIComponent(k) + "=" + encodeURIComponent(v)); });
return "?" + query_params.join("&");
}
function repl(s, dict) {
if(s==null)return '';
for(key in dict) {
s = s.split("%("+key+")s").join(dict[key]);
}
return s;
}
function replace_all(s, t1, t2) {
return s.split(t1).join(t2);
}
function getCookie(name) {
return getCookies()[name];
}
function getCookies() {
var c = document.cookie, v = 0, cookies = {};
if (document.cookie.match(/^\s*\$Version=(?:"1"|1);\s*(.*)/)) {
c = RegExp.$1;
v = 1;
}
if (v === 0) {
c.split(/[,;]/).map(function(cookie) {
var parts = cookie.split(/=/, 2),
name = decodeURIComponent(parts[0].trimLeft()),
value = parts.length > 1 ? decodeURIComponent(parts[1].trimRight()) : null;
if(value && value.charAt(0)==='"') {
value = value.substr(1, value.length-2);
}
cookies[name] = value;
});
} else {
c.match(/(?:^|\s+)([!#$%&'*+\-.0-9A-Z^`a-z|~]+)=([!#$%&'*+\-.0-9A-Z^`a-z|~]*|"(?:[\x20-\x7E\x80\xFF]|\\[\x00-\x7F])*")(?=\s*[,;]|$)/g).map(function($0, $1) {
var name = $0,
value = $1.charAt(0) === '"'
? $1.substr(1, -1).replace(/\\(.)/g, "$1")
: $1;
cookies[name] = value;
});
}
return cookies;
}
if (typeof String.prototype.trimLeft !== "function") {
String.prototype.trimLeft = function() {
return this.replace(/^\s+/, "");
};
}
if (typeof String.prototype.trimRight !== "function") {
String.prototype.trimRight = function() {
return this.replace(/\s+$/, "");
};
}
if (typeof Array.prototype.map !== "function") {
Array.prototype.map = function(callback, thisArg) {
for (var i=0, n=this.length, a=[]; i<n; i++) {
if (i in this) a[i] = callback.call(thisArg, this[i]);
}
return a;
};
}
// shopping cart // shopping cart
if(!wn.cart) wn.cart = {}; if(!erpnext.cart) erpnext.cart = {};
var full_name = getCookie("full_name");
$.extend(wn.cart, { $.extend(erpnext.cart, {
update_cart: function(opts) { update_cart: function(opts) {
if(!full_name) { if(!full_name) {
if(localStorage) { if(localStorage) {
@ -206,7 +46,7 @@ $.extend(wn.cart, {
} else { } else {
return wn.call({ return wn.call({
type: "POST", type: "POST",
method: "website.helpers.cart.update_cart", method: "selling.utils.cart.update_cart",
args: { args: {
item_code: opts.item_code, item_code: opts.item_code,
qty: opts.qty, qty: opts.qty,
@ -217,7 +57,7 @@ $.extend(wn.cart, {
if(opts.callback) if(opts.callback)
opts.callback(r); opts.callback(r);
wn.cart.set_cart_count(); erpnext.cart.set_cart_count();
} }
}); });
} }
@ -225,29 +65,22 @@ $.extend(wn.cart, {
set_cart_count: function() { set_cart_count: function() {
var cart_count = getCookie("cart_count"); var cart_count = getCookie("cart_count");
if(cart_count) var $cart = $("#website-post-login").find('[data-label="Cart"]');
$(".cart-count").html("( "+ cart_count +" )") var $badge = $cart.find(".badge");
} var $cog = $("#website-post-login").find(".dropdown-toggle");
}); var $cog_count = $cog.find(".cart-count");
if(cart_count) {
function remove_script_and_style(txt) { if($badge.length === 0) {
return (!txt || (txt.indexOf("<script>")===-1 && txt.indexOf("<style>")===-1)) ? txt : var $badge = $('<span class="badge pull-right"></span>').appendTo($cart.find("a"));
$("<div></div>").html(txt).find("script,noscript,style,title,meta").remove().end().html(); }
} $badge.html(cart_count);
if($cog_count.length === 0) {
function is_html(txt) { var $cog_count = $('<sup class="cart-count"></span>').insertAfter($cog.find(".icon-cog"));
if(txt.indexOf("<br>")==-1 && txt.indexOf("<p")==-1 }
&& txt.indexOf("<img")==-1 && txt.indexOf("<div")==-1) { $cog_count.html(cart_count);
return false; } else {
} $badge.remove();
return true; $cog_count.remove();
}
function ask_to_login() {
if(!full_name) {
if(localStorage) {
localStorage.setItem("last_visited", window.location.href.split("/").slice(-1)[0]);
} }
window.location.href = "login";
} }
} });

View File

@ -57,6 +57,8 @@ class TestCustomer(unittest.TestCase):
# check that old name doesn't exist # check that old name doesn't exist
self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer"), ()) self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer"), ())
self.assertEqual(webnotes.conn.exists("Account", "_Test Customer - _TC"), ()) self.assertEqual(webnotes.conn.exists("Account", "_Test Customer - _TC"), ())
test_ignore = ["Price List"]
test_records = [ test_records = [
[{ [{

View File

@ -31,13 +31,9 @@ class DocType:
def get_item_details(self, name): def get_item_details(self, name):
det = webnotes.conn.sql("""select description, stock_uom from `tabItem` det = webnotes.conn.sql("""select description, stock_uom from `tabItem`
where name = %s""", name) where name = %s""", name)
rate = webnotes.conn.sql("""select ref_rate from `tabItem Price`
where price_list = %s and parent = %s
and ref_currency = %s""", (self.doc.price_list, name, self.doc.currency))
return { return {
'description' : det and det[0][0] or '', 'description' : det and det[0][0] or '',
'uom': det and det[0][1] or '', 'uom': det and det[0][1] or ''
'rate': rate and flt(rate[0][0]) or 0.00
} }
def check_duplicate(self, finder=0): def check_duplicate(self, finder=0):

View File

@ -2,7 +2,7 @@
{ {
"creation": "2013-05-23 16:55:51", "creation": "2013-05-23 16:55:51",
"docstatus": 0, "docstatus": 0,
"modified": "2013-07-10 14:54:19", "modified": "2013-09-09 15:47:56",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -53,17 +53,18 @@
"label": "Description", "label": "Description",
"oldfieldname": "description", "oldfieldname": "description",
"oldfieldtype": "Text", "oldfieldtype": "Text",
"print_width": "300px", "print_width": "300px"
"width": "300px"
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
"fieldname": "rate", "fieldname": "rate",
"fieldtype": "Float", "fieldtype": "Float",
"in_list_view": 1, "hidden": 1,
"in_list_view": 0,
"label": "Rate", "label": "Rate",
"oldfieldname": "rate", "oldfieldname": "rate",
"oldfieldtype": "Currency" "oldfieldtype": "Currency",
"print_hide": 1
}, },
{ {
"doctype": "DocField", "doctype": "DocField",

View File

@ -49,16 +49,6 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
this.frm.set_query("selling_price_list", function() { this.frm.set_query("selling_price_list", function() {
return { filters: { buying_or_selling: "Selling" } }; return { filters: { buying_or_selling: "Selling" } };
}); });
this.frm.set_query("price_list_currency", function() {
return {
query: "controllers.queries.get_price_list_currency",
filters: {
price_list: me.frm.doc.selling_price_list,
buying_or_selling: "Selling"
}
};
});
} }
if(!this.fname) { if(!this.fname) {

View File

@ -286,6 +286,9 @@ class DocType(SellingController):
def on_update(self): def on_update(self):
pass pass
def get_portal_page(self):
return "order" if self.doc.docstatus==1 else None
def set_missing_values(source, target): def set_missing_values(source, target):
bean = webnotes.bean(target) bean = webnotes.bean(target)
bean.run_method("onload_post_render") bean.run_method("onload_post_render")

View File

@ -0,0 +1,5 @@
{% extends "app/portal/templates/sale.html" %}
{% block status -%}
{% if doc.status %}{{ doc.status }}{% endif %}
{%- endblock %}

View File

@ -0,0 +1,32 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes import _
no_cache = True
def get_context():
from portal.utils import get_transaction_context
context = get_transaction_context("Sales Order", webnotes.form_dict.name)
modify_status(context.get("doc"))
context.update({
"parent_link": "orders",
"parent_title": "My Orders"
})
return context
def modify_status(doc):
doc.status = []
if 0 < doc.per_billed < 100:
doc.status.append(("label-warning", "icon-ok", _("Partially Billed")))
elif doc.per_billed == 100:
doc.status.append(("label-success", "icon-ok", _("Billed")))
if 0 < doc.per_delivered < 100:
doc.status.append(("label-warning", "icon-truck", _("Partially Delivered")))
elif doc.per_delivered == 100:
doc.status.append(("label-success", "icon-truck", _("Delivered")))
doc.status = " " + " ".join(('<span class="label %s"><i class="icon-fixed-width %s"></i> %s</span>' % s
for s in doc.status))

View File

@ -0,0 +1 @@
{% extends "app/portal/templates/sales_transactions.html" %}

View File

@ -0,0 +1,30 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
no_cache = True
def get_context():
from portal.utils import get_currency_context
context = get_currency_context()
context.update({
"title": "My Orders",
"method": "selling.doctype.sales_order.templates.pages.orders.get_orders",
"icon": "icon-list",
"empty_list_message": "No Orders Yet",
"page": "order",
})
return context
@webnotes.whitelist()
def get_orders(start=0):
from portal.utils import get_transaction_list
from selling.doctype.sales_order.templates.pages.order import modify_status
orders = get_transaction_list("Sales Order", start, ["per_billed", "per_delivered"])
for d in orders:
modify_status(d)
return orders

View File

@ -2,14 +2,14 @@
{ {
"creation": "2013-06-20 16:00:18", "creation": "2013-06-20 16:00:18",
"docstatus": 0, "docstatus": 0,
"modified": "2013-08-09 14:47:12", "modified": "2013-08-09 14:47:15",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
{ {
"doctype": "DocType", "doctype": "DocType",
"istable": 1, "istable": 1,
"module": "Website", "module": "Selling",
"name": "__common__" "name": "__common__"
}, },
{ {

View File

@ -94,6 +94,11 @@ class DocType(DocListController):
price_list_currency_map = webnotes.conn.get_values("Price List", price_list_currency_map = webnotes.conn.get_values("Price List",
[d.selling_price_list for d in self.doclist.get({"parentfield": "price_lists"})], [d.selling_price_list for d in self.doclist.get({"parentfield": "price_lists"})],
"currency") "currency")
# check if all price lists have a currency
for price_list, currency in price_list_currency_map.items():
if not currency:
webnotes.throw("%s: %s" % (_("Currency is missing for Price List"), price_list))
expected_to_exist = [currency + "-" + company_currency expected_to_exist = [currency + "-" + company_currency
for currency in price_list_currency_map.values() for currency in price_list_currency_map.values()

View File

@ -2,7 +2,7 @@
{ {
"creation": "2013-06-19 15:57:32", "creation": "2013-06-19 15:57:32",
"docstatus": 0, "docstatus": 0,
"modified": "2013-07-15 17:33:05", "modified": "2013-07-15 17:33:15",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -11,7 +11,7 @@
"doctype": "DocType", "doctype": "DocType",
"icon": "icon-shopping-cart", "icon": "icon-shopping-cart",
"issingle": 1, "issingle": 1,
"module": "Website", "module": "Selling",
"name": "__common__" "name": "__common__"
}, },
{ {

View File

@ -6,7 +6,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import webnotes import webnotes
import unittest import unittest
from website.doctype.shopping_cart_settings.shopping_cart_settings import ShoppingCartSetupError from selling.doctype.shopping_cart_settings.shopping_cart_settings import ShoppingCartSetupError
class TestShoppingCartSettings(unittest.TestCase): class TestShoppingCartSettings(unittest.TestCase):
def setUp(self): def setUp(self):

View File

@ -2,14 +2,14 @@
{ {
"creation": "2013-07-03 13:15:34", "creation": "2013-07-03 13:15:34",
"docstatus": 0, "docstatus": 0,
"modified": "2013-07-10 14:54:23", "modified": "2013-07-10 14:54:25",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
{ {
"doctype": "DocType", "doctype": "DocType",
"istable": 1, "istable": 1,
"module": "Website", "module": "Selling",
"name": "__common__" "name": "__common__"
}, },
{ {

View File

@ -2,14 +2,14 @@
{ {
"creation": "2013-06-20 16:57:03", "creation": "2013-06-20 16:57:03",
"docstatus": 0, "docstatus": 0,
"modified": "2013-07-10 14:54:23", "modified": "2013-07-10 14:54:25",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
{ {
"doctype": "DocType", "doctype": "DocType",
"istable": 1, "istable": 1,
"module": "Website", "module": "Selling",
"name": "__common__" "name": "__common__"
}, },
{ {

View File

@ -65,6 +65,12 @@ wn.module_page["Selling"] = [
"doctype":"Selling Settings", "doctype":"Selling Settings",
"description": "Settings for Selling Module" "description": "Settings for Selling Module"
}, },
{
"route":"Form/Shopping Cart Settings",
"label":wn._("Shopping Cart Settings"),
"description":wn._("Setup of Shopping Cart."),
doctype:"Shopping Cart Settings"
},
{ {
label: wn._("Sales Taxes and Charges Master"), label: wn._("Sales Taxes and Charges Master"),
description: wn._("Sales taxes template."), description: wn._("Sales taxes template."),

View File

@ -141,20 +141,19 @@ def _get_basic_details(args, item_bean, warehouse_fieldname):
return out return out
def _get_price_list_rate(args, item_bean, meta): def _get_price_list_rate(args, item_bean, meta):
base_ref_rate = item_bean.doclist.get({ ref_rate = webnotes.conn.sql("""select ip.ref_rate from `tabItem Price` ip,
"parentfield": "ref_rate_details", `tabPrice List` pl where ip.parent = pl.name and ip.parent=%s and
"price_list": args.selling_price_list, ip.item_code=%s and pl.buying_or_selling='Selling'""",
"ref_currency": args.price_list_currency, (args.selling_price_list, args.item_code), as_dict=1)
"buying_or_selling": "Selling"})
if not base_ref_rate: if not ref_rate:
return {} return {}
# found price list rate - now we can validate # found price list rate - now we can validate
from utilities.transaction_base import validate_currency from utilities.transaction_base import validate_currency
validate_currency(args, item_bean.doc, meta) validate_currency(args, item_bean.doc, meta)
return {"ref_rate": flt(base_ref_rate[0].ref_rate) * flt(args.plc_conversion_rate) / flt(args.conversion_rate)} return {"ref_rate": flt(ref_rate[0].ref_rate) * flt(args.plc_conversion_rate) / flt(args.conversion_rate)}
def _get_item_discount(item_group, customer): def _get_item_discount(item_group, customer):
parent_item_groups = [x[0] for x in webnotes.conn.sql("""SELECT parent.name parent_item_groups = [x[0] for x in webnotes.conn.sql("""SELECT parent.name

View File

@ -4,9 +4,9 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import webnotes import webnotes
from webnotes.utils import cstr, cint, fmt_money from webnotes.utils import cstr, cint, fmt_money, get_base_path
from webnotes.webutils import build_html, delete_page_cache from webnotes.webutils import delete_page_cache
from website.helpers.cart import _get_cart_quotation from selling.utils.cart import _get_cart_quotation
@webnotes.whitelist(allow_guest=True) @webnotes.whitelist(allow_guest=True)
def get_product_info(item_code): def get_product_info(item_code):
@ -27,18 +27,19 @@ def get_product_info(item_code):
else: else:
in_stock = -1 in_stock = -1
price = price_list and webnotes.conn.sql("""select ref_rate, ref_currency from price = price_list and webnotes.conn.sql("""select ip.ref_rate, pl.currency from
`tabItem Price` where parent=%s and price_list=%s""", `tabItem Price` ip, `tabPrice List` pl where ip.parent = pl.name and
ip.item_code=%s and ip.parent=%s""",
(item_code, price_list), as_dict=1) or [] (item_code, price_list), as_dict=1) or []
price = price and price[0] or None price = price and price[0] or None
qty = 0 qty = 0
if price: if price:
price["formatted_price"] = fmt_money(price["ref_rate"], currency=price["ref_currency"]) price["formatted_price"] = fmt_money(price["ref_rate"], currency=price["currency"])
price["ref_currency"] = not cint(webnotes.conn.get_default("hide_currency_symbol")) \ price["currency"] = not cint(webnotes.conn.get_default("hide_currency_symbol")) \
and (webnotes.conn.get_value("Currency", price.ref_currency, "symbol") or price.ref_currency) \ and (webnotes.conn.get_value("Currency", price.currency, "symbol") or price.currency) \
or "" or ""
if webnotes.session.user != "Guest": if webnotes.session.user != "Guest":
@ -106,10 +107,12 @@ def get_group_item_count(item_group):
or name in (select parent from `tabWebsite Item Group` or name in (select parent from `tabWebsite Item Group`
where item_group in (%s))) """ % (child_groups, child_groups))[0][0] where item_group in (%s))) """ % (child_groups, child_groups))[0][0]
def get_item_for_list_in_html(r): def get_item_for_list_in_html(context):
scrub_item_for_list(r) from jinja2 import Environment, FileSystemLoader
r.template = "app/website/templates/html/product_in_grid.html" scrub_item_for_list(context)
return build_html(r) jenv = Environment(loader = FileSystemLoader(get_base_path()))
template = jenv.get_template("app/stock/doctype/item/templates/includes/product_in_grid.html")
return template.render(context)
def scrub_item_for_list(r): def scrub_item_for_list(r):
if not r.website_description: if not r.website_description:

View File

@ -23,8 +23,6 @@ $.extend(cur_frm.cscript, {
set_exchange_rate_label: function() { set_exchange_rate_label: function() {
if(cur_frm.doc.from_currency && cur_frm.doc.to_currency) { if(cur_frm.doc.from_currency && cur_frm.doc.to_currency) {
var default_label = wn._(wn.meta.docfield_map[cur_frm.doctype]["exchange_rate"].label); var default_label = wn._(wn.meta.docfield_map[cur_frm.doctype]["exchange_rate"].label);
console.log(default_label +
repl(" (1 %(from_currency)s = [?] %(to_currency)s)", cur_frm.doc));
cur_frm.fields_dict.exchange_rate.set_label(default_label + cur_frm.fields_dict.exchange_rate.set_label(default_label +
repl(" (1 %(from_currency)s = [?] %(to_currency)s)", cur_frm.doc)); repl(" (1 %(from_currency)s = [?] %(to_currency)s)", cur_frm.doc));
} }

View File

@ -1,6 +1,9 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt # License: GNU General Public License v3. See license.txt
test_ignore = ["Price List"]
test_records = [ test_records = [
[{ [{
"doctype": "Customer Group", "doctype": "Customer Group",

View File

@ -18,7 +18,7 @@ class DocType(DocTypeNestedSet):
self.validate_name_with_item() self.validate_name_with_item()
from website.helpers.product import invalidate_cache_for from selling.utils.product import invalidate_cache_for
if self.doc.show_in_website: if self.doc.show_in_website:
from webnotes.webutils import update_page_name from webnotes.webutils import update_page_name
@ -44,8 +44,8 @@ class DocType(DocTypeNestedSet):
webnotes.msgprint("An item exists with same name (%s), please change the \ webnotes.msgprint("An item exists with same name (%s), please change the \
item group name or rename the item" % self.doc.name, raise_exception=1) item group name or rename the item" % self.doc.name, raise_exception=1)
def prepare_template_args(self): def get_context(self):
from website.helpers.product import get_product_list_for_group, \ from selling.utils.product import get_product_list_for_group, \
get_parent_item_groups, get_group_item_count get_parent_item_groups, get_group_item_count
self.doc.sub_groups = webnotes.conn.sql("""select name, page_name self.doc.sub_groups = webnotes.conn.sql("""select name, page_name
@ -60,6 +60,6 @@ class DocType(DocTypeNestedSet):
self.doc.title = self.doc.name self.doc.title = self.doc.name
if self.doc.slideshow: if self.doc.slideshow:
from website.helpers.slideshow import get_slideshow from website.doctype.website_slideshow.website_slideshow import get_slideshow
get_slideshow(self) get_slideshow(self)

View File

@ -1,11 +1,11 @@
{% extends "app/website/templates/html/page.html" %} {% extends base_template %}
{% block content %} {% block content %}
{% include 'app/website/templates/html/product_search_box.html' %} {% include 'app/stock/doctype/item/templates/includes/product_search_box.html' %}
{% include 'app/website/templates/html/product_breadcrumbs.html' %} {% include 'app/stock/doctype/item/templates/includes/product_breadcrumbs.html' %}
<div class="col-md-12"> <div class="col-md-12">
{% if slideshow %}<!-- slideshow --> {% if slideshow %}<!-- slideshow -->
{% include "app/website/templates/html/slideshow.html" %} {% include "lib/website/doctype/website_slideshow/templates/includes/slideshow.html" %}
{% endif %} {% endif %}
{% if description %}<!-- description --> {% if description %}<!-- description -->
<div>{{ description or ""}}</div> <div>{{ description or ""}}</div>
@ -31,11 +31,11 @@
{{ item }} {{ item }}
{% endfor %} {% endfor %}
</div> </div>
{% if len(items)==100 %} {% if (items|length)==100 %}
<div class="alert info">Showing top 100 items.</div> <div class="alert alert-info info">Showing top 100 items.</div>
{% endif %} {% endif %}
{% else %} {% else %}
<div class="alert">No items listed.</div> <div class="alert alert-warning">No items listed.</div>
{% endif %} {% endif %}
</div> </div>

View File

@ -0,0 +1,2 @@
doctype = "Item Group"
condition_field = "show_in_website"

View File

@ -1,5 +1,5 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt # MIT License. See license.txt
# For license information, please see license.txt # For license information, please see license.txt

View File

@ -2,7 +2,7 @@
{ {
"creation": "2013-05-02 16:29:48", "creation": "2013-05-02 16:29:48",
"docstatus": 0, "docstatus": 0,
"modified": "2013-08-09 14:46:58", "modified": "2013-09-13 11:50:02",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -11,18 +11,20 @@
"doctype": "DocType", "doctype": "DocType",
"in_create": 0, "in_create": 0,
"istable": 1, "istable": 1,
"module": "Stock", "module": "Setup",
"name": "__common__", "name": "__common__",
"read_only": 0 "read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
"in_filter": 1,
"in_list_view": 1, "in_list_view": 1,
"name": "__common__", "name": "__common__",
"parent": "Item Price", "parent": "Item Price",
"parentfield": "fields", "parentfield": "fields",
"parenttype": "DocType", "parenttype": "DocType",
"permlevel": 0 "permlevel": 0,
"reqd": 1
}, },
{ {
"doctype": "DocType", "doctype": "DocType",
@ -30,49 +32,22 @@
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
"fieldname": "price_list", "fieldname": "item_code",
"fieldtype": "Link", "fieldtype": "Link",
"in_filter": 1, "label": "Item Code",
"label": "Price List Name",
"oldfieldname": "price_list_name", "oldfieldname": "price_list_name",
"oldfieldtype": "Select", "oldfieldtype": "Select",
"options": "Price List", "options": "Item",
"reqd": 1,
"search_index": 1 "search_index": 1
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
"fieldname": "ref_rate", "fieldname": "ref_rate",
"fieldtype": "Currency", "fieldtype": "Currency",
"in_filter": 1, "label": "Rate",
"label": "Ref Rate",
"oldfieldname": "ref_rate", "oldfieldname": "ref_rate",
"oldfieldtype": "Currency", "oldfieldtype": "Currency",
"options": "ref_currency", "options": "currency",
"reqd": 1,
"search_index": 0 "search_index": 0
},
{
"doctype": "DocField",
"fieldname": "ref_currency",
"fieldtype": "Link",
"in_filter": 1,
"label": "Currency",
"oldfieldname": "ref_currency",
"oldfieldtype": "Select",
"options": "Currency",
"read_only": 1,
"reqd": 0,
"search_index": 1
},
{
"default": "Selling",
"doctype": "DocField",
"fieldname": "buying_or_selling",
"fieldtype": "Select",
"label": "Valid for Buying or Selling?",
"options": "Buying\nSelling",
"read_only": 1,
"reqd": 1
} }
] ]

View File

@ -3,44 +3,6 @@
$.extend(cur_frm.cscript, { $.extend(cur_frm.cscript, {
onload: function() { onload: function() {
cur_frm.cscript.show_item_prices();
erpnext.add_for_territory(); erpnext.add_for_territory();
}, },
refresh: function(doc) {
cur_frm.set_intro("");
if(doc.__islocal) {
cur_frm.toggle_display("item_prices_section", false);
cur_frm.set_intro("Save this list to begin.");
return;
} else {
cur_frm.cscript.show_item_prices();
}
},
show_item_prices: function() {
var item_price = wn.model.get("Item Price", {price_list: cur_frm.doc.name});
var show = item_price && item_price.length;
cur_frm.toggle_display("item_prices_section", show);
$(cur_frm.fields_dict.item_prices.wrapper).empty();
if (!show) return;
var out = '<table class="table table-striped table-bordered">\
<thead><tr>\
<th>' + wn._("Item Code") + '</th>\
<th>' + wn._("Price") + '</th>\
</tr></thead>\
<tbody>'
+ $.map(item_price.sort(function(a, b) { return a.parent.localeCompare(b.parent); }), function(d) {
return '<tr>'
+ '<td><a href="#Form/Item/' + encodeURIComponent(d.parent) +'">' + d.parent + '</a></td>'
+ '<td style="text-align: right;">' + format_currency(d.ref_rate, d.ref_currency) + '</td>'
+ '</tr>'
}).join("\n")
+ '</tbody>\
</table>';
$(out).appendTo($(cur_frm.fields_dict.item_prices.wrapper));
}
}); });

View File

@ -8,11 +8,9 @@ from webnotes.utils import comma_or, cint
from webnotes.model.controller import DocListController from webnotes.model.controller import DocListController
import webnotes.defaults import webnotes.defaults
class PriceListDuplicateItem(Exception): pass
class DocType(DocListController): class DocType(DocListController):
def onload(self):
self.doclist.extend(webnotes.conn.sql("""select * from `tabItem Price`
where price_list=%s""", self.doc.name, as_dict=True, update={"doctype": "Item Price"}))
def validate(self): def validate(self):
if self.doc.buying_or_selling not in ["Buying", "Selling"]: if self.doc.buying_or_selling not in ["Buying", "Selling"]:
msgprint(_(self.meta.get_label("buying_or_selling")) + " " + _("must be one of") + " " + msgprint(_(self.meta.get_label("buying_or_selling")) + " " + _("must be one of") + " " +
@ -29,17 +27,24 @@ class DocType(DocListController):
else: else:
# at least one territory # at least one territory
self.validate_table_has_rows("valid_for_territories") self.validate_table_has_rows("valid_for_territories")
# check for duplicate items
self.check_duplicate_items()
def on_update(self): def on_update(self):
self.set_default_if_missing() self.set_default_if_missing()
cart_settings = webnotes.get_obj("Shopping Cart Settings") cart_settings = webnotes.get_obj("Shopping Cart Settings")
if cint(cart_settings.doc.enabled): if cint(cart_settings.doc.enabled):
cart_settings.validate_price_lists() cart_settings.validate_price_lists()
def check_duplicate_items(self):
item_codes = []
for d in self.doclist.get({"parentfield": "item_prices"}):
if d.item_code not in item_codes:
item_codes.append(d.item_code)
else:
msgprint(_("Duplicate Item ") + ": " + d.item_code, raise_exception=PriceListDuplicateItem)
def on_trash(self):
webnotes.conn.sql("""delete from `tabItem Price` where price_list = %s""",
self.doc.name)
def set_default_if_missing(self): def set_default_if_missing(self):
if self.doc.buying_or_selling=="Selling": if self.doc.buying_or_selling=="Selling":
if not webnotes.conn.get_value("Selling Settings", None, "selling_price_list"): if not webnotes.conn.get_value("Selling Settings", None, "selling_price_list"):
@ -47,4 +52,5 @@ class DocType(DocListController):
elif self.doc.buying_or_selling=="Buying": elif self.doc.buying_or_selling=="Buying":
if not webnotes.conn.get_value("Buying Settings", None, "buying_price_list"): if not webnotes.conn.get_value("Buying Settings", None, "buying_price_list"):
webnotes.set_value("Buying Settings", "Buying Settings", "buying_price_list", self.doc.name) webnotes.set_value("Buying Settings", "Buying Settings", "buying_price_list", self.doc.name)

View File

@ -2,7 +2,7 @@
{ {
"creation": "2013-01-25 11:35:09", "creation": "2013-01-25 11:35:09",
"docstatus": 0, "docstatus": 0,
"modified": "2013-07-26 11:19:06", "modified": "2013-09-06 15:03:38",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -94,28 +94,9 @@
{ {
"doctype": "DocField", "doctype": "DocField",
"fieldname": "item_prices", "fieldname": "item_prices",
"fieldtype": "HTML", "fieldtype": "Table",
"label": "Item Prices" "label": "Item Prices",
}, "options": "Item Price"
{
"doctype": "DocField",
"fieldname": "column_break_10",
"fieldtype": "Column Break"
},
{
"depends_on": "eval:!doc.__islocal",
"doctype": "DocField",
"fieldname": "section_break_1",
"fieldtype": "Section Break",
"label": "How to upload"
},
{
"depends_on": "eval:!doc.__islocal",
"doctype": "DocField",
"fieldname": "how_to_upload",
"fieldtype": "HTML",
"label": "How to upload",
"options": "<div class=\"well\">Use the <a href=\"#data-import-tool\">Data Import Tool</a> to upload, update Item Prices in bulk:\n<ol> \n<li>Go to Data Import Tool.\n<li>Select \"Item\"\n<li>Check on \"With Data\"\n<li>Download \"Item Price\" from Child Tables.\n<li>Update the prices required and add new rows if required.\n<li>Check on \"Overwrite\"\n<li>Upload the modified sheet.\n</div>\n"
}, },
{ {
"amend": 0, "amend": 0,

View File

@ -1,6 +1,20 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt # License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import unittest
import webnotes
from setup.doctype.price_list.price_list import PriceListDuplicateItem
class TestItem(unittest.TestCase):
def test_duplicate_item(self):
price_list = webnotes.bean(copy=test_records[0])
item_price = price_list.doclist.get({"doctype": "Item Price"})[0]
price_list.doclist.append(webnotes.doc(item_price.fields.copy()))
self.assertRaises(PriceListDuplicateItem, price_list.insert)
# test_ignore = ["Item"]
test_records = [ test_records = [
[ [
{ {
@ -13,6 +27,12 @@ test_records = [
"doctype": "For Territory", "doctype": "For Territory",
"parentfield": "valid_for_territories", "parentfield": "valid_for_territories",
"territory": "All Territories" "territory": "All Territories"
},
{
"doctype": "Item Price",
"parentfield": "item_prices",
"item_code": "_Test Item",
"ref_rate": 100
} }
], ],
[ [

View File

@ -29,7 +29,7 @@ class DocType:
else: else:
return '' return ''
def prepare_template_args(self): def get_context(self):
address = webnotes.conn.get_value("Address", address = webnotes.conn.get_value("Address",
{"sales_partner": self.doc.name, "is_primary_address": 1}, {"sales_partner": self.doc.name, "is_primary_address": 1},
"*", as_dict=True) "*", as_dict=True)
@ -42,4 +42,4 @@ class DocType:
"email": address.email_id, "email": address.email_id,
"partner_address": filter_strip_join(address_rows, "\n<br>"), "partner_address": filter_strip_join(address_rows, "\n<br>"),
"phone": filter_strip_join(cstr(address.phone).split(","), "\n<br>") "phone": filter_strip_join(cstr(address.phone).split(","), "\n<br>")
}) })

View File

@ -1,4 +1,4 @@
{% extends "app/website/templates/html/page.html" %} {% extends base_template %}
{% block content %} {% block content %}
<div class="col-md-12" itemscope itemtype="http://schema.org/Organization"> <div class="col-md-12" itemscope itemtype="http://schema.org/Organization">

View File

@ -0,0 +1,2 @@
doctype = "Sales Partner"
condition_field = "show_in_website"

View File

@ -1,4 +1,4 @@
{% extends "app/website/templates/html/page.html" %} {% extends base_template %}
{% set title="Partners" %} {% set title="Partners" %}

View File

@ -0,0 +1,7 @@
import webnotes
def get_context():
return {
"partners": webnotes.conn.sql("""select * from `tabSales Partner`
where show_in_website=1 order by name asc""", as_dict=True),
}

View File

@ -101,7 +101,6 @@ class DocType:
'default_currency': args.get('currency'), 'default_currency': args.get('currency'),
'default_company':args.get('company_name'), 'default_company':args.get('company_name'),
'date_format': webnotes.conn.get_value("Country", args.get("country"), "date_format"), 'date_format': webnotes.conn.get_value("Country", args.get("country"), "date_format"),
'emp_created_by':'Naming Series',
"float_precision": 4 "float_precision": 4
}) })
global_defaults.save() global_defaults.save()
@ -135,6 +134,10 @@ class DocType:
notification_control.doc.purchase_order = 1 notification_control.doc.purchase_order = 1
notification_control.save() notification_control.save()
hr_settings = webnotes.bean("HR Settings")
hr_settings.doc.emp_created_by = "Naming Series"
hr_settings.save()
# control panel # control panel
cp = webnotes.doc("Control Panel", "Control Panel") cp = webnotes.doc("Control Panel", "Control Panel")
for k in ['country', 'timezone', 'company_name']: for k in ['country', 'timezone', 'company_name']:

View File

@ -1,5 +1,5 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt # MIT License. See license.txt
# For license information, please see license.txt # For license information, please see license.txt

Some files were not shown because too many files have changed in this diff Show More