From 8c3cfe076e17bf078003b31b7dcc8e5afd50809a Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 18 Sep 2012 13:56:47 +0530 Subject: [PATCH 1/5] get last purchase rate from item if not found from purchase order or receipt --- erpnext/buying/doctype/purchase_common/purchase_common.py | 5 +++++ public/js/all-app.js | 2 +- public/js/all-web.js | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.py b/erpnext/buying/doctype/purchase_common/purchase_common.py index b8424aba7f..a1a41ca424 100644 --- a/erpnext/buying/doctype/purchase_common/purchase_common.py +++ b/erpnext/buying/doctype/purchase_common/purchase_common.py @@ -265,6 +265,11 @@ class DocType(TransactionBase): else: # if no last purchase found, reset all values to 0 d.purchase_ref_rate = d.purchase_rate = d.import_ref_rate = d.import_rate = d.discount_rate = 0 + + item_last_purchase_rate = webnotes.conn.get_value("Item", + d.item_code, "last_purchase_rate") + if item_last_purchase_rate: + d.purchase_ref_rate = item_last_purchase_rate def get_last_purchase_details(self, item_code, doc_name): import webnotes diff --git a/public/js/all-app.js b/public/js/all-app.js index 5b25f348da..bb2b30b84c 100644 --- a/public/js/all-app.js +++ b/public/js/all-app.js @@ -2272,7 +2272,7 @@ me.dialog.clear();me.dialog.show();}}); */ wn.Application=Class.extend({init:function(){var me=this;if(window.app){wn.call({method:'startup',callback:function(r,rt){wn.provide('wn.boot');wn.boot=r;if(wn.boot.profile.name=='Guest'){window.location='index.html';return;} me.startup();}})}else{this.startup();}},startup:function(){this.load_bootinfo();this.make_page_container();this.make_nav_bar();this.set_favicon();$(document).trigger('startup');if(wn.boot){wn.route();} -$(document).trigger('app_ready');},load_bootinfo:function(){if(wn.boot){LocalDB.sync(wn.boot.docs);wn.control_panel=wn.boot.control_panel;this.set_globals();if(wn.boot.developer_mode){(console.warn||console.log)("LocalStorage is OFF for developer mode. Please build before going live.");}}else{this.set_as_guest();}},set_globals:function(){profile=wn.boot.profile;user=wn.boot.profile.name;user_fullname=wn.user_info(user).fullname;user_defaults=profile.defaults;user_roles=profile.roles;user_email=profile.email;sys_defaults=wn.boot.sysdefaults;},set_as_guest:function(){profile={name:'Guest'};user='Guest';user_fullname='Guest';user_defaults={};user_roles=['Guest'];user_email='';sys_defaults={};},make_page_container:function(){wn.container=new wn.views.Container();wn.views.make_403();wn.views.make_404();},make_nav_bar:function(){if(wn.boot){wn.container.wntoolbar=new wn.ui.toolbar.Toolbar();}},logout:function(){var me=this;me.logged_out=true;wn.call({method:'logout',callback:function(r){if(r.exc){console.log(r.exc);} +$(document).trigger('app_ready');},load_bootinfo:function(){if(wn.boot){LocalDB.sync(wn.boot.docs);wn.control_panel=wn.boot.control_panel;this.set_globals();if(wn.boot.developer_mode){console.log("LocalStorage is OFF for developer mode. Please build before going live.");}}else{this.set_as_guest();}},set_globals:function(){profile=wn.boot.profile;user=wn.boot.profile.name;user_fullname=wn.user_info(user).fullname;user_defaults=profile.defaults;user_roles=profile.roles;user_email=profile.email;sys_defaults=wn.boot.sysdefaults;},set_as_guest:function(){profile={name:'Guest'};user='Guest';user_fullname='Guest';user_defaults={};user_roles=['Guest'];user_email='';sys_defaults={};},make_page_container:function(){wn.container=new wn.views.Container();wn.views.make_403();wn.views.make_404();},make_nav_bar:function(){if(wn.boot){wn.container.wntoolbar=new wn.ui.toolbar.Toolbar();}},logout:function(){var me=this;me.logged_out=true;wn.call({method:'logout',callback:function(r){if(r.exc){console.log(r.exc);} me.redirect_to_login();}})},redirect_to_login:function(){window.location.href='index.html';},set_favicon:function(){var link=$('link[type="image/x-icon"]').remove().attr("href");var favicon='\ \ ' diff --git a/public/js/all-web.js b/public/js/all-web.js index cb25654e02..81aaaaa220 100644 --- a/public/js/all-web.js +++ b/public/js/all-web.js @@ -699,7 +699,7 @@ if(errfld.length)msgprint('Mandatory fields required in '+ */ wn.Application=Class.extend({init:function(){var me=this;if(window.app){wn.call({method:'startup',callback:function(r,rt){wn.provide('wn.boot');wn.boot=r;if(wn.boot.profile.name=='Guest'){window.location='index.html';return;} me.startup();}})}else{this.startup();}},startup:function(){this.load_bootinfo();this.make_page_container();this.make_nav_bar();this.set_favicon();$(document).trigger('startup');if(wn.boot){wn.route();} -$(document).trigger('app_ready');},load_bootinfo:function(){if(wn.boot){LocalDB.sync(wn.boot.docs);wn.control_panel=wn.boot.control_panel;this.set_globals();if(wn.boot.developer_mode){(console.warn||console.log)("LocalStorage is OFF for developer mode. Please build before going live.");}}else{this.set_as_guest();}},set_globals:function(){profile=wn.boot.profile;user=wn.boot.profile.name;user_fullname=wn.user_info(user).fullname;user_defaults=profile.defaults;user_roles=profile.roles;user_email=profile.email;sys_defaults=wn.boot.sysdefaults;},set_as_guest:function(){profile={name:'Guest'};user='Guest';user_fullname='Guest';user_defaults={};user_roles=['Guest'];user_email='';sys_defaults={};},make_page_container:function(){wn.container=new wn.views.Container();wn.views.make_403();wn.views.make_404();},make_nav_bar:function(){if(wn.boot){wn.container.wntoolbar=new wn.ui.toolbar.Toolbar();}},logout:function(){var me=this;me.logged_out=true;wn.call({method:'logout',callback:function(r){if(r.exc){console.log(r.exc);} +$(document).trigger('app_ready');},load_bootinfo:function(){if(wn.boot){LocalDB.sync(wn.boot.docs);wn.control_panel=wn.boot.control_panel;this.set_globals();if(wn.boot.developer_mode){console.log("LocalStorage is OFF for developer mode. Please build before going live.");}}else{this.set_as_guest();}},set_globals:function(){profile=wn.boot.profile;user=wn.boot.profile.name;user_fullname=wn.user_info(user).fullname;user_defaults=profile.defaults;user_roles=profile.roles;user_email=profile.email;sys_defaults=wn.boot.sysdefaults;},set_as_guest:function(){profile={name:'Guest'};user='Guest';user_fullname='Guest';user_defaults={};user_roles=['Guest'];user_email='';sys_defaults={};},make_page_container:function(){wn.container=new wn.views.Container();wn.views.make_403();wn.views.make_404();},make_nav_bar:function(){if(wn.boot){wn.container.wntoolbar=new wn.ui.toolbar.Toolbar();}},logout:function(){var me=this;me.logged_out=true;wn.call({method:'logout',callback:function(r){if(r.exc){console.log(r.exc);} me.redirect_to_login();}})},redirect_to_login:function(){window.location.href='index.html';},set_favicon:function(){var link=$('link[type="image/x-icon"]').remove().attr("href");var favicon='\ \ ' From 05f1d4560064fc051068cf2eacf6dc000cf2ddcb Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 18 Sep 2012 14:04:22 +0530 Subject: [PATCH 2/5] removed unicode literals from patch list --- erpnext/patches/patch_list.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py index f07f20bdb0..5a38c5b1bf 100644 --- a/erpnext/patches/patch_list.py +++ b/erpnext/patches/patch_list.py @@ -511,11 +511,6 @@ patch_list = [ 'patch_file': 'deprecate_bulk_rename', 'description': "Remove Bulk Rename Tool" }, - { - 'patch_module': 'patches.july_2012', - 'patch_file': 'unicode_conf', - 'description': "appends from __future__ import unicode_literals to py files if necessary" - }, { 'patch_module': 'patches.july_2012', 'patch_file': 'sync_trial_balance', From 56bac90081de6485f9cab599a26cf958114d4a7f Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 18 Sep 2012 16:07:22 +0530 Subject: [PATCH 3/5] bug fix in doclistview --- public/js/all-app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/js/all-app.js b/public/js/all-app.js index bb2b30b84c..c7f494ff76 100644 --- a/public/js/all-app.js +++ b/public/js/all-app.js @@ -1011,7 +1011,7 @@ else if(opts.type=='link'&&opts.doctype){$(parent).append(repl(' %(content)s',{"title":opts.title||opts.content,"content":data[opts.content]}));}},render:function(row,data){var me=this;this.prepare_data(data);rowhtml='';$.each(this.columns,function(i,v){rowhtml+=repl('',v);});var tr=$(row).html(''+rowhtml+'
').find('tr').get(0);$.each(this.columns,function(i,v){me.render_column(data,tr.cells[i],v);});},prepare_data:function(data){data.fullname=wn.user_info(data.owner).fullname;data.avatar=wn.user_info(data.owner).image;this.prepare_when(data,data.modified);if(data.docstatus==0||data.docstatus==null){data.docstatus_icon='icon-pencil';data.docstatus_title='Editable';}else if(data.docstatus==1){data.docstatus_icon='icon-lock';data.docstatus_title='Submitted';}else if(data.docstatus==2){data.docstatus_icon='icon-remove';data.docstatus_title='Cancelled';} -for(key in data){if(data[key]==null){data[key]='';}}},prepare_when:function(data,date_str){if(!date_str)date_str=data.modified;data.when=dateutil.str_to_user(date_str).split(' ')[0];var diff=dateutil.get_diff(dateutil.get_today(),date_str.split(' ')[0]);if(diff==0){data.when=dateutil.comment_when(date_str);} +for(key in data){if(data[key]==null){data[key]='';}}},prepare_when:function(data,date_str){if(!date_str)date_str=data.modified;data.when=(dateutil.str_to_user(date_str)).split(' ')[0];var diff=dateutil.get_diff(dateutil.get_today(),date_str.split(' ')[0]);if(diff==0){data.when=dateutil.comment_when(date_str);} if(diff==1){data.when='Yesterday'} if(diff==2){data.when='2 days ago'}},add_user_tags:function(parent,data){var me=this;if(data._user_tags){if($(parent).html().length>0){$(parent).append('
');} $.each(data._user_tags.split(','),function(i,t){if(t){$('' From 081be012dce2a29e0d69606b0713895f4ecdcce5 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 18 Sep 2012 16:25:56 +0530 Subject: [PATCH 4/5] fix in doclistview new button permissios --- public/js/all-app.js | 5 +++-- public/js/all-web.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/public/js/all-app.js b/public/js/all-app.js index c7f494ff76..89ce7c3d42 100644 --- a/public/js/all-app.js +++ b/public/js/all-app.js @@ -255,7 +255,7 @@ return;wn.route();}); /* * lib/js/wn/ui/listing.js */ -wn.provide('wn.ui');wn.ui.Listing=Class.extend({init:function(opts){this.opts=opts||{};this.page_length=20;this.start=0;this.data=[];if(opts){this.make();}},prepare_opts:function(){if(this.opts.new_doctype){if(wn.boot.profile.can_read.indexOf(this.opts.new_doctype)==-1){this.opts.new_doctype=null;}else{this.opts.new_doctype=get_doctype_label(this.opts.new_doctype);}} +wn.provide('wn.ui');wn.ui.Listing=Class.extend({init:function(opts){this.opts=opts||{};this.page_length=20;this.start=0;this.data=[];if(opts){this.make();}},prepare_opts:function(){if(this.opts.new_doctype){if(wn.boot.profile.can_create.indexOf(this.opts.new_doctype)==-1){this.opts.new_doctype=null;}else{this.opts.new_doctype=get_doctype_label(this.opts.new_doctype);}} if(!this.opts.no_result_message){this.opts.no_result_message='Nothing to show'}},make:function(opts){if(opts){this.opts=opts;} this.prepare_opts();$.extend(this,this.opts);$(this.parent).html(repl('\
\ @@ -1010,7 +1010,8 @@ else if(opts.type=='link'&&opts.doctype){$(parent).append(repl(''+data[opts.content]+'',data));} else if(opts.template){$(parent).append(repl(opts.template,data));} else if(data[opts.content]){if(opts.type=="date"){data[opts.content]=wn.datetime.str_to_user(data[opts.content])} -$(parent).append(repl(' %(content)s',{"title":opts.title||opts.content,"content":data[opts.content]}));}},render:function(row,data){var me=this;this.prepare_data(data);rowhtml='';$.each(this.columns,function(i,v){rowhtml+=repl('',v);});var tr=$(row).html(''+rowhtml+'
').find('tr').get(0);$.each(this.columns,function(i,v){me.render_column(data,tr.cells[i],v);});},prepare_data:function(data){data.fullname=wn.user_info(data.owner).fullname;data.avatar=wn.user_info(data.owner).image;this.prepare_when(data,data.modified);if(data.docstatus==0||data.docstatus==null){data.docstatus_icon='icon-pencil';data.docstatus_title='Editable';}else if(data.docstatus==1){data.docstatus_icon='icon-lock';data.docstatus_title='Submitted';}else if(data.docstatus==2){data.docstatus_icon='icon-remove';data.docstatus_title='Cancelled';} +$(parent).append(repl(' %(content)s',{"title":opts.title||opts.content,"content":data[opts.content]}));}},render:function(row,data){var me=this;this.prepare_data(data);rowhtml='';$.each(this.columns,function(i,v){rowhtml+=repl('',v);});var tr=$(row).html(''+rowhtml+'
').find('tr').get(0);$.each(this.columns,function(i,v){me.render_column(data,tr.cells[i],v);});},prepare_data:function(data){data.fullname=wn.user_info(data.owner).fullname;data.avatar=wn.user_info(data.owner).image;if(data.modified) +this.prepare_when(data,data.modified);if(data.docstatus==0||data.docstatus==null){data.docstatus_icon='icon-pencil';data.docstatus_title='Editable';}else if(data.docstatus==1){data.docstatus_icon='icon-lock';data.docstatus_title='Submitted';}else if(data.docstatus==2){data.docstatus_icon='icon-remove';data.docstatus_title='Cancelled';} for(key in data){if(data[key]==null){data[key]='';}}},prepare_when:function(data,date_str){if(!date_str)date_str=data.modified;data.when=(dateutil.str_to_user(date_str)).split(' ')[0];var diff=dateutil.get_diff(dateutil.get_today(),date_str.split(' ')[0]);if(diff==0){data.when=dateutil.comment_when(date_str);} if(diff==1){data.when='Yesterday'} if(diff==2){data.when='2 days ago'}},add_user_tags:function(parent,data){var me=this;if(data._user_tags){if($(parent).html().length>0){$(parent).append('
');} diff --git a/public/js/all-web.js b/public/js/all-web.js index 81aaaaa220..535762fef3 100644 --- a/public/js/all-web.js +++ b/public/js/all-web.js @@ -142,7 +142,7 @@ return;wn.route();}); /* * lib/js/wn/ui/listing.js */ -wn.provide('wn.ui');wn.ui.Listing=Class.extend({init:function(opts){this.opts=opts||{};this.page_length=20;this.start=0;this.data=[];if(opts){this.make();}},prepare_opts:function(){if(this.opts.new_doctype){if(wn.boot.profile.can_read.indexOf(this.opts.new_doctype)==-1){this.opts.new_doctype=null;}else{this.opts.new_doctype=get_doctype_label(this.opts.new_doctype);}} +wn.provide('wn.ui');wn.ui.Listing=Class.extend({init:function(opts){this.opts=opts||{};this.page_length=20;this.start=0;this.data=[];if(opts){this.make();}},prepare_opts:function(){if(this.opts.new_doctype){if(wn.boot.profile.can_create.indexOf(this.opts.new_doctype)==-1){this.opts.new_doctype=null;}else{this.opts.new_doctype=get_doctype_label(this.opts.new_doctype);}} if(!this.opts.no_result_message){this.opts.no_result_message='Nothing to show'}},make:function(opts){if(opts){this.opts=opts;} this.prepare_opts();$.extend(this,this.opts);$(this.parent).html(repl('\
\ From 06f4c1a55f13a5655b3e96175274df2e98c10dad Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 19 Sep 2012 11:29:32 +0530 Subject: [PATCH 5/5] if last purchase not found, take last purchase rate from item --- erpnext/buying/doctype/purchase_common/purchase_common.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.py b/erpnext/buying/doctype/purchase_common/purchase_common.py index a1a41ca424..4c307e67a9 100644 --- a/erpnext/buying/doctype/purchase_common/purchase_common.py +++ b/erpnext/buying/doctype/purchase_common/purchase_common.py @@ -269,7 +269,8 @@ class DocType(TransactionBase): item_last_purchase_rate = webnotes.conn.get_value("Item", d.item_code, "last_purchase_rate") if item_last_purchase_rate: - d.purchase_ref_rate = item_last_purchase_rate + d.purchase_ref_rate = d.purchase_rate = d.import_ref_rate \ + = d.import_rate = item_last_purchase_rate def get_last_purchase_details(self, item_code, doc_name): import webnotes