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

This commit is contained in:
Nabin Hait
2013-07-16 14:40:40 +05:30
22 changed files with 636 additions and 331 deletions

View File

@@ -19,10 +19,4 @@ Tabs!
### Copyright ### Copyright
The ERPNext code is licensed as GNU General Public License (v3) and the Documentation is licensed as Creative Commons (CC-BY-SA-3.0) and the copyright is owned by Web Notes Technologies Pvt Ltd (Web Notes). Unless otherwise asserted in the code files, Web Notes will own the copyright of all contributions too. That means Web Notes holds the rights to change the license in the future or offer Commercial Licenses. Please see README.md
We will only accept copyright assertions in case of a significant contribution like a whole new functionality or a major rewrite. We believe if your contribution is significant then you should have a say in what license Web Notes selects in the future and/or have a right to any revenue Web Notes gets from a Commercial License. Either ways Web Notes will have the right to decide what is a "significant" contribution.
Note: At the moment, Web Notes does not give Commercial License for ERPNext nor has specific plans do so in the future.
The brand name ERPNext and the logo are trademarks of Web Notes Technologies Pvt. Ltd.

View File

@@ -4,40 +4,89 @@
Includes Accounting, Inventory, CRM, Sales, Purchase, Projects, HRMS. Built on Python / MySQL. Includes Accounting, Inventory, CRM, Sales, Purchase, Projects, HRMS. Built on Python / MySQL.
## Platform ERPNext is built on [wnframework](https://github.com/webnotes/wnframework)
ERPNext is built on [wnframework](https://github.com/webnotes/wnframework) (Version 2.0) - [User Guide](https://erpnext.org/docs.user.html)
- [Getting Help](https://erpnext.org/docs.user.help.html)
- [Developer Forum](http://groups.google.com/group/erpnext-developer-forum)
- [User Forum](http://groups.google.com/group/erpnext-user-forum)
## User Guide ---
[See wiki](https://github.com/webnotes/erpnext/wiki/User-Guide) ### Download and Install
## Download and Install ##### Virtual Image:
First install all the pre-requisites, then - [ERPNext Download](http://erpnext.com/erpnext-download)
$ git clone git://github.com/webnotes/erpnext.git ##### On Linux:
$ cd erpnext
$ python erpnext_install.py 1. Switch to root user using `sudo su`
1. create a folder where you want to install erpnext
1. go to the new folder
1. `wget https://raw.github.com/webnotes/erpnext/master/install_erpnext.py`
1. `python install_erpnext.py`
[See installation notes](https://github.com/webnotes/erpnext/wiki/How-to-Install-ERPNext) [See installation notes](https://github.com/webnotes/erpnext/wiki/How-to-Install-ERPNext)
## Patch and update ##### Patch and update
To patch and update from the latest git repository the erpnext folder and run. To patch and update from the latest git repository the erpnext folder and run.
You will have to set your origin in git remote You will have to set your origin in git remote
$ lib/wnf.py --update origin master $ lib/wnf.py --update origin master
## Forums ---
Please join our forums for more questions:
- [Developer Forum](http://groups.google.com/group/erpnext-developer-forum)
- [User Forum](http://groups.google.com/group/erpnext-user-forum)
## License ## License
GNU/General Public License (see licence.txt) GNU/General Public License (see LICENSE.txt)
Along with the GPL, the name "ERPNext" must be retained in all derivatives. The ERPNext code is licensed as GNU General Public License (v3) and the Documentation is licensed as Creative Commons (CC-BY-SA-3.0) and the copyright is owned by Web Notes Technologies Pvt Ltd (Web Notes).
### Copyright for Contributors
Unless otherwise asserted in the code files, Web Notes will own the copyright of all contributions too. That means Web Notes holds the rights to change the license in the future or offer Commercial Licenses.
Web Notes will only accept copyright assertions in case of a significant contribution like a whole new functionality or a major rewrite. We believe if your contribution is significant then you should have a say in what license Web Notes selects in the future and/or have a right to any revenue Web Notes gets from a Commercial License. Either ways Web Notes will have the right to decide what is a "significant" contribution.
Note: At the moment, Web Notes does not give Commercial License for ERPNext nor has specific plans do so in the future.
---
## Logo and Trademark
The brand name ERPNext and the logo are trademarks of Web Notes Technologies Pvt. Ltd.
### Introduction
Web Notes Technologies Pvt. Ltd. (Web Notes) owns and oversees the trademarks for the ERPNext name and logos. We have developed this trademark usage policy with the following goals in mind:
- Wed like to make it easy for anyone to use the ERPNext name or logo for community-oriented efforts that help spread and improve ERPNext.
- Wed like to make it clear how ERPNext-related businesses and projects can (and cannot) use the ERPNext name and logo.
- Wed like to make it hard for anyone to use the ERPNext name and logo to unfairly profit from, trick or confuse people who are looking for official ERPNext resources.
### Web Notes Trademark Usage Policy
Permission from Web Notes is required to use the ERPNext name or logo as part of any project, product, service, domain or company name.
We will grant permission to use the ERPNext name and logo for projects that meet the following criteria:
- The primary purpose of your project is to promote the spread and improvement of the ERPNext software.
- Your project is non-commercial in nature (it can make money to cover its costs or contribute to non-profit entities, but it cannot be run as a for-profit project or business).
Your project neither promotes nor is associated with entities that currently fail to comply with the GPL license under which ERPNext is distributed.
- If your project meets these criteria, you will be permitted to use the ERPNext name and logo to promote your project in any way you see fit with one exception: Please do not use ERPNext as part of a domain name.
Use of the ERPNext name and logo is additionally allowed in the following situations:
All other ERPNext-related businesses or projects can use the ERPNext name and logo to refer to and explain their services, but they cannot use them as part of a product, project, service, domain, or company name and they cannot use them in any way that suggests an affiliation with or endorsement by the ERPNext or WebNotes or the ERPNext open source project. For example, a consulting company can describe its business as “123 Web Services, offering ERPNext consulting for small businesses,” but cannot call its business “The ERPNext Consulting Company.”
Similarly, its OK to use the ERPNext logo as part of a page that describes your products or services, but it is not OK to use it as part of your company or product logo or branding itself. Under no circumstances is it permitted to use ERPNext as part of a top-level domain name.
We do not allow the use of the trademark in advertising, including AdSense/AdWords.
Please note that it is not the goal of this policy to limit commercial activity around ERPNext. We encourage ERPNext-based businesses, and we would love to see hundreds of them.
When in doubt about your use of the ERPNext name or logo, please contact the Web Notes Technologies for clarification.
(inspired from Wordpress)

View File

@@ -8,19 +8,20 @@
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
//--------- ONLOAD ------------- //--------- ONLOAD -------------
cur_frm.cscript.onload = function(doc, cdt, cdn) { cur_frm.cscript.onload = function(doc, cdt, cdn) {
// if(doc.doctype === "Sales Taxes and Charges Master")
erpnext.add_for_territory();
} }
cur_frm.cscript.refresh = function(doc, cdt, cdn) { cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.set_footnote(wn.markdown(cur_frm.meta.description)); cur_frm.set_footnote(wn.markdown(cur_frm.meta.description));
} }
// For customizing print // For customizing print
@@ -41,7 +42,7 @@ cur_frm.pformat.in_words_export = function(doc) {
} }
cur_frm.pformat.other_charges= function(doc){ cur_frm.pformat.other_charges= function(doc){
//function to make row of table //function to make row of table
var make_row = function(title,val,bold){ var make_row = function(title,val,bold){
var bstart = '<b>'; var bend = '</b>'; var bstart = '<b>'; var bend = '</b>';
return '<tr><td style="width:50%;">'+(bold?bstart:'')+title+(bold?bend:'')+'</td>' return '<tr><td style="width:50%;">'+(bold?bstart:'')+title+(bold?bend:'')+'</td>'
@@ -63,7 +64,7 @@ cur_frm.pformat.other_charges= function(doc){
if (!doc.print_without_amount) { if (!doc.print_without_amount) {
var cl = getchildren('Sales Taxes and Charges',doc.name,'other_charges'); var cl = getchildren('Sales Taxes and Charges',doc.name,'other_charges');
// outer table // outer table
var out='<div><table class="noborder" style="width:100%"><tr><td style="width: 60%"></td><td>'; var out='<div><table class="noborder" style="width:100%"><tr><td style="width: 60%"></td><td>';
// main table // main table
@@ -77,7 +78,7 @@ cur_frm.pformat.other_charges= function(doc){
if(cl.length){ if(cl.length){
for(var i=0;i<cl.length;i++){ for(var i=0;i<cl.length;i++){
if(convert_rate(cl[i].tax_amount)!=0 && !cl[i].included_in_print_rate) if(convert_rate(cl[i].tax_amount)!=0 && !cl[i].included_in_print_rate)
out += make_row(cl[i].description,convert_rate(cl[i].tax_amount),0); out += make_row(cl[i].description,convert_rate(cl[i].tax_amount),0);
} }
} }
@@ -96,98 +97,98 @@ cur_frm.pformat.other_charges= function(doc){
out += '<table><tr><td style="width:25%;"><b>In Words</b></td>' out += '<table><tr><td style="width:25%;"><b>In Words</b></td>'
out+= '<td style="width:50%;">'+doc.in_words_export+'</td></tr>' out+= '<td style="width:50%;">'+doc.in_words_export+'</td></tr>'
} }
out +='</table></td></tr></table></div>'; out +='</table></td></tr></table></div>';
} }
return out; return out;
} }
cur_frm.cscript.charge_type = function(doc, cdt, cdn) { cur_frm.cscript.charge_type = function(doc, cdt, cdn) {
var d = locals[cdt][cdn]; var d = locals[cdt][cdn];
if(d.idx == 1 && (d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total')){ if(d.idx == 1 && (d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total')){
alert("You cannot select Charge Type as 'On Previous Row Amount' or 'On Previous Row Total' for first row"); alert("You cannot select Charge Type as 'On Previous Row Amount' or 'On Previous Row Total' for first row");
d.charge_type = ''; d.charge_type = '';
} }
validated = false; validated = false;
refresh_field('charge_type',d.name,'other_charges'); refresh_field('charge_type',d.name,'other_charges');
cur_frm.cscript.row_id(doc, cdt, cdn); cur_frm.cscript.row_id(doc, cdt, cdn);
cur_frm.cscript.rate(doc, cdt, cdn); cur_frm.cscript.rate(doc, cdt, cdn);
cur_frm.cscript.tax_amount(doc, cdt, cdn); cur_frm.cscript.tax_amount(doc, cdt, cdn);
} }
cur_frm.cscript.row_id = function(doc, cdt, cdn) { cur_frm.cscript.row_id = function(doc, cdt, cdn) {
var d = locals[cdt][cdn]; var d = locals[cdt][cdn];
if(!d.charge_type && d.row_id){ if(!d.charge_type && d.row_id){
alert("Please select Charge Type first"); alert("Please select Charge Type first");
d.row_id = ''; d.row_id = '';
} }
else if((d.charge_type == 'Actual' || d.charge_type == 'On Net Total') && d.row_id) { else if((d.charge_type == 'Actual' || d.charge_type == 'On Net Total') && d.row_id) {
alert("You can Enter Row only if your Charge Type is 'On Previous Row Amount' or ' Previous Row Total'"); alert("You can Enter Row only if your Charge Type is 'On Previous Row Amount' or ' Previous Row Total'");
d.row_id = ''; d.row_id = '';
} }
else if((d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total') && d.row_id){ else if((d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total') && d.row_id){
if(d.row_id >= d.idx){ if(d.row_id >= d.idx){
alert("You cannot Enter Row no. greater than or equal to current row no. for this Charge type"); alert("You cannot Enter Row no. greater than or equal to current row no. for this Charge type");
d.row_id = ''; d.row_id = '';
} }
} }
validated = false; validated = false;
refresh_field('row_id',d.name,'other_charges'); refresh_field('row_id',d.name,'other_charges');
} }
/*---------------------- Get rate if account_head has account_type as TAX or CHARGEABLE-------------------------------------*/ /*---------------------- Get rate if account_head has account_type as TAX or CHARGEABLE-------------------------------------*/
cur_frm.fields_dict['other_charges'].grid.get_field("account_head").get_query = function(doc,cdt,cdn) { cur_frm.fields_dict['other_charges'].grid.get_field("account_head").get_query = function(doc,cdt,cdn) {
return{ return{
filters:[ filters:[
['Account', 'group_or_ledger', '=', 'Ledger'], ['Account', 'group_or_ledger', '=', 'Ledger'],
['Account', 'account_type', 'in', 'Tax, Chargeable, Income Account'], ['Account', 'account_type', 'in', 'Tax, Chargeable, Income Account'],
['Account', 'company', '=', doc.company] ['Account', 'company', '=', doc.company]
] ]
} }
} }
cur_frm.fields_dict['other_charges'].grid.get_field("cost_center").get_query = function(doc) { cur_frm.fields_dict['other_charges'].grid.get_field("cost_center").get_query = function(doc) {
return{ return{
'company': doc.company, 'company': doc.company,
'group_or_ledger': "Ledger" 'group_or_ledger': "Ledger"
} }
} }
cur_frm.cscript.account_head = function(doc, cdt, cdn) { cur_frm.cscript.account_head = function(doc, cdt, cdn) {
var d = locals[cdt][cdn]; var d = locals[cdt][cdn];
if(!d.charge_type && d.account_head){ if(!d.charge_type && d.account_head){
alert("Please select Charge Type first"); alert("Please select Charge Type first");
validated = false; validated = false;
d.account_head = ''; d.account_head = '';
} }
else if(d.account_head && d.charge_type) { else if(d.account_head && d.charge_type) {
arg = "{'charge_type' : '" + d.charge_type +"', 'account_head' : '" + d.account_head + "'}"; arg = "{'charge_type' : '" + d.charge_type +"', 'account_head' : '" + d.account_head + "'}";
get_server_fields('get_rate', arg, 'other_charges', doc, cdt, cdn, 1); get_server_fields('get_rate', arg, 'other_charges', doc, cdt, cdn, 1);
} }
refresh_field('account_head',d.name,'other_charges'); refresh_field('account_head',d.name,'other_charges');
} }
cur_frm.cscript.rate = function(doc, cdt, cdn) { cur_frm.cscript.rate = function(doc, cdt, cdn) {
var d = locals[cdt][cdn]; var d = locals[cdt][cdn];
if(!d.charge_type && d.rate) { if(!d.charge_type && d.rate) {
alert("Please select Charge Type first"); alert("Please select Charge Type first");
d.rate = ''; d.rate = '';
} }
validated = false; validated = false;
refresh_field('rate',d.name,'other_charges'); refresh_field('rate',d.name,'other_charges');
} }
cur_frm.cscript.tax_amount = function(doc, cdt, cdn) { cur_frm.cscript.tax_amount = function(doc, cdt, cdn) {
var d = locals[cdt][cdn]; var d = locals[cdt][cdn];
if(!d.charge_type && d.tax_amount){ if(!d.charge_type && d.tax_amount){
alert("Please select Charge Type first"); alert("Please select Charge Type first");
d.tax_amount = ''; d.tax_amount = '';
} }
else if(d.charge_type && d.tax_amount) { else if(d.charge_type && d.tax_amount) {
alert("You cannot directly enter Amount and if your Charge Type is Actual enter your amount in Rate"); alert("You cannot directly enter Amount and if your Charge Type is Actual enter your amount in Rate");
d.tax_amount = ''; d.tax_amount = '';
} }
validated = false; validated = false;
refresh_field('tax_amount',d.name,'other_charges'); refresh_field('tax_amount',d.name,'other_charges');
}; };

View File

@@ -0,0 +1,5 @@
$.extend(cur_frm.cscript, {
onload: function() {
erpnext.add_for_territory();
}
});

View File

@@ -30,11 +30,6 @@ class AccountsController(TransactionBase):
self.validate_date_with_fiscal_year() self.validate_date_with_fiscal_year()
if self.meta.get_field("currency"): if self.meta.get_field("currency"):
self.company_currency = get_company_currency(self.doc.company)
validate_conversion_rate(self.doc.currency, self.doc.conversion_rate,
self.meta.get_label("conversion_rate"), self.doc.company)
self.calculate_taxes_and_totals() self.calculate_taxes_and_totals()
self.validate_value("grand_total", ">=", 0) self.validate_value("grand_total", ">=", 0)
self.set_total_in_words() self.set_total_in_words()
@@ -66,7 +61,7 @@ class AccountsController(TransactionBase):
"price_list_name": self.doc.price_list_name, "price_list_name": self.doc.price_list_name,
"buying_or_selling": buying_or_selling "buying_or_selling": buying_or_selling
})) }))
if self.doc.price_list_currency: if self.doc.price_list_currency:
if not self.doc.plc_conversion_rate: if not self.doc.plc_conversion_rate:
company_currency = get_company_currency(self.doc.company) company_currency = get_company_currency(self.doc.company)
@@ -129,6 +124,14 @@ class AccountsController(TransactionBase):
self.doclist.append(tax) self.doclist.append(tax)
def calculate_taxes_and_totals(self): def calculate_taxes_and_totals(self):
# validate conversion rate
if not self.doc.currency:
self.doc.currency = get_company_currency(self.doc.company)
self.doc.conversion_rate = 1.0
else:
validate_conversion_rate(self.doc.currency, self.doc.conversion_rate,
self.meta.get_label("conversion_rate"), self.doc.company)
self.doc.conversion_rate = flt(self.doc.conversion_rate) self.doc.conversion_rate = flt(self.doc.conversion_rate)
self.item_doclist = self.doclist.get({"parentfield": self.fname}) self.item_doclist = self.doclist.get({"parentfield": self.fname})
self.tax_doclist = self.doclist.get({"parentfield": self.other_fname}) self.tax_doclist = self.doclist.get({"parentfield": self.other_fname})

View File

@@ -17,7 +17,7 @@ Install ERPNext in one command!
1. Switch to root user using `sudo su` 1. Switch to root user using `sudo su`
1. create a folder where you want to install erpnext 1. create a folder where you want to install erpnext
1. go to the new folder 1. go to the new folder
1. `wget https://gist.github.com/anandpdoshi/5991402/raw/5b3b451720a8575f8708e58a640b9a760d048392/install_erpnext.py` 1. `wget https://raw.github.com/webnotes/erpnext/master/install_erpnext.py`
1. `python install_erpnext.py` 1. `python install_erpnext.py`
> If you are installing on your server for deployment, remember to change Administrator's password! > If you are installing on your server for deployment, remember to change Administrator's password!

View File

@@ -1,170 +1,343 @@
#!/usr/bin/python #!/usr/bin/env python
from __future__ import unicode_literals from __future__ import unicode_literals
import os, commands, sys import os, sys
def install(): apache_user = None
# get required details is_redhat = is_debian = None
root_pwd = get_root_password() root_password = None
db_name, db_pwd = get_new_db_details()
def install(install_path=None):
install_pre_requisites()
# install path if not install_path:
install_path = os.getcwd() install_path = os.getcwd()
install_erpnext(install_path)
post_install(install_path)
def install_pre_requisites():
global is_redhat, is_debian
is_redhat, is_debian = validate_install()
if is_redhat:
install_using_yum()
elif is_debian:
install_using_apt()
install_python_modules()
print "-"*80
print "Pre-requisites Installed"
print "-"*80
def validate_install():
import platform
# check os
operating_system = platform.system()
print "Operating System =", operating_system
if operating_system != "Linux":
raise Exception, "Sorry! This installer works only for Linux based Operating Systems"
# check python version
python_version = sys.version.split(" ")[0]
print "Python Version =", python_version
if not (python_version and int(python_version.split(".")[0])==2 and int(python_version.split(".")[1]) >= 6):
raise Exception, "Hey! ERPNext needs Python version to be 2.6+"
# check distribution
distribution = platform.linux_distribution()[0].lower().replace('"', '')
print "Distribution = ", distribution
is_redhat = distribution in ("redhat", "centos", "fedora")
is_debian = distribution in ("debian", "ubuntu", "elementary os")
if not (is_redhat or is_debian):
raise Exception, "Sorry! This installer works only with yum or apt-get package management"
return is_redhat, is_debian
def install_using_yum():
packages = "python python-setuptools MySQL-python httpd git memcached ntp vim-enhanced screen"
print "-"*80
print "Installing Packages: (This may take some time)"
print packages
print "-"*80
exec_in_shell("yum install -y %s" % packages)
if not exec_in_shell("which mysql"):
packages = "mysql mysql-server mysql-devel"
print "Installing Packages:", packages
exec_in_shell("yum install -y %s" % packages)
exec_in_shell("service mysqld restart")
# set a root password post install
global root_password
print "Please create a password for root user of MySQL"
root_password = (get_root_password() or "erpnext").strip()
exec_in_shell('mysqladmin -u root password "%s"' % (root_password,))
print "Root password set as", root_password
# install htop
if not exec_in_shell("which htop"):
try:
exec_in_shell("cd /tmp && rpm -i --force http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm && yum install -y htop")
except:
pass
update_config_for_redhat()
def update_config_for_redhat():
import re
global apache_user
apache_user = "apache"
# update memcache user
with open("/etc/sysconfig/memcached", "r") as original:
memcached_conf = original.read()
with open("/etc/sysconfig/memcached", "w") as modified:
modified.write(re.sub('USER.*', 'USER="%s"' % apache_user, memcached_conf))
# set to autostart on startup
for service in ("mysqld", "httpd", "memcached", "ntpd"):
exec_in_shell("chkconfig --level 2345 %s on" % service)
exec_in_shell("service %s restart" % service)
def install_using_apt():
packages = "python python-setuptools python-mysqldb apache2 git memcached ntp vim screen htop"
print "-"*80
print "Installing Packages: (This may take some time)"
print packages
print "-"*80
exec_in_shell("apt-get install -y %s" % packages)
if not exec_in_shell("which mysql"):
packages = "mysql-server libmysqlclient-dev"
print "Installing Packages:", packages
exec_in_shell("apt-get install -y %s" % packages)
update_config_for_debian()
def update_config_for_debian():
global apache_user
apache_user = "www-data"
# update memcache user
with open("/etc/memcached.conf", "r") as original:
memcached_conf = original.read()
with open("/etc/memcached.conf", "w") as modified:
modified.write(memcached_conf.replace("-u memcache", "-u %s" % apache_user))
exec_in_shell("a2enmod rewrite")
for service in ("mysql", "apache2", "memcached", "ntpd"):
exec_in_shell("service %s restart" % service)
def install_python_modules():
python_modules = "pytz python-dateutil jinja2 markdown2 termcolor python-memcached requests chardet dropbox google-api-python-client pygeoip gitpython"
print "-"*80
print "Installing Python Modules: (This may take some time)"
print python_modules
print "-"*80
exec_in_shell("easy_install pip")
exec_in_shell("pip install -q %s" % python_modules)
def install_erpnext(install_path):
print
print "-"*80
print "Installing ERPNext"
print "-"*80
# ask for details
global root_password
if not root_password:
root_password = get_root_password()
test_root_connection(root_password)
db_name = raw_input("ERPNext Database Name: ")
if not db_name:
raise Exception, "Sorry! You must specify ERPNext Database Name"
# install folders and conf
setup_folders(install_path) setup_folders(install_path)
setup_conf(install_path, db_name)
setup_conf(install_path, db_name, db_pwd)
# setup paths # setup paths
sys.path.append('.') sys.path.extend([".", "lib", "app"])
sys.path.append('lib')
sys.path.append('app')
setup_db(install_path, root_pwd, db_name) # install database, run patches, update schema
setup_db(install_path, root_password, db_name)
apply_patches(install_path) setup_cron(install_path)
show_remaining_steps() setup_apache_conf(install_path)
def setup_folders(path):
execute_in_shell("git clone git://github.com/webnotes/wnframework.git lib", verbose=1)
execute_in_shell("git clone git://github.com/webnotes/erpnext.git app", verbose=1)
public = os.path.join(path, "public")
os.mkdir(public)
os.mkdir(os.path.join(public, "files"))
os.mkdir(os.path.join(public, "backups"))
os.mkdir(os.path.join(path, "logs"))
def setup_conf(path, db_name, db_pwd):
# read template conf file
with open(os.path.join(path, 'lib', 'conf', 'conf.py'), 'r') as template:
content = template.read()
# manipulate content
import re
# set new_dbname, new_dbpassword, files_path, backup_path, log_file_name
content = re.sub("db_name.*", "db_name = '%s'" % db_name, content)
content = re.sub("db_password.*", "db_password = '%s'" % db_pwd, content)
# write conf file
with open(os.path.join(path, 'conf.py'), 'w') as new_conf:
new_conf.write(content)
def setup_db(path, root_pwd, db_name):
source = os.path.join(path, 'app', "master.sql")
execute_in_shell("gunzip -c %s.gz > %s" % (source, source), verbose=1)
from webnotes.install_lib.install import Installer
inst = Installer('root', root_pwd)
inst.import_from_db(db_name, source_path=source, verbose = 1)
execute_in_shell("rm %s" % source)
def apply_patches(path):
# need to build before patches, once, so that all-web.js and all-web.css exists
execute_in_shell("./lib/wnf.py -b", verbose=1)
execute_in_shell("./lib/wnf.py --patch_sync_build", verbose=1)
# set filemode false
execute_in_shell("cd app && git config core.filemode false", verbose=1)
execute_in_shell("cd lib && git config core.filemode false", verbose=1)
def get_root_password(): def get_root_password():
# ask for root mysql password # ask for root mysql password
import getpass import getpass
root_pwd = None root_pwd = None
while not root_pwd: root_pwd = getpass.getpass("MySQL Root user's Password: ")
root_pwd = getpass.getpass("MySQL Root user's Password: ")
test_root_connection(root_pwd)
return root_pwd return root_pwd
def test_root_connection(root_pwd): def test_root_connection(root_pwd):
err, out = execute_in_shell("mysql -u root -p%s -e 'exit'" % \ out = exec_in_shell("mysql -u root %s -e 'exit'" % \
root_pwd.replace('$', '\$').replace(' ', '\ ')) (("-p"+root_pwd) if root_pwd else "").replace('$', '\$').replace(' ', '\ '))
if "access denied" in out.lower(): if "access denied" in out.lower():
raise Exception("Incorrect MySQL Root user's password") raise Exception("Incorrect MySQL Root user's password")
def setup_folders(install_path):
from git import Repo
def get_new_db_details(): app = os.path.join(install_path, "app")
return get_input("New ERPNext Database Name: "), \ if not os.path.exists(app):
get_input("New ERPNext Database's Password: ") print "Cloning erpnext"
Repo.clone_from("https://github.com/webnotes/erpnext.git", app)
exec_in_shell("cd app && git config core.filemode false")
def get_input(msg): lib = os.path.join(install_path, "lib")
val = None if not os.path.exists(lib):
while not val: print "Cloning wnframework"
val = raw_input(msg) Repo.clone_from("https://github.com/webnotes/wnframework.git", lib)
return val exec_in_shell("cd lib && git config core.filemode false")
public = os.path.join(install_path, "public")
for p in [public, os.path.join(public, "files"), os.path.join(public, "backups"),
os.path.join(install_path, "logs")]:
if not os.path.exists(p):
os.mkdir(p)
def setup_conf(install_path, db_name):
import os, string, random, re
def show_remaining_steps(): # generate db password
steps_remaining = """ char_range = string.ascii_letters + string.digits
Notes: db_password = "".join((random.choice(char_range) for n in xrange(16)))
------
# make conf file
with open(os.path.join(install_path, "lib", "conf", "conf.py"), "r") as template:
conf = template.read()
conf = re.sub("db_name.*", 'db_name = "%s"' % (db_name,), conf)
conf = re.sub("db_password.*", 'db_password = "%s"' % (db_password,), conf)
with open(os.path.join(install_path, "conf.py"), "w") as conf_file:
conf_file.write(conf)
return db_password
def setup_db(install_path, root_password, db_name):
master_sql = os.path.join(install_path, "app", "master.sql")
exec_in_shell("gunzip -c %s.gz > %s" % (master_sql, master_sql))
from webnotes.install_lib.install import Installer
inst = Installer("root", root_password)
inst.import_from_db(db_name, source_path=master_sql, verbose=1)
sample apache conf file exec_in_shell("rm -f %s" % (master_sql,))
#-----------------------------------------------------------
SetEnv PYTHON_EGG_CACHE /var/www # run patches and sync
exec_in_shell("./lib/wnf.py -b --no_cms")
exec_in_shell("./lib/wnf.py --patch_sync_build")
def setup_cron(install_path):
erpnext_cron_entries = [
"*/3 * * * * cd %s && python lib/wnf.py --run_scheduler >> /var/log/erpnext-sch.log 2>&1" % install_path,
"0 */6 * * * cd %s && python lib/wnf.py --backup >> /var/log/erpnext-backup.log 2>&1" % install_path
]
for row in erpnext_cron_entries:
try:
existing_cron = exec_in_shell("crontab -l")
if row not in existing_cron:
exec_in_shell('{ crontab -l; echo "%s"; } | crontab' % row)
except:
exec_in_shell('echo "%s" | crontab' % row)
def setup_apache_conf(install_path):
apache_conf_content = """Listen 8080
NameVirtualHost *:8080
<VirtualHost *:8080>
ServerName localhost
DocumentRoot %s/public/
AddHandler cgi-script .cgi .xml .py
AddType application/vnd.ms-fontobject .eot
AddType font/ttf .ttf
AddType font/otf .otf
AddType application/x-font-woff .woff
# you can change 99 to any other port <Directory %s/public/>
# directory specific options
Options -Indexes +FollowSymLinks +ExecCGI
# directory's index file
DirectoryIndex web.py
AllowOverride all
Order Allow,Deny
Allow from all
Listen 99 # rewrite rule
NameVirtualHost *:99 RewriteEngine on
<VirtualHost *:99> RewriteCond %%{REQUEST_FILENAME} !-f
ServerName localhost RewriteCond %%{REQUEST_FILENAME} !-d
DocumentRoot {path to erpnext's folder}/public RewriteCond %%{REQUEST_FILENAME} !-l
AddHandler cgi-script .cgi .xml .py RewriteRule ^([^/]+)$ /web.py?page=$1 [QSA,L]
</Directory>
</VirtualHost>""" % (install_path, install_path)
new_apache_conf_path = os.path.join(install_path, os.path.basename(install_path)+".conf")
with open(new_apache_conf_path, "w") as apache_conf_file:
apache_conf_file.write(apache_conf_content)
<Directory {path to erpnext's folder}/public/> def post_install(install_path):
# directory specific options global apache_user
Options -Indexes +FollowSymLinks +ExecCGI exec_in_shell("chown -R %s %s" % (apache_user, install_path))
apache_conf_filename = os.path.basename(install_path)+".conf"
if is_redhat:
os.symlink(os.path.join(install_path, apache_conf_filename),
os.path.join("/etc/httpd/conf.d", apache_conf_filename))
exec_in_shell("service httpd restart")
elif is_debian:
os.symlink(os.path.join(install_path, apache_conf_filename),
os.path.join("/etc/apache2/sites-enabled", apache_conf_filename))
exec_in_shell("service apache2 restart")
print
print "-"*80
print "Installation complete"
print "Open your browser and go to http://localhost:8080"
print "Login using username = Administrator and password = admin"
# directory's index file def exec_in_shell(cmd):
DirectoryIndex web.py
# rewrite rule
RewriteEngine on
# condition 1:
# ignore login-page.html, app.html, blank.html, unsupported.html
RewriteCond %{REQUEST_URI} ^((?!app\.html|blank\.html|unsupported\.html).)*$
# condition 2: if there are no slashes
# and file is .html or does not containt a .
RewriteCond %{REQUEST_URI} ^(?!.+/)((.+\.html)|([^.]+))$
# rewrite if both of the above conditions are true
RewriteRule ^(.+)$ web.py?page=$1 [NC,L]
AllowOverride all
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
#-----------------------------------------------------------
To Do:
* Configure apache/http conf file to point to public folder
* chown recursively all files in your folder to apache user
* login using: user="Administrator" and password="admin"
"""
print steps_remaining
def execute_in_shell(cmd, verbose=0):
# using Popen instead of os.system - as recommended by python docs # using Popen instead of os.system - as recommended by python docs
from subprocess import Popen, PIPE from subprocess import Popen
p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE) import tempfile
# get err and output with tempfile.TemporaryFile() as stdout:
err, out = p.stderr.read(), p.stdout.read() with tempfile.TemporaryFile() as stderr:
p = Popen(cmd, shell=True, stdout=stdout, stderr=stderr)
p.wait()
if verbose: stdout.seek(0)
if err: print err out = stdout.read()
if out: print out
return err, out stderr.seek(0)
err = stderr.read()
if __name__=="__main__": if err and any((kw in err.lower() for kw in ["traceback", "error", "exception"])):
print out
raise Exception, err
else:
print "."
return out
if __name__ == "__main__":
install() install()

View File

@@ -0,0 +1,13 @@
import webnotes
from webnotes.utils import extract_email_id
def execute():
email_lead = {}
for name, email in webnotes.conn.sql("""select name, email_id from `tabLead`
where ifnull(email_id, '')!='' order by creation asc"""):
email = extract_email_id(email)
if email:
if email not in email_lead:
email_lead[email] = name
else:
webnotes.rename("Lead", name, email_lead[email], merge=True)

View File

@@ -197,7 +197,6 @@ patch_list = [
"execute:webnotes.reload_doc('website', 'doctype', 'blog_post') #2013-03-25", "execute:webnotes.reload_doc('website', 'doctype', 'blog_post') #2013-03-25",
"execute:webnotes.reload_doc('website', 'doctype', 'web_page') #2013-03-25", "execute:webnotes.reload_doc('website', 'doctype', 'web_page') #2013-03-25",
"execute:webnotes.reload_doc('setup', 'doctype', 'sales_partner') #2013-06-25", "execute:webnotes.reload_doc('setup', 'doctype', 'sales_partner') #2013-06-25",
"execute:webnotes.bean('Style Settings').save() #2013-03-25",
"execute:webnotes.conn.set_value('Email Settings', None, 'send_print_in_body_and_attachment', 1)", "execute:webnotes.conn.set_value('Email Settings', None, 'send_print_in_body_and_attachment', 1)",
"patches.march_2013.p09_unset_user_type_partner", "patches.march_2013.p09_unset_user_type_partner",
"patches.march_2013.p10_set_fiscal_year_for_stock", "patches.march_2013.p10_set_fiscal_year_for_stock",
@@ -251,4 +250,6 @@ patch_list = [
"execute:webnotes.delete_doc('Report', 'Received Items To Be Billed')", "execute:webnotes.delete_doc('Report', 'Received Items To Be Billed')",
"patches.july_2013.p02_copy_shipping_address", "patches.july_2013.p02_copy_shipping_address",
"patches.july_2013.p03_cost_center_company", "patches.july_2013.p03_cost_center_company",
"execute:webnotes.bean('Style Settings').save() #2013-07-16",
"patches.july_2013.p04_merge_duplicate_leads",
] ]

View File

@@ -39,5 +39,14 @@ $.extend(erpnext, {
cur_frm.toggle_display("company", false); cur_frm.toggle_display("company", false);
} }
} }
} },
add_for_territory: function() {
if(cur_frm.doc.__islocal &&
wn.model.get_doclist(cur_frm.doc.doctype, cur_frm.doc.name).length === 1) {
var territory = wn.model.add_child(cur_frm.doc, "For Territory",
"valid_for_territories");
territory.territory = wn.defaults.get_default("territory");
}
},
}); });

View File

@@ -492,6 +492,21 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
} }
}, },
shipping_rule: function() {
var me = this;
if(this.frm.doc.shipping_rule) {
this.frm.call({
doc: this.frm.doc,
method: "apply_shipping_rule",
callback: function(r) {
if(!r.exc) {
me.calculate_taxes_and_totals();
}
}
})
}
},
set_dynamic_labels: function() { set_dynamic_labels: function() {
this._super(); this._super();
set_sales_bom_help(this.frm.doc); set_sales_bom_help(this.frm.doc);

View File

@@ -2,7 +2,7 @@
{ {
"creation": "2013-05-02 17:53:24", "creation": "2013-05-02 17:53:24",
"docstatus": 0, "docstatus": 0,
"modified": "2013-07-05 14:39:17", "modified": "2013-07-15 15:03:01",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@@ -179,7 +179,6 @@
"fieldname": "hr", "fieldname": "hr",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "HR", "label": "HR",
"options": "<div style=\"padding-top: 8px;\" class=\"columnHeading\">HR</div>",
"read_only": 0 "read_only": 0
}, },
{ {

View File

@@ -14,43 +14,46 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
cur_frm.cscript.onload = function() { $.extend(cur_frm.cscript, {
cur_frm.cscript.show_item_prices(); onload: function() {
}
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
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(); cur_frm.cscript.show_item_prices();
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_name: 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));
} }
} });
cur_frm.cscript.show_item_prices = function() {
var item_price = wn.model.get("Item Price", {price_list_name: 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

@@ -82,10 +82,10 @@ def get_profile_args():
phone = party.phone phone = party.phone
else: else:
mobile_no, phone = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user, mobile_no, phone = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user,
"customer": party.name}) "customer": party.name}, ["mobile_no", "phone"])
return { return {
"company_name": party.customer_name if party.doctype == "Customer" else party.company_name, "company_name": cstr(party.customer_name if party.doctype == "Customer" else party.company_name),
"mobile_no": mobile_no, "mobile_no": cstr(mobile_no),
"phone": phone "phone": cstr(phone)
} }

View File

@@ -186,3 +186,8 @@ fieldset[disabled] .btn-default.active {
background-color: #a7a9aa; background-color: #a7a9aa;
border-color: #a7a9aa; border-color: #a7a9aa;
} }
.breadcrumb {
margin: 0 -20px 20px;
border-radius: 0px;
}

View File

@@ -0,0 +1,7 @@
$.extend(cur_frm.cscript, {
onload: function() {
if(cur_frm.doc.__quotation_series) {
cur_frm.fields_dict.quotation_series.df.options = cur_frm.doc.__quotation_series;
}
}
});

View File

@@ -9,6 +9,9 @@ from webnotes.model.controller import DocListController
class ShoppingCartSetupError(webnotes.ValidationError): pass class ShoppingCartSetupError(webnotes.ValidationError): pass
class DocType(DocListController): class DocType(DocListController):
def onload(self):
self.doc.fields["__quotation_series"] = webnotes.get_doctype("Quotation").get_options("naming_series")
def validate(self): def validate(self):
if self.doc.enabled: if self.doc.enabled:
self.validate_price_lists() self.validate_price_lists()
@@ -17,6 +20,7 @@ class DocType(DocListController):
def on_update(self): def on_update(self):
webnotes.conn.set_default("shopping_cart_enabled", self.doc.fields.get("enabled") or 0) webnotes.conn.set_default("shopping_cart_enabled", self.doc.fields.get("enabled") or 0)
webnotes.conn.set_default("shopping_cart_quotation_series", self.doc.fields.get("quotation_series"))
def validate_overlapping_territories(self, parentfield, fieldname): def validate_overlapping_territories(self, parentfield, fieldname):
# for displaying message # for displaying message
@@ -91,16 +95,17 @@ class DocType(DocListController):
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()
if currency != company_currency] if currency != company_currency]
exists = webnotes.conn.sql_list("""select name from `tabCurrency Exchange` if expected_to_exist:
where name in (%s)""" % (", ".join(["%s"]*len(expected_to_exist)),), exists = webnotes.conn.sql_list("""select name from `tabCurrency Exchange`
tuple(expected_to_exist)) where name in (%s)""" % (", ".join(["%s"]*len(expected_to_exist)),),
tuple(expected_to_exist))
missing = list(set(expected_to_exist).difference(exists)) missing = list(set(expected_to_exist).difference(exists))
if missing: if missing:
msgprint(_("Missing Currency Exchange Rates for" + ": " + comma_and(missing)), msgprint(_("Missing Currency Exchange Rates for" + ": " + comma_and(missing)),
raise_exception=ShoppingCartSetupError) raise_exception=ShoppingCartSetupError)
def get_name_from_territory(self, territory, parentfield, fieldname): def get_name_from_territory(self, territory, parentfield, fieldname):
name = None name = None

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-10 18:42:29", "modified": "2013-07-15 17:33:05",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@@ -78,6 +78,13 @@
"options": "Customer Group", "options": "Customer Group",
"reqd": 1 "reqd": 1
}, },
{
"doctype": "DocField",
"fieldname": "quotation_series",
"fieldtype": "Select",
"label": "Quotation Series",
"reqd": 1
},
{ {
"doctype": "DocField", "doctype": "DocField",
"fieldname": "section_break_6", "fieldname": "section_break_6",

View File

@@ -58,6 +58,10 @@ def update_cart(item_code, qty, with_doclist=0):
qty = flt(qty) qty = flt(qty)
if qty == 0: if qty == 0:
quotation.set_doclist(quotation.doclist.get({"item_code": ["!=", item_code]})) quotation.set_doclist(quotation.doclist.get({"item_code": ["!=", item_code]}))
if not quotation.doclist.get({"parentfield": "quotation_details"}) and \
not quotation.doc.fields.get("__islocal"):
quotation.__delete = True
else: else:
quotation_items = quotation.doclist.get({"item_code": item_code}) quotation_items = quotation.doclist.get({"item_code": item_code})
if not quotation_items: if not quotation_items:
@@ -72,8 +76,12 @@ def update_cart(item_code, qty, with_doclist=0):
apply_cart_settings(quotation=quotation) apply_cart_settings(quotation=quotation)
quotation.ignore_permissions = True if hasattr(quotation, "__delete"):
quotation.save() webnotes.delete_doc("Quotation", quotation.doc.name, ignore_permissions=True)
quotation = _get_cart_quotation()
else:
quotation.ignore_permissions = True
quotation.save()
set_cart_count(quotation) set_cart_count(quotation)
@@ -191,7 +199,7 @@ def decorate_quotation_doclist(doclist):
for d in doclist: for d in doclist:
if d.item_code: if d.item_code:
d.fields.update(webnotes.conn.get_value("Item", d.item_code, d.fields.update(webnotes.conn.get_value("Item", d.item_code,
["website_image", "web_short_description", "page_name"], as_dict=True)) ["website_image", "description", "page_name"], as_dict=True))
d.formatted_rate = fmt_money(d.export_rate, currency=doclist[0].currency) d.formatted_rate = fmt_money(d.export_rate, currency=doclist[0].currency)
d.formatted_amount = fmt_money(d.export_amount, currency=doclist[0].currency) d.formatted_amount = fmt_money(d.export_amount, currency=doclist[0].currency)
elif d.charge_type: elif d.charge_type:
@@ -215,7 +223,7 @@ def _get_cart_quotation(party=None):
else: else:
qbean = webnotes.bean({ qbean = webnotes.bean({
"doctype": "Quotation", "doctype": "Quotation",
"naming_series": "QTN-CART-", "naming_series": webnotes.defaults.get_user_default("shopping_cart_quotation_series") or "QTN-CART-",
"quotation_to": party.doctype, "quotation_to": party.doctype,
"company": webnotes.defaults.get_user_default("company"), "company": webnotes.defaults.get_user_default("company"),
"order_type": "Shopping Cart", "order_type": "Shopping Cart",
@@ -224,7 +232,10 @@ def _get_cart_quotation(party=None):
(party.doctype.lower()): party.name (party.doctype.lower()): party.name
}) })
# map_contact_fields(qbean, party) if party.doctype == "Customer":
qbean.doc.contact_person = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user,
"customer": party.name})
qbean.run_method("set_contact_fields")
qbean.run_method("onload_post_render") qbean.run_method("onload_post_render")
apply_cart_settings(party, qbean) apply_cart_settings(party, qbean)
@@ -259,10 +270,11 @@ def update_party(fullname, company_name=None, mobile_no=None, phone=None):
party_bean.save() party_bean.save()
qbean = _get_cart_quotation(party) qbean = _get_cart_quotation(party)
qbean.doc.customer_name = company_name or fullname if not qbean.doc.fields.get("__islocal"):
qbean.run_method("set_contact_fields") qbean.doc.customer_name = company_name or fullname
qbean.ignore_permissions = True qbean.run_method("set_contact_fields")
qbean.save() qbean.ignore_permissions = True
qbean.save()
def apply_cart_settings(party=None, quotation=None): def apply_cart_settings(party=None, quotation=None):
if not party: if not party:
@@ -374,27 +386,26 @@ def get_address_territory(address_name):
return territory return territory
@webnotes.whitelist()
def checkout():
quotation = _get_cart_quotation()
quotation.ignore_permissions = True
quotation.submit()
from selling.doctype.quotation.quotation import make_sales_order
sales_order = webnotes.bean(make_sales_order(quotation.doc.name))
sales_order.ignore_permissions = True
sales_order.insert()
sales_order.submit()
return sales_order
import unittest import unittest
test_dependencies = ["Item", "Price List", "Contact"] test_dependencies = ["Item", "Price List", "Contact", "Shopping Cart Settings"]
class TestCart(unittest.TestCase): class TestCart(unittest.TestCase):
def tearDown(self):
return
cart_settings = webnotes.bean("Shopping Cart Settings")
cart_settings.ignore_permissions = True
cart_settings.doc.enabled = 0
cart_settings.save()
def enable_shopping_cart(self):
return
if not webnotes.conn.get_value("Shopping Cart Settings", None, "enabled"):
cart_settings = webnotes.bean("Shopping Cart Settings")
cart_settings.ignore_permissions = True
cart_settings.doc.enabled = 1
cart_settings.save()
def test_get_lead_or_customer(self): def test_get_lead_or_customer(self):
webnotes.session.user = "test@example.com" webnotes.session.user = "test@example.com"
party1 = get_lead_or_customer() party1 = get_lead_or_customer()
@@ -407,7 +418,9 @@ class TestCart(unittest.TestCase):
self.assertEquals(party.name, "_Test Customer") self.assertEquals(party.name, "_Test Customer")
def test_add_to_cart(self): def test_add_to_cart(self):
self.enable_shopping_cart()
webnotes.session.user = "test@example.com" webnotes.session.user = "test@example.com"
update_cart("_Test Item", 1) update_cart("_Test Item", 1)
quotation = _get_cart_quotation() quotation = _get_cart_quotation()
@@ -440,8 +453,9 @@ class TestCart(unittest.TestCase):
quotation_items = quotation.doclist.get({"parentfield": "quotation_details", "item_code": "_Test Item"}) quotation_items = quotation.doclist.get({"parentfield": "quotation_details", "item_code": "_Test Item"})
self.assertEquals(quotation_items, []) self.assertEquals(quotation_items, [])
def test_checkout(self): def test_place_order(self):
quotation = self.test_update_cart() quotation = self.test_update_cart()
sales_order = checkout() sales_order_name = place_order()
sales_order = webnotes.bean("Sales Order", sales_order_name)
self.assertEquals(sales_order.doclist.getone({"item_code": "_Test Item"}).prevdoc_docname, quotation.doc.name) self.assertEquals(sales_order.doclist.getone({"item_code": "_Test Item"}).prevdoc_docname, quotation.doc.name)

View File

@@ -7,4 +7,7 @@
font-size: 18px; font-size: 18px;
line-height: 200%; line-height: 200%;
} }
.item-stock {
margin-bottom: 10px !important;
}
</style> </style>

View File

@@ -32,8 +32,7 @@
<p class="help">Item Code: <span itemprop="productID">{{ name }}</span></p> <p class="help">Item Code: <span itemprop="productID">{{ name }}</span></p>
<h4>Product Description</h4> <h4>Product Description</h4>
<div itemprop="description"> <div itemprop="description">
{{ web_long_description or web_short_description or description or {{ web_long_description or description or "[No description given]" }}
"[No description given]" }}
</div> </div>
<div style="min-height: 100px; margin: 10px 0;"> <div style="min-height: 100px; margin: 10px 0;">
<div class="item-price-info" style="display: none;"> <div class="item-price-info" style="display: none;">

View File

@@ -143,7 +143,7 @@ $.extend(wn.cart, {
'<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/website/templates/html/product_missing_image.html" %}';
if(!doc.web_short_description) doc.web_short_description = doc.description; if(doc.description === doc.item_name) doc.description = "";
$(repl('<div class="row">\ $(repl('<div class="row">\
<div class="col col-lg-9 col-sm-9">\ <div class="col col-lg-9 col-sm-9">\
@@ -151,7 +151,7 @@ $.extend(wn.cart, {
<div class="col col-lg-3">%(image_html)s</div>\ <div class="col col-lg-3">%(image_html)s</div>\
<div class="col col-lg-9">\ <div class="col col-lg-9">\
<h4><a href="%(page_name)s">%(item_name)s</a></h4>\ <h4><a href="%(page_name)s">%(item_name)s</a></h4>\
<p>%(web_short_description)s</p>\ <p>%(description)s</p>\
</div>\ </div>\
</div>\ </div>\
</div>\ </div>\