Merge branch 'master' of github.com:webnotes/erpnext

This commit is contained in:
Rushabh Mehta 2012-11-30 12:32:50 +01:00
commit f9d4927303
167 changed files with 3613 additions and 5075 deletions

View File

@ -14,19 +14,15 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import flt, fmt_money
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.wrapper import copy_doclist
from webnotes import msgprint
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
class DocType:
def __init__(self,d,dl):
@ -49,11 +45,6 @@ class DocType:
msgprint("Message: Please enter Master Name once the account is created.")
# Rate is mandatory for tax account
def validate_rate_for_tax(self):
if self.doc.account_type == 'Tax' and not self.doc.tax_rate:
msgprint("Please Enter Rate", raise_exception=1)
# Fetch Parent Details and validation for account not to be created under ledger
def validate_parent(self):
if self.doc.parent_account:
@ -135,7 +126,6 @@ class DocType:
def validate(self):
self.validate_master_name()
self.validate_rate_for_tax()
self.validate_parent()
self.validate_duplicate_account()
self.validate_root_details()

View File

@ -14,24 +14,17 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import cstr, flt, getdate, now, nowdate
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.doc import addchild
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes import msgprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:

View File

@ -14,24 +14,17 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import cstr, flt, getdate
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.wrapper import copy_doclist
from webnotes.model.code import get_obj
from webnotes import msgprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:

View File

@ -14,17 +14,14 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, cint, cstr, date_diff, default_fields, flt, getdate, now, nowdate
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.utils import flt, getdate
from webnotes.model.doc import make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj
from webnotes import msgprint, errprint
from webnotes import msgprint
sql = webnotes.conn.sql
# -----------------------------------------------------------------------------------------
class DocType:

View File

@ -14,24 +14,18 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import cstr, flt, now
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.doc import addchild, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.code import get_obj
from webnotes import form, msgprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
from utilities.transaction_base import TransactionBase
class DocType(TransactionBase):

View File

@ -14,22 +14,18 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import cstr, flt, get_defaults, now, sendmail
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist, clone
from webnotes.model.doc import Document, addchild
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj
from webnotes import session, form, msgprint, errprint
from webnotes import msgprint
from webnotes.utils.email_lib import sendmail
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
from utilities.transaction_base import TransactionBase
class DocType:
@ -192,7 +188,7 @@ class DocType:
# check total debit / credit
# Due to old wrong entries (total debit != total credit) some voucher could be cancelled
if abs(self.td - self.tc) > 0.01 and not cancel:
if abs(self.td - self.tc) > 0.004 and not cancel:
msgprint("Debit and Credit not equal for this voucher: Diff (Debit) is %s" % (self.td-self.tc))
raise Exception
@ -397,194 +393,3 @@ class DocType:
fy_obj = get_obj('Fiscal Year', fy[0])
for a in set(ac_list):
fy_obj.repost(a)
def manage_recurring_invoices():
"""
Create recurring invoices on specific date by copying the original one
and notify the concerned people
"""
rv = webnotes.conn.sql("""select name, recurring_id from `tabSales Invoice` \
where ifnull(convert_into_recurring_invoice, 0) = 1 and next_date = %s \
and next_date <= ifnull(end_date, '2199-12-31') and docstatus=1""", nowdate())
exception_list = []
for d in rv:
if not webnotes.conn.sql("""select name from `tabSales Invoice` \
where posting_date = %s and recurring_id = %s and docstatus=1""", (nowdate(), d[1])):
try:
prev_rv = get_obj('Sales Invoice', d[0], with_children=1)
new_rv = create_new_invoice(prev_rv)
send_notification(new_rv)
webnotes.conn.commit()
except Exception, e:
webnotes.conn.rollback()
webnotes.conn.begin()
webnotes.conn.sql("update `tabSales Invoice` set \
convert_into_recurring_invoice = 0 where name = %s", d[0])
notify_errors(d[0], prev_rv.doc.owner)
webnotes.conn.commit()
exception_list.append(e)
finally:
webnotes.conn.begin()
if exception_list:
exception_message = "\n\n".join([cstr(d) for d in exception_list])
raise Exception, exception_message
def notify_errors(inv, owner):
import webnotes
import website
exception_msg = """
Dear User,
An error occured while creating recurring invoice from %s (at %s).
May be there are some invalid email ids mentioned in the invoice.
To stop sending repetitive error notifications from the system, we have unchecked
"Convert into Recurring" field in the invoice %s.
Please correct the invoice and make the invoice recurring again.
<b>It is necessary to take this action today itself for the above mentioned recurring invoice \
to be generated. If delayed, you will have to manually change the "Repeat on Day of Month" field \
of this invoice for generating the recurring invoice.</b>
Regards,
Administrator
""" % (inv, website.get_site_address(), inv)
subj = "[Urgent] Error while creating recurring invoice from %s" % inv
from webnotes.profile import get_system_managers
recipients = get_system_managers()
owner_email = webnotes.conn.get_value("Profile", owner, "email")
if not owner_email in recipients:
recipients.append(owner_email)
assign_task_to_owner(inv, exception_msg, recipients)
sendmail(recipients, subject=subj, msg = exception_msg)
def assign_task_to_owner(inv, msg, users):
for d in users:
if d.lower() == 'administrator':
d = webnotes.conn.sql("select ifnull(email_id, '') \
from `tabProfile` where name = 'Administrator'")[0][0]
from webnotes.widgets.form import assign_to
args = {
'assign_to' : d,
'doctype' : 'Sales Invoice',
'name' : inv,
'description' : msg,
'priority' : 'Urgent'
}
assign_to.add(args)
def create_new_invoice(prev_rv):
# clone rv
new_rv = clone(prev_rv)
mdict = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, 'Yearly': 12}
mcount = mdict[prev_rv.doc.recurring_type]
# update new rv
new_rv.doc.posting_date = new_rv.doc.next_date
new_rv.doc.aging_date = new_rv.doc.next_date
new_rv.doc.due_date = add_days(new_rv.doc.next_date, cint(date_diff(prev_rv.doc.due_date, prev_rv.doc.posting_date)))
new_rv.doc.invoice_period_from_date = get_next_date(new_rv.doc.invoice_period_from_date, mcount)
new_rv.doc.invoice_period_to_date = get_next_date(new_rv.doc.invoice_period_to_date, mcount)
new_rv.doc.owner = prev_rv.doc.owner
new_rv.doc.save()
# submit and after submit
new_rv.submit()
new_rv.update_after_submit()
return new_rv
def get_next_date(dt, mcount):
import datetime
m = getdate(dt).month + mcount
y = getdate(dt).year
d = getdate(dt).day
if m > 12:
m, y = m-12, y+1
try:
next_month_date = datetime.date(y, m, d)
except:
import calendar
last_day = calendar.monthrange(y, m)[1]
next_month_date = datetime.date(y, m, last_day)
return next_month_date.strftime("%Y-%m-%d")
def send_notification(new_rv):
"""Notify concerned persons about recurring invoice generation"""
subject = "Invoice : " + new_rv.doc.name
com = new_rv.doc.company # webnotes.conn.get_value('Control Panel', '', 'letter_head')
hd = '''<div><h2>%s</h2></div>
<div><h3>Invoice: %s</h3></div>
<table cellspacing= "5" cellpadding="5" width = "100%%">
<tr>
<td width = "50%%"><b>Customer</b><br>%s<br>%s</td>
<td width = "50%%">Invoice Date : %s<br>Invoice Period : %s to %s <br>Due Date : %s</td>
</tr>
</table>
''' % (com, new_rv.doc.name, new_rv.doc.customer_name, new_rv.doc.address_display, getdate(new_rv.doc.posting_date).strftime("%d-%m-%Y"), \
getdate(new_rv.doc.invoice_period_from_date).strftime("%d-%m-%Y"), getdate(new_rv.doc.invoice_period_to_date).strftime("%d-%m-%Y"),\
getdate(new_rv.doc.due_date).strftime("%d-%m-%Y"))
tbl = '''<table border="1px solid #CCC" width="100%%" cellpadding="0px" cellspacing="0px">
<tr>
<td width = "15%%" bgcolor="#CCC" align="left"><b>Item</b></td>
<td width = "40%%" bgcolor="#CCC" align="left"><b>Description</b></td>
<td width = "15%%" bgcolor="#CCC" align="center"><b>Qty</b></td>
<td width = "15%%" bgcolor="#CCC" align="center"><b>Rate</b></td>
<td width = "15%%" bgcolor="#CCC" align="center"><b>Amount</b></td>
</tr>
'''
for d in getlist(new_rv.doclist, 'entries'):
tbl += '<tr><td>' + d.item_code +'</td><td>' + d.description+'</td><td>' + cstr(d.qty) +'</td><td>' + cstr(d.basic_rate) +'</td><td>' + cstr(d.amount) +'</td></tr>'
tbl += '</table>'
totals =''' <table cellspacing= "5" cellpadding="5" width = "100%%">
<tr>
<td width = "50%%"></td>
<td width = "50%%">
<table width = "100%%">
<tr>
<td width = "50%%">Net Total: </td><td>%s </td>
</tr><tr>
<td width = "50%%">Total Tax: </td><td>%s </td>
</tr><tr>
<td width = "50%%">Grand Total: </td><td>%s</td>
</tr><tr>
<td width = "50%%">In Words: </td><td>%s</td>
</tr>
</table>
</td>
</tr>
<tr><td>Terms and Conditions:</td></tr>
<tr><td>%s</td></tr>
</table>
''' % (new_rv.doc.net_total, new_rv.doc.other_charges_total,new_rv.doc.grand_total, new_rv.doc.in_words,new_rv.doc.terms)
msg = hd + tbl + totals
recipients = new_rv.doc.notification_email_address.replace('\n', '').replace(' ', '').split(",")
sendmail(recipients, subject=subject, msg = msg)

View File

@ -14,24 +14,17 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import flt, fmt_money, get_first_day, get_last_day, getdate
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.wrapper import copy_doclist
from webnotes.model.code import get_obj
from webnotes import msgprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:

View File

@ -14,24 +14,18 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cint, cstr, flt, fmt_money, formatdate, getTraceback, get_defaults, getdate, has_common, month_name, now, nowdate, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import cint, cstr, flt, fmt_money, formatdate, getdate
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.doc import addchild, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.code import get_obj
from webnotes import form, msgprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
from utilities.transaction_base import TransactionBase
class DocType:

View File

@ -14,7 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import unittest

View File

@ -14,22 +14,15 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import cint, cstr, flt, get_defaults, get_first_day, get_last_day, has_common
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.wrapper import copy_doclist
from webnotes import session, msgprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
from accounts.utils import get_balance_on, get_fiscal_year

View File

@ -14,24 +14,18 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import flt
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.doc import addchild
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.code import get_obj
from webnotes import msgprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:

View File

@ -14,24 +14,18 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import cstr, flt, getdate
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.doc import Document
from webnotes.model.wrapper import copy_doclist
from webnotes.model.code import get_obj
from webnotes import msgprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:

View File

@ -14,24 +14,15 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.wrapper import copy_doclist
from webnotes import msgprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:

View File

@ -14,24 +14,18 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import add_days, cint, cstr, flt, formatdate, get_defaults
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.doc import Document, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.code import get_obj
from webnotes import form, msgprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
from utilities.transaction_base import TransactionBase

View File

@ -14,24 +14,15 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.wrapper import copy_doclist
from webnotes.model.code import get_obj
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:

View File

@ -25,7 +25,6 @@ cur_frm.pformat.print_heading = 'Invoice';
wn.require('app/selling/doctype/sales_common/sales_common.js');
wn.require('app/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js');
wn.require('app/utilities/doctype/sms_control/sms_control.js');
wn.require('app/setup/doctype/notification_control/notification_control.js');
// On Load
// -------
@ -94,8 +93,6 @@ cur_frm.cscript.hide_fields = function(doc, cdt, cdn) {
for(f in item_flds_normal) cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_normal[f], true);
for(f in item_flds_pos) cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_pos[f], false);
}
if (doc.docstatus==1) unhide_field('recurring_invoice');
else hide_field('recurring_invoice');
if(doc.customer) unhide_field('contact_section');
else hide_field('contact_section');
@ -499,25 +496,34 @@ cur_frm.cscript.view_ledger_entry = function(){
wn.set_route('Report', 'GL Entry', 'General Ledger', 'Voucher No='+cur_frm.doc.name);
}
// Default values for recurring invoices
cur_frm.cscript.convert_into_recurring_invoice = function(doc, dt, dn) {
if (doc.convert_into_recurring_invoice)
get_server_fields('set_default_recurring_values','','',doc, dt, dn, 0);
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
if(cint(wn.boot.notification_settings.sales_invoice)) {
cur_frm.email_doc(wn.boot.notification_settings.sales_invoice);
}
}
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
var args = {
type: 'Sales Invoice',
doctype: 'Sales Invoice'
cur_frm.cscript.convert_into_recurring_invoice = function(doc, dt, dn) {
// set default values for recurring invoices
if(doc.convert_into_recurring_invoice) {
var owner_email = doc.owner=="Administrator"
? wn.user_info("Administrator").email
: doc.owner;
doc.notification_email_address = $.map([cstr(owner_email),
cstr(doc.contact_email)], function(v) { return v || null; }).join(", ");
doc.repeat_on_day_of_month = wn.datetime.str_to_obj(doc.posting_date).getDate();
}
cur_frm.cscript.notify(doc, args);
refresh_many(["notification_email_address", "repeat_on_day_of_month"]);
}
cur_frm.cscript.invoice_period_from_date = function(doc, dt, dn) {
// set invoice_period_to_date
if(doc.invoice_period_from_date) {
var recurring_type_map = { 'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, 'Yearly': 12 };
var recurring_type_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6,
'Yearly': 12};
var months = $(recurring_type_map).attr(doc.recurring_type);
var months = recurring_type_map[doc.recurring_type];
if(months) {
var to_date = wn.datetime.add_months(doc.invoice_period_from_date,
months);
@ -525,4 +531,4 @@ cur_frm.cscript.invoice_period_from_date = function(doc, dt, dn) {
refresh_field('invoice_period_to_date');
}
}
}
}

View File

@ -14,22 +14,23 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr,date_diff, default_fields, flt, fmt_money, formatdate,getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common,month_name, now, nowdate, replace_newlines, sendmail, set_default,str_esc_quote, user_format, validate_email_add
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.utils import add_days, cint, cstr, date_diff, flt, getTraceback, getdate, now, nowdate, sendmail, validate_email_add
from webnotes.utils import comma_and
from webnotes import _
from webnotes.model import db_exists
from webnotes.model.doc import make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj
from webnotes import session, form, msgprint
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
session = webnotes.session
# -----------------------------------------------------------------------------------------
month_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, 'Yearly': 12}
from utilities.transaction_base import TransactionBase
@ -40,10 +41,92 @@ class DocType(TransactionBase):
self.tname = 'Sales Invoice Item'
self.fname = 'entries'
def autoname(self):
self.doc.name = make_autoname(self.doc.naming_series+ '.#####')
def validate(self):
self.so_dn_required()
self.validate_proj_cust()
sales_com_obj = get_obj('Sales Common')
sales_com_obj.check_stop_sales_order(self)
sales_com_obj.check_active_sales_items(self)
sales_com_obj.check_conversion_rate(self)
sales_com_obj.validate_max_discount(self, 'entries') #verify whether rate is not greater than tolerance
sales_com_obj.get_allocated_sum(self) # this is to verify that the allocated % of sales persons is 100%
sales_com_obj.validate_fiscal_year(self.doc.fiscal_year,self.doc.posting_date,'Posting Date')
self.validate_customer()
self.validate_customer_account()
self.validate_debit_acc()
self.validate_fixed_asset_account()
self.add_remarks()
if cint(self.doc.is_pos):
self.validate_pos()
self.validate_write_off_account()
if cint(self.doc.update_stock):
sl = get_obj('Stock Ledger')
sl.validate_serial_no(self, 'entries')
sl.validate_serial_no(self, 'packing_details')
self.validate_item_code()
self.update_current_stock()
self.validate_delivery_note()
self.set_in_words()
if not self.doc.is_opening:
self.doc.is_opening = 'No'
self.set_aging_date()
self.clear_advances()
self.set_against_income_account()
self.validate_c_form()
self.validate_recurring_invoice()
def on_submit(self):
if cint(self.doc.is_pos) == 1:
if cint(self.doc.update_stock) == 1:
sl_obj = get_obj("Stock Ledger")
sl_obj.validate_serial_no_warehouse(self, 'entries')
sl_obj.validate_serial_no_warehouse(self, 'packing_details')
sl_obj.update_serial_record(self, 'entries', is_submit = 1, is_incoming = 0)
sl_obj.update_serial_record(self, 'packing_details', is_submit = 1, is_incoming = 0)
self.update_stock_ledger(update_stock=1)
else:
# Check for Approving Authority
if not self.doc.recurring_id:
get_obj('Authorization Control').validate_approving_authority(self.doc.doctype, self.doc.company, self.doc.grand_total, self)
self.check_prev_docstatus()
get_obj("Sales Common").update_prevdoc_detail(1,self)
# this sequence because outstanding may get -ve
self.make_gl_entries()
if not cint(self.doc.is_pos) == 1:
self.update_against_document_in_jv()
self.update_c_form()
self.convert_to_recurring()
def on_cancel(self):
if cint(self.doc.is_pos) == 1:
if cint(self.doc.update_stock) == 1:
sl = get_obj('Stock Ledger')
sl.update_serial_record(self, 'entries', is_submit = 0, is_incoming = 0)
sl.update_serial_record(self, 'packing_details', is_submit = 0, is_incoming = 0)
self.update_stock_ledger(update_stock = -1)
sales_com_obj = get_obj(dt = 'Sales Common')
sales_com_obj.check_stop_sales_order(self)
self.check_next_docstatus()
sales_com_obj.update_prevdoc_detail(0, self)
self.make_gl_entries(is_cancel=1)
def on_update_after_submit(self):
self.validate_recurring_invoice()
self.convert_to_recurring()
def set_pos_fields(self):
"""Set retail related fields from pos settings"""
@ -428,40 +511,6 @@ class DocType(TransactionBase):
d.projected_qty = bin and flt(bin[0]['projected_qty']) or 0
def validate(self):
self.so_dn_required()
self.validate_proj_cust()
sales_com_obj = get_obj('Sales Common')
sales_com_obj.check_stop_sales_order(self)
sales_com_obj.check_active_sales_items(self)
sales_com_obj.check_conversion_rate(self)
sales_com_obj.validate_max_discount(self, 'entries') #verify whether rate is not greater than tolerance
sales_com_obj.get_allocated_sum(self) # this is to verify that the allocated % of sales persons is 100%
sales_com_obj.validate_fiscal_year(self.doc.fiscal_year,self.doc.posting_date,'Posting Date')
self.validate_customer()
self.validate_customer_account()
self.validate_debit_acc()
self.validate_fixed_asset_account()
self.add_remarks()
if cint(self.doc.is_pos):
self.validate_pos()
self.validate_write_off_account()
if cint(self.doc.update_stock):
sl = get_obj('Stock Ledger')
sl.validate_serial_no(self, 'entries')
sl.validate_serial_no(self, 'packing_details')
self.validate_item_code()
self.update_current_stock()
self.validate_delivery_note()
self.set_in_words()
if not self.doc.is_opening:
self.doc.is_opening = 'No'
self.set_aging_date()
self.clear_advances()
self.set_against_income_account()
self.validate_c_form()
def get_warehouse(self):
w = webnotes.conn.sql("select warehouse from `tabPOS Setting` where ifnull(user,'') = '%s' and company = '%s'" % (session['user'], self.doc.company))
w = w and w[0][0] or ''
@ -598,114 +647,255 @@ class DocType(TransactionBase):
if submit_jv:
msgprint("Journal Voucher : " + cstr(submit_jv[0][0]) + " has been created against " + cstr(self.doc.doctype) + ". So " + cstr(self.doc.doctype) + " cannot be Cancelled.")
raise Exception, "Validation Error."
def on_submit(self):
if cint(self.doc.is_pos) == 1:
if cint(self.doc.update_stock) == 1:
sl_obj = get_obj("Stock Ledger")
sl_obj.validate_serial_no_warehouse(self, 'entries')
sl_obj.validate_serial_no_warehouse(self, 'packing_details')
sl_obj.update_serial_record(self, 'entries', is_submit = 1, is_incoming = 0)
sl_obj.update_serial_record(self, 'packing_details', is_submit = 1, is_incoming = 0)
self.update_stock_ledger(update_stock=1)
else:
# Check for Approving Authority
@property
def meta(self):
if not hasattr(self, "_meta"):
self._meta = webnotes.get_doctype(self.doc.doctype)
return self._meta
def validate_recurring_invoice(self):
if self.doc.convert_into_recurring_invoice:
self.validate_notification_email_id()
if not self.doc.recurring_type:
msgprint(_("Please select: ") + self.meta.get_label("recurring_type"),
raise_exception=1)
elif not (self.doc.invoice_period_from_date and \
self.doc.invoice_period_to_date):
msgprint(comma_and([self.meta.get_label("invoice_period_from_date"),
self.meta.get_label("invoice_period_to_date")])
+ _(": Mandatory for a Recurring Invoice."),
raise_exception=True)
def convert_to_recurring(self):
if self.doc.convert_into_recurring_invoice:
if not self.doc.recurring_id:
get_obj('Authorization Control').validate_approving_authority(self.doc.doctype, self.doc.company, self.doc.grand_total, self)
webnotes.conn.set(self.doc, "recurring_id",
make_autoname("RECINV/.#####"))
self.set_next_date()
self.check_prev_docstatus()
get_obj("Sales Common").update_prevdoc_detail(1,self)
# this sequence because outstanding may get -ve
self.make_gl_entries()
if not cint(self.doc.is_pos) == 1:
self.update_against_document_in_jv()
self.update_c_form()
def on_cancel(self):
if cint(self.doc.is_pos) == 1:
if cint(self.doc.update_stock) == 1:
sl = get_obj('Stock Ledger')
sl.update_serial_record(self, 'entries', is_submit = 0, is_incoming = 0)
sl.update_serial_record(self, 'packing_details', is_submit = 0, is_incoming = 0)
self.update_stock_ledger(update_stock = -1)
sales_com_obj = get_obj(dt = 'Sales Common')
sales_com_obj.check_stop_sales_order(self)
self.check_next_docstatus()
sales_com_obj.update_prevdoc_detail(0, self)
self.make_gl_entries(is_cancel=1)
def set_default_recurring_values(self):
from webnotes.utils import cstr
owner_email = self.doc.owner
if owner_email.lower() == 'administrator':
owner_email = cstr(webnotes.conn.get_value("Profile", "Administrator", "email"))
ret = {
'repeat_on_day_of_month' : getdate(self.doc.posting_date).day,
'notification_email_address' : ', '.join([owner_email, cstr(self.doc.contact_email)]),
}
return ret
elif self.doc.recurring_id:
webnotes.conn.sql("""update `tabSales Invoice`
set convert_into_recurring_invoice = 0
where recurring_id = %s""", (self.doc.recurring_id,))
def validate_notification_email_id(self):
if self.doc.notification_email_address:
email_list = filter(None, [cstr(email).strip() for email in
self.doc.notification_email_address.replace("\n", "").split(",")])
from webnotes.utils import validate_email_add
for add in self.doc.notification_email_address.replace('\n', '').replace(' ', '').split(","):
if add and not validate_email_add(add):
msgprint("%s is not a valid email address" % add, raise_exception=1)
for email in email_list:
if not validate_email_add(email):
msgprint(self.meta.get_label("notification_email_address") \
+ " - " + _("Invalid Email Address") + ": \"%s\"" % email,
raise_exception=1)
else:
msgprint("Notification Email Addresses not specified for recurring invoice",
raise_exception=1)
def on_update_after_submit(self):
self.convert_into_recurring()
def convert_into_recurring(self):
if self.doc.convert_into_recurring_invoice:
self.validate_notification_email_id()
if not self.doc.recurring_type:
msgprint("Please select recurring type", raise_exception=1)
elif not self.doc.invoice_period_from_date or not self.doc.invoice_period_to_date:
msgprint("Invoice period from date and to date is mandatory for recurring invoice", raise_exception=1)
self.set_next_date()
if not self.doc.recurring_id:
webnotes.conn.set(self.doc, 'recurring_id', make_autoname('RECINV/.#####'))
elif self.doc.recurring_id:
webnotes.conn.sql("""update `tabSales Invoice` set convert_into_recurring_invoice = 0 where recurring_id = %s""", self.doc.recurring_id)
def set_next_date(self):
""" Set next date on which auto invoice will be created"""
if not self.doc.repeat_on_day_of_month:
msgprint("""Please enter 'Repeat on Day of Month' field value. \nThe day of the month on which auto invoice
will be generated e.g. 05, 28 etc.""", raise_exception=1)
import datetime
mcount = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, 'Yearly': 12}
m = getdate(self.doc.posting_date).month + mcount[self.doc.recurring_type]
y = getdate(self.doc.posting_date).year
if m > 12:
m, y = m-12, y+1
try:
next_date = datetime.date(y, m, cint(self.doc.repeat_on_day_of_month))
except:
import calendar
last_day = calendar.monthrange(y, m)[1]
next_date = datetime.date(y, m, last_day)
next_date = next_date.strftime("%Y-%m-%d")
msgprint("""Please enter 'Repeat on Day of Month' field value.
The day of the month on which auto invoice
will be generated e.g. 05, 28 etc.""", raise_exception=1)
next_date = get_next_date(self.doc.posting_date,
month_map[self.doc.recurring_type], cint(self.doc.repeat_on_day_of_month))
webnotes.conn.set(self.doc, 'next_date', next_date)
def get_next_date(dt, mcount, day=None):
import datetime
month = getdate(dt).month + mcount
year = getdate(dt).year
if not day:
day = getdate(dt).day
if month > 12:
month, year = m-12, y+1
try:
next_month_date = datetime.date(year, month, day)
except:
import calendar
last_day = calendar.monthrange(year, month)[1]
next_month_date = datetime.date(year, month, last_day)
return next_month_date.strftime("%Y-%m-%d")
def manage_recurring_invoices():
"""
Create recurring invoices on specific date by copying the original one
and notify the concerned people
"""
recurring_invoices = webnotes.conn.sql("""select name, recurring_id
from `tabSales Invoice` where ifnull(convert_into_recurring_invoice, 0)=1
and docstatus=1 and next_date=%s
and next_date <= ifnull(end_date, '2199-12-31')""", nowdate())
exception_list = []
for ref_invoice, recurring_id in recurring_invoices:
if not webnotes.conn.sql("""select name from `tabSales Invoice`
where posting_date=%s and recurring_id=%s and docstatus=1""",
(nowdate(), recurring_id)):
try:
ref_wrapper = webnotes.model_wrapper('Sales Invoice', ref_invoice)
new_invoice_wrapper = make_new_invoice(ref_wrapper)
send_notification(new_invoice_wrapper)
webnotes.conn.commit()
except Exception, e:
webnotes.conn.rollback()
webnotes.conn.begin()
webnotes.conn.sql("update `tabSales Invoice` set \
convert_into_recurring_invoice = 0 where name = %s", ref_invoice)
notify_errors(ref_invoice, ref_wrapper.doc.owner)
webnotes.conn.commit()
exception_list.append(webnotes.getTraceback())
finally:
webnotes.conn.begin()
if exception_list:
exception_message = "\n\n".join([cstr(d) for d in exception_list])
raise Exception, exception_message
def make_new_invoice(ref_wrapper):
from webnotes.model.wrapper import clone
new_invoice = clone(ref_wrapper)
mcount = month_map[ref_wrapper.doc.recurring_type]
today = nowdate()
new_invoice.doc.fields.update({
"posting_date": today,
"aging_date": today,
"due_date": add_days(today, cint(date_diff(ref_wrapper.doc.due_date,
ref_wrapper.doc.posting_date))),
"invoice_period_from_date": \
get_next_date(ref_wrapper.doc.invoice_period_from_date, mcount),
"invoice_period_to_date": \
get_next_date(ref_wrapper.doc.invoice_period_to_date, mcount),
"owner": ref_wrapper.doc.owner,
})
new_invoice.submit()
return new_invoice
def send_notification(new_rv):
"""Notify concerned persons about recurring invoice generation"""
subject = "Invoice : " + new_rv.doc.name
com = new_rv.doc.company # webnotes.conn.get_value('Control Panel', '', 'letter_head')
hd = '''<div><h2>%s</h2></div>
<div><h3>Invoice: %s</h3></div>
<table cellspacing= "5" cellpadding="5" width = "100%%">
<tr>
<td width = "50%%"><b>Customer</b><br>%s<br>%s</td>
<td width = "50%%">Invoice Date : %s<br>Invoice Period : %s to %s <br>Due Date : %s</td>
</tr>
</table>
''' % (com, new_rv.doc.name, new_rv.doc.customer_name, new_rv.doc.address_display, getdate(new_rv.doc.posting_date).strftime("%d-%m-%Y"), \
getdate(new_rv.doc.invoice_period_from_date).strftime("%d-%m-%Y"), getdate(new_rv.doc.invoice_period_to_date).strftime("%d-%m-%Y"),\
getdate(new_rv.doc.due_date).strftime("%d-%m-%Y"))
tbl = '''<table border="1px solid #CCC" width="100%%" cellpadding="0px" cellspacing="0px">
<tr>
<td width = "15%%" bgcolor="#CCC" align="left"><b>Item</b></td>
<td width = "40%%" bgcolor="#CCC" align="left"><b>Description</b></td>
<td width = "15%%" bgcolor="#CCC" align="center"><b>Qty</b></td>
<td width = "15%%" bgcolor="#CCC" align="center"><b>Rate</b></td>
<td width = "15%%" bgcolor="#CCC" align="center"><b>Amount</b></td>
</tr>
'''
for d in getlist(new_rv.doclist, 'entries'):
tbl += '<tr><td>' + d.item_code +'</td><td>' + d.description+'</td><td>' + cstr(d.qty) +'</td><td>' + cstr(d.basic_rate) +'</td><td>' + cstr(d.amount) +'</td></tr>'
tbl += '</table>'
totals ='''<table cellspacing= "5" cellpadding="5" width = "100%%">
<tr>
<td width = "50%%"></td>
<td width = "50%%">
<table width = "100%%">
<tr>
<td width = "50%%">Net Total: </td><td>%s </td>
</tr><tr>
<td width = "50%%">Total Tax: </td><td>%s </td>
</tr><tr>
<td width = "50%%">Grand Total: </td><td>%s</td>
</tr><tr>
<td width = "50%%">In Words: </td><td>%s</td>
</tr>
</table>
</td>
</tr>
<tr><td>Terms and Conditions:</td></tr>
<tr><td>%s</td></tr>
</table>
''' % (new_rv.doc.net_total,
new_rv.doc.other_charges_total,new_rv.doc.grand_total,
new_rv.doc.in_words,new_rv.doc.terms)
msg = hd + tbl + totals
sendmail(new_rv.doc.notification_email_address, subject=subject, msg = msg)
def notify_errors(inv, owner):
import webnotes
import website
exception_msg = """
Dear User,
An error occured while creating recurring invoice from %s (at %s).
May be there are some invalid email ids mentioned in the invoice.
To stop sending repetitive error notifications from the system, we have unchecked
"Convert into Recurring" field in the invoice %s.
Please correct the invoice and make the invoice recurring again.
<b>It is necessary to take this action today itself for the above mentioned recurring invoice \
to be generated. If delayed, you will have to manually change the "Repeat on Day of Month" field \
of this invoice for generating the recurring invoice.</b>
Regards,
Administrator
""" % (inv, website.get_site_address(), inv)
subj = "[Urgent] Error while creating recurring invoice from %s" % inv
from webnotes.profile import get_system_managers
recipients = get_system_managers()
owner_email = webnotes.conn.get_value("Profile", owner, "email")
if not owner_email in recipients:
recipients.append(owner_email)
assign_task_to_owner(inv, exception_msg, recipients)
sendmail(recipients, subject=subj, msg = exception_msg)
def assign_task_to_owner(inv, msg, users):
for d in users:
from webnotes.widgets.form import assign_to
args = {
'assign_to' : d,
'doctype' : 'Sales Invoice',
'name' : inv,
'description' : msg,
'priority' : 'Urgent'
}
assign_to.add(args)

View File

@ -2,12 +2,13 @@
{
"owner": "Administrator",
"docstatus": 0,
"creation": "2012-10-10 10:52:22",
"creation": "2012-09-10 12:22:26",
"modified_by": "Administrator",
"modified": "2012-09-07 11:56:59"
"modified": "2012-11-30 16:39:08"
},
{
"is_submittable": 1,
"autoname": "naming_series:",
"allow_attach": 1,
"default_print_format": "Standard",
"search_fields": "posting_date, due_date, debit_to, fiscal_year, grand_total, outstanding_amount",
@ -34,6 +35,15 @@
"name": "Sales Invoice",
"doctype": "DocType"
},
{
"print_hide": 1,
"oldfieldtype": "Section Break",
"doctype": "DocField",
"label": "Basic Info",
"fieldname": "basic_info",
"fieldtype": "Section Break",
"permlevel": 0
},
{
"print_hide": 0,
"oldfieldtype": "Column Break",
@ -217,9 +227,9 @@
"permlevel": 0
},
{
"allow_on_submit": 1,
"oldfieldtype": "Table",
"colour": "White:FFF",
"allow_on_submit": 1,
"doctype": "DocField",
"label": "Entries",
"oldfieldname": "entries",
@ -428,9 +438,9 @@
"permlevel": 0
},
{
"allow_on_submit": 1,
"oldfieldtype": "Table",
"colour": "White:FFF",
"allow_on_submit": 1,
"doctype": "DocField",
"label": "Taxes and Charges1",
"oldfieldname": "other_charges",
@ -1174,6 +1184,7 @@
},
{
"print_hide": 1,
"depends_on": "eval:doc.docstatus<2",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Recurring Invoice",
@ -1193,7 +1204,7 @@
"print_hide": 1,
"description": "Check if recurring invoice, uncheck to stop recurring or put proper End Date",
"no_copy": 1,
"depends_on": "eval:doc.docstatus==1",
"depends_on": "eval:doc.docstatus<2",
"colour": "White:FFF",
"allow_on_submit": 1,
"doctype": "DocField",
@ -1205,23 +1216,24 @@
},
{
"print_hide": 1,
"allow_on_submit": 1,
"description": "Select the period when the invoice will be generated automatically",
"no_copy": 1,
"depends_on": "eval:doc.convert_into_recurring_invoice==1",
"colour": "White:FFF",
"allow_on_submit": 1,
"doctype": "DocField",
"label": "Recurring Type",
"options": "Monthly\nQuarterly\nHalf-yearly\nYearly",
"permlevel": 0,
"fieldname": "recurring_type",
"fieldtype": "Select",
"permlevel": 0
"options": "Monthly\nQuarterly\nHalf-yearly\nYearly"
},
{
"print_hide": 1,
"allow_on_submit": 1,
"description": "The day of the month on which auto invoice will be generated e.g. 05, 28 etc ",
"no_copy": 1,
"depends_on": "eval:doc.convert_into_recurring_invoice==1",
"allow_on_submit": 1,
"doctype": "DocField",
"label": "Repeat on Day of Month",
"fieldname": "repeat_on_day_of_month",
@ -1230,11 +1242,11 @@
},
{
"print_hide": 1,
"allow_on_submit": 1,
"description": "Start date of the invoice period",
"description": "Start date of current invoice's period",
"no_copy": 1,
"depends_on": "eval:doc.convert_into_recurring_invoice==1",
"colour": "White:FFF",
"allow_on_submit": 1,
"doctype": "DocField",
"label": "Invoice Period From Date",
"fieldname": "invoice_period_from_date",
@ -1243,10 +1255,11 @@
},
{
"print_hide": 1,
"allow_on_submit": 1,
"description": "End date of the invoice period",
"description": "End date of current invoice's period",
"no_copy": 1,
"depends_on": "eval:doc.convert_into_recurring_invoice==1",
"colour": "White:FFF",
"allow_on_submit": 1,
"doctype": "DocField",
"label": "Invoice Period To Date",
"fieldname": "invoice_period_to_date",
@ -1264,10 +1277,10 @@
},
{
"print_hide": 1,
"allow_on_submit": 1,
"description": "Enter email id separated by commas, invoice will be mailed automatically on particular date",
"no_copy": 1,
"depends_on": "eval:doc.convert_into_recurring_invoice==1",
"allow_on_submit": 1,
"doctype": "DocField",
"label": "Notification Email Address",
"fieldname": "notification_email_address",
@ -1276,9 +1289,10 @@
},
{
"print_hide": 1,
"description": "The unique id for tracking all recurring invoices ",
"description": "The unique id for tracking all recurring invoices.\u00a0It is generated on submit.",
"no_copy": 1,
"depends_on": "eval:doc.convert_into_recurring_invoice==1",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Recurring Id",
"fieldname": "recurring_id",
@ -1287,9 +1301,10 @@
},
{
"print_hide": 1,
"description": "The date on which next invoice will be generated ",
"description": "The date on which next invoice will be generated. It is generated on submit.\n",
"no_copy": 1,
"depends_on": "eval:doc.convert_into_recurring_invoice==1",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Next Date",
"fieldname": "next_date",
@ -1298,10 +1313,10 @@
},
{
"print_hide": 1,
"allow_on_submit": 1,
"description": "The date on which recurring invoice will be stop",
"no_copy": 1,
"depends_on": "eval:doc.convert_into_recurring_invoice==1",
"allow_on_submit": 1,
"doctype": "DocField",
"label": "End Date",
"fieldname": "end_date",

View File

@ -14,24 +14,14 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.wrapper import copy_doclist
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:

View File

@ -14,24 +14,16 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import cstr, flt, getdate
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes import msgprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:

View File

@ -14,24 +14,17 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import cstr, flt, now
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.doc import addchild, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes import msgprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:

View File

@ -14,24 +14,15 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import add_days, add_months, cint, cstr, month_name
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.wrapper import copy_doclist
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:
def __init__(self, d, dl):

View File

@ -185,9 +185,9 @@ erpnext.AccountsChart = Class.extend({
// tax rate if tax
$(fd.account_type.input).change(function() {
if($(this).val()=='Tax') {
$(fd.tax_rate.wrapper).toggle(true);
$(fd.tax_rate.wrapper).toggle(true);
} else {
$(fd.tax_rate.wrapper).toggle(false);
$(fd.tax_rate.wrapper).toggle(false);
}
})
@ -214,6 +214,7 @@ erpnext.AccountsChart = Class.extend({
// show
d.onshow = function() {
$(fd.group_or_ledger.input).change();
$(fd.account_type.input).change();
}
d.show();
},

View File

@ -1,14 +1,14 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import formatdate, flt
from webnotes.utils import flt
@webnotes.whitelist()
def get_template():
"""download template"""
template_type = webnotes.form_dict.get('type')
from webnotes.model.doctype import get_field_property
naming_options = get_field_property("Journal Voucher", "naming_series", "options")
voucher_type = get_field_property("Journal Voucher", "voucher_type", "options")
from webnotes.model.doctype import get_property
naming_options = get_property("Journal Voucher", "naming_series", "options")
voucher_type = get_property("Journal Voucher", "voucher_type", "options")
if template_type=="Two Accounts":
extra_note = ""
columns = '''"Naming Series","Voucher Type","Posting Date","Amount","Debit Account","Credit Account","Cost Center","Against Sales Invoice","Against Purchase Invoice","Against Journal Voucher","Remarks","Due Date","Ref Number","Ref Date"'''
@ -64,7 +64,6 @@ def map_fields(field_list, source, target):
def import_vouchers(common_values, data, start_idx, import_type):
from webnotes.model.doc import Document
from webnotes.model.wrapper import ModelWrapper
from webnotes.model.code import get_obj
from accounts.utils import get_fiscal_year
from webnotes.utils.dateutils import parse_date

View File

@ -16,7 +16,7 @@
# add expense head columns
from __future__ import unicode_literals
from webnotes.utils import flt, cint, cstr
from webnotes.utils import flt
expense_acc = [c[0] for c in sql("""select distinct expense_head
from `tabPurchase Invoice Item`

View File

@ -16,7 +16,7 @@
# add additional columns
from __future__ import unicode_literals
from webnotes.utils import flt, cint, cstr
from webnotes.utils import flt
cl = [c[0] for c in sql("""select distinct account_head
from `tabSales Taxes and Charges`

View File

@ -30,8 +30,7 @@ else:
if from_date != "" and to_date != "":
get_obj('MIS Control').dates(from_fiscal_year,from_date,to_date) # validate dates (i.e. dates should be between particular fiscal year)
# Add columns based on from and to fiscal year
# --------------------------------------------------------------------------------------------------
# Add columns based on from and to fiscal year---------
columns = []
columns.append(['ID','Data','150px',''])
columns.append(['Description','Data','150px',''])

View File

@ -14,24 +14,18 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import add_days, cint, cstr, flt, getdate, now
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.doc import Document, addchild
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.code import get_obj
from webnotes import form, msgprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
from utilities.transaction_base import TransactionBase
class DocType(TransactionBase):

View File

@ -21,7 +21,6 @@ cur_frm.cscript.other_fname = "purchase_tax_details";
wn.require('app/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js');
wn.require('app/buying/doctype/purchase_common/purchase_common.js');
wn.require('app/utilities/doctype/sms_control/sms_control.js');
wn.require('app/setup/doctype/notification_control/notification_control.js');
cur_frm.cscript.onload = function(doc, cdt, cdn) {
// set missing values in parent doc
@ -220,9 +219,7 @@ cur_frm.pformat.indent_no = function(doc, cdt, cdn){
}
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
var args = {
type: 'Purchase Order',
doctype: 'Purchase Order'
if(cint(wn.boot.notification_settings.purchase_order)) {
cur_frm.email_doc(wn.boot.notification_settings.purchase_order);
}
cur_frm.cscript.notify(doc, args);
}

View File

@ -14,24 +14,18 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import cstr, date_diff, flt, get_defaults, now
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.doc import addchild, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.code import get_obj
from webnotes import msgprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
from utilities.transaction_base import TransactionBase

View File

@ -14,24 +14,18 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import cstr, date_diff, flt, get_defaults, now
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.doc import make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.code import get_obj
from webnotes import msgprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:

View File

@ -14,24 +14,15 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.doc import addchild, make_autoname
from webnotes.model.wrapper import copy_doclist
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:

View File

@ -15,7 +15,6 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
wn.require('app/setup/doctype/contact_control/contact_control.js');
wn.require('app/support/doctype/communication/communication.js');
cur_frm.cscript.onload = function(doc,dt,dn){
@ -29,7 +28,6 @@ cur_frm.cscript.onload = function(doc,dt,dn){
// make contact, history list body
//cur_frm.cscript.make_cl_body();
cur_frm.cscript.make_hl_body();
cur_frm.cscript.make_communication_body();
}
cur_frm.cscript.refresh = function(doc,dt,dn) {
@ -46,8 +44,13 @@ cur_frm.cscript.refresh = function(doc,dt,dn) {
// make lists
cur_frm.cscript.make_address(doc,dt,dn);
cur_frm.cscript.make_contact(doc,dt,dn);
cur_frm.cscript.render_communication_list(doc, cdt, cdn);
cur_frm.cscript.make_history(doc,dt,dn);
cur_frm.communication_view = new wn.views.CommunicationList({
list: wn.model.get("Communication", {"supplier": doc.name}),
parent: cur_frm.fields_dict.communication_html.wrapper,
doc: doc
})
}
}

View File

@ -14,30 +14,25 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.utils import cstr, get_defaults
from webnotes.model.code import get_obj
from webnotes import msgprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
from utilities.transaction_base import TransactionBase
class DocType:
class DocType(TransactionBase):
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
def onload(self):
self.add_communication_list()
def autoname(self):
#get default naming conventional from control panel
supp_master_name = get_defaults()['supp_master_name']
@ -59,22 +54,17 @@ class DocType:
else:
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
# ----------------------------------------
# update credit days and limit in account
# ----------------------------------------
def update_credit_days_limit(self):
sql("update tabAccount set credit_days = '%s' where name = '%s'" % (self.doc.credit_days, self.doc.name + " - " + self.get_company_abbr()))
def on_update(self):
if not self.doc.naming_series:
self.doc.naming_series = ''
# create address
addr_flds = [self.doc.address_line1, self.doc.address_line2, self.doc.city, self.doc.state, self.doc.country, self.doc.pincode]
address_line = "\n".join(filter(lambda x : (x!='' and x!=None),addr_flds))
set(self.doc,'address', address_line)
webnotes.conn.set(self.doc,'address', address_line)
# create account head
self.create_account_head()
@ -82,12 +72,9 @@ class DocType:
# update credit days and limit in account
self.update_credit_days_limit()
def check_state(self):
return "\n" + "\n".join([i[0] for i in sql("select state_name from `tabState` where `tabState`.country='%s' " % self.doc.country)])
# ACCOUNTS
# -------------------------------------------
def get_payables_group(self):
g = sql("select payables_group from tabCompany where name=%s", self.doc.company)
g = g and g[0][0] or ''
@ -116,7 +103,6 @@ class DocType:
return self.doc.supplier_type + " - " + abbr
def validate(self):
#validation for Naming Series mandatory field...
if get_defaults()['supp_master_name'] == 'Naming Series':
@ -124,9 +110,6 @@ class DocType:
msgprint("Series is Mandatory.")
raise Exception
# create accont head - in tree under zone + territory
# -------------------------------------------------------
def create_account_head(self):
if self.doc.company :
abbr = self.get_company_abbr()
@ -142,7 +125,6 @@ class DocType:
else :
msgprint("Please select Company under which you want to create account head")
def get_contacts(self,nm):
if nm:
contact_details =convert_to_lists(sql("select name, CONCAT(IFNULL(first_name,''),' ',IFNULL(last_name,'')),contact_no,email_id from `tabContact` where supplier = '%s'"%nm))
@ -172,16 +154,12 @@ class DocType:
from webnotes.model import delete_doc
delete_doc('Account', acc[0][0])
def on_trash(self):
self.delete_supplier_address()
self.delete_supplier_contact()
self.delete_supplier_communication()
self.delete_supplier_account()
# on rename
# ---------
def on_rename(self,newdn,olddn):
#update supplier_name if not naming series
if get_defaults().get('supp_master_name') == 'Supplier Name':

View File

@ -2,11 +2,12 @@
{
"owner": "Administrator",
"docstatus": 0,
"creation": "2012-07-18 20:34:42",
"creation": "2012-11-02 17:17:04",
"modified_by": "Administrator",
"modified": "2012-07-18 17:41:49"
"modified": "2012-11-30 10:53:32"
},
{
"autoname": "naming_series:",
"name": "__common__",
"search_fields": "supplier_name,supplier_type",
"module": "Buying",
@ -32,6 +33,16 @@
"name": "Supplier",
"doctype": "DocType"
},
{
"description": "Note: You Can Manage Multiple Address or Contacts via Addresses & Contacts",
"oldfieldtype": "Section Break",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Basic Info",
"fieldname": "basic_info",
"fieldtype": "Section Break",
"permlevel": 0
},
{
"no_copy": 1,
"oldfieldtype": "Data",
@ -124,7 +135,6 @@
},
{
"doctype": "DocField",
"label": "Communication History",
"fieldname": "communication_history",
"fieldtype": "Section Break",
"permlevel": 0
@ -246,8 +256,7 @@
"write": 1,
"role": "Purchase Master Manager",
"cancel": 1,
"permlevel": 0,
"match": ""
"permlevel": 0
},
{
"amend": 0,

View File

@ -0,0 +1,433 @@
# ERPNext - web based ERP (http://erpnext.com)
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import webnotes
import webnotes.model
from webnotes import _, msgprint
from webnotes.utils import cint, flt
from webnotes.model.utils import round_doc
import json
from controllers.transaction_controller import TransactionController
class TaxController(TransactionController):
def append_taxes(self):
"""append taxes as per tax master link field"""
# clear tax table
self.doclist = self.doclist.get({"parentfield": ["!=",
self.fmap.taxes_and_charges]})
tax_master_doctype = self.meta.get_options(self.fmap.taxes_and_charges_master)
master_tax_list = webnotes.get_doclist(tax_master_doctype,
self.doc.fields.get(self.fmap.taxes_and_charges_master)).get(
{"parentfield": self.fmap.taxes_and_charges})
for base_tax in master_tax_list:
tax = DictObj([[field, base_tax.fields.get(field)]
for field in base_tax.fields
if field not in webnotes.model.default_fields])
tax.update({
"doctype": self.meta.get_options(self.fmap.taxes_and_charges),
"parentfield": self.fmap.taxes_and_charges,
"rate": flt(tax.rate, self.precision.tax.rate),
})
self.doclist.append(tax)
def calculate_taxes_and_totals(self):
"""
Calculates:
* amount for each item
* valuation_tax_amount for each item,
* tax amount and tax total for each tax
* net total
* total taxes
* grand total
"""
self.doc.fields[self.fmap.exchange_rate] = \
flt(self.doc.fields.get(self.fmap.exchange_rate),
self.precision.main[self.fmap.exchange_rate])
self.calculate_item_values()
self.initialize_taxes()
if self.meta.get_field("included_in_print_rate",
parentfield=self.fmap.taxes_and_charges):
self.determine_exclusive_rate()
self.calculate_net_total()
self.calculate_taxes()
self.calculate_totals()
self.set_amount_in_words()
def calculate_item_values(self):
def _set_base(item, print_field, base_field):
"""set values in base currency"""
item.fields[base_field] = flt((flt(item.fields[print_field],
self.precision.item[print_field]) * \
self.doc.fields.get(self.fmap.exchange_rate)),
self.precision.item[base_field])
for item in self.item_doclist:
round_doc(item, self.precision.item)
if item.fields.get(self.fmap.discount) == 100:
if not item.fields.get(self.fmap.print_ref_rate):
item.fields[self.fmap.print_ref_rate] = \
item.fields.get(self.fmap.print_rate)
item.fields[self.fmap.print_rate] = 0
else:
if item.fields.get(self.fmap.print_ref_rate):
item.fields[self.fmap.print_rate] = \
flt(item.fields.get(self.fmap.print_ref_rate) *
(1.0 - (item.fields.get(self.fmap.discount) / 100.0)),
self.precision.item[self.fmap.print_rate])
else:
# assume that print rate and discount are specified
item.fields[self.fmap.print_ref_rate] = \
flt(item.fields.get(self.fmap.print_rate) /
(1.0 - (item.fields.get(self.fmap.discount) / 100.0)),
self.precision.item[self.fmap.print_ref_rate])
item.fields[self.fmap.print_amount] = \
flt(item.fields.get(self.fmap.print_rate) * \
item.fields.get(self.fmap.qty),
self.precision.item[self.fmap.print_amount])
_set_base(item, self.fmap.print_ref_rate, self.fmap.ref_rate)
_set_base(item, self.fmap.print_rate, self.fmap.rate)
_set_base(item, self.fmap.print_amount, self.fmap.amount)
def initialize_taxes(self):
for tax in self.tax_doclist:
# initialize totals to 0
tax.tax_amount = tax.total = tax.total_print = 0
tax.grand_total_for_current_item = tax.tax_amount_for_current_item = 0
# for actual type, user can mention actual tax amount in tax.tax_amount_print
if tax.charge_type != "Actual" or tax.rate:
tax.tax_amount_print = 0
self.validate_on_previous_row(tax)
self.validate_included_tax(tax)
# round relevant values
round_doc(tax, self.precision.tax)
def calculate_net_total(self):
self.doc.net_total = 0
self.doc.fields[self.fmap.net_total_print] = 0
for item in self.item_doclist:
self.doc.net_total += item.amount
self.doc.fields[self.fmap.net_total_print] += \
item.fields.get(self.fmap.print_amount)
self.doc.net_total = flt(self.doc.net_total, self.precision.main.net_total)
self.doc.fields[self.fmap.net_total_print] = \
flt(self.doc.fields.get(self.fmap.net_total_print),
self.precision.main[self.fmap.net_total_print])
def calculate_taxes(self):
for item in self.item_doclist:
item_tax_map = self._load_item_tax_rate(item.item_tax_rate)
item.fields[self.fmap.valuation_tax_amount] = 0
for i, tax in enumerate(self.tax_doclist):
# tax_amount represents the amount of tax for the current step
current_tax_amount = self.get_current_tax_amount(item, tax, item_tax_map)
if hasattr(self, "set_valuation_tax_amount"):
self.set_valuation_tax_amount(item, tax, current_tax_amount)
# case when net total is 0 but there is an actual type charge
# in this case add the actual amount to tax.tax_amount
# and tax.grand_total_for_current_item for the first such iteration
if not (current_tax_amount or self.doc.net_total or tax.tax_amount) and \
tax.charge_type=="Actual":
zero_net_total_adjustment = flt((tax.tax_amount_print *
self.doc.fields.get(self.fmap.exchange_rate)) or tax.rate,
self.precision.tax.tax_amount)
current_tax_amount += zero_net_total_adjustment
# store tax_amount for current item as it will be used for
# charge type = 'On Previous Row Amount'
tax.tax_amount_for_current_item = current_tax_amount
# accumulate tax amount into tax.tax_amount
tax.tax_amount += tax.tax_amount_for_current_item
# accumulate tax_amount_print only if tax is not included
# and if tax amount of actual type is entered in 'rate' field
if not cint(tax.included_in_print_rate) and (tax.charge_type != "Actual"
or tax.rate):
tax.tax_amount_print += flt((tax.tax_amount_for_current_item /
self.doc.fields.get(self.fmap.exchange_rate)),
self.precision.tax.tax_amount_print)
if tax.category == "Valuation":
# if just for valuation, do not add the tax amount in total
# hence, setting it as 0 for further steps
current_tax_amount = 0
# Calculate tax.total viz. grand total till that step
# note: grand_total_for_current_item contains the contribution of
# item's amount, previously applied tax and the current tax on that item
if i==0:
tax.grand_total_for_current_item = flt(item.amount +
current_tax_amount, self.precision.tax.total)
# if inclusive pricing, current_tax_amount should not be considered
if cint(tax.included_in_print_rate):
current_tax_amount = 0
tax.grand_total_print_for_current_item = \
flt(item.fields.get(self.fmap.print_amount) +
(current_tax_amount / self.doc.fields.get(
self.fmap.exchange_rate)),
self.precision.tax.total_print)
else:
tax.grand_total_for_current_item = \
flt(self.tax_doclist[i-1].grand_total_for_current_item +
current_tax_amount, self.precision.tax.total)
# if inclusive pricing, current_tax_amount should not be considered
if cint(tax.included_in_print_rate):
current_tax_amount = 0
tax.grand_total_print_for_current_item = \
flt(self.tax_doclist[i-1].grand_total_print_for_current_item +
(current_tax_amount / self.doc.fields.get(
self.fmap.exchange_rate)),
self.precision.tax.total_print)
# in tax.total, accumulate grand total of each item
tax.total += tax.grand_total_for_current_item
tax.total_print += tax.grand_total_print_for_current_item
# TODO store tax_breakup for each item
def get_current_tax_amount(self, item, tax, item_tax_map):
tax_rate = self._get_tax_rate(tax, item_tax_map)
if tax.charge_type == "Actual":
# distribute the tax amount proportionally to each item row
actual = flt(tax.rate or (tax.tax_amount_print * \
self.doc.fields.get(self.fmap.exchange_rate)),
self.precision.tax.tax_amount)
current_tax_amount = (self.doc.net_total
and ((item.amount / self.doc.net_total) * actual)
or 0)
elif tax.charge_type == "On Net Total":
current_tax_amount = (tax_rate / 100.0) * item.amount
elif tax.charge_type == "On Previous Row Amount":
current_tax_amount = (tax_rate / 100.0) * \
self.tax_doclist[cint(tax.row_id) - 1].tax_amount_for_current_item
elif tax.charge_type == "On Previous Row Total":
current_tax_amount = (tax_rate / 100.0) * \
self.tax_doclist[cint(tax.row_id) - 1].grand_total_for_current_item
return flt(current_tax_amount, self.precision.tax.tax_amount)
def calculate_totals(self):
if self.tax_doclist:
self.doc.grand_total = flt(self.tax_doclist[-1].total,
self.precision.main.grand_total)
self.doc.fields[self.fmap.grand_total_print] = \
flt(self.tax_doclist[-1].total_print,
self.precision.main[self.fmap.grand_total_print])
else:
self.doc.grand_total = flt(self.doc.net_total,
self.precision.main.grand_total)
self.doc.fields[self.fmap.grand_total_print] = \
flt(self.doc.fields.get(self.fmap.net_total_print),
self.precision.main[self.fmap.grand_total_print])
self.doc.fields[self.fmap.taxes_and_charges_total] = \
flt(self.doc.grand_total - self.doc.net_total,
self.precision.main[self.fmap.taxes_and_charges_total])
self.doc.taxes_and_charges_total_print = \
flt(self.doc.fields.get(self.fmap.grand_total_print) - \
self.doc.fields.get(self.fmap.net_total_print),
self.precision.main.taxes_and_charges_total_print)
self.doc.rounded_total = round(self.doc.grand_total)
self.doc.fields[self.fmap.rounded_total_print] = \
round(self.doc.fields.get(self.fmap.grand_total_print))
def set_amount_in_words(self):
from webnotes.utils import money_in_words
base_currency = webnotes.conn.get_value("Company", self.doc.currency,
"default_currency")
self.doc.fields[self.fmap.grand_total_in_words] = \
money_in_words(self.doc.grand_total, base_currency)
self.doc.fields[self.fmap.rounded_total_in_words] = \
money_in_words(self.doc.rounded_total, base_currency)
self.doc.fields[self.fmap.grand_total_in_words_print] = \
money_in_words(self.doc.fields.get(self.fmap.grand_total_print),
self.doc.currency)
self.doc.fields[self.fmap.rounded_total_in_words_print] = \
money_in_words(self.doc.fields.get(self.fmap.rounded_total_print),
self.doc.currency)
def validate_on_previous_row(self, tax):
"""
validate if a valid row id is mentioned in case of
On Previous Row Amount and On Previous Row Total
"""
if tax.charge_type in ["On Previous Row Amount", "On Previous Row Total"] and \
(not tax.row_id or cint(tax.row_id) >= tax.idx):
msgprint((_("Row") + " # %(idx)s [%(taxes_doctype)s]: " + \
_("Please specify a valid") + " %(row_id_label)s") % {
"idx": tax.idx,
"taxes_doctype": tax.parenttype,
"row_id_label": self.meta.get_label("row_id",
parentfield=self.fmap.taxes_and_charges)
}, raise_exception=True)
def validate_included_tax(self, tax):
"""
validate conditions related to "Is this Tax Included in Rate?"
"""
def _on_previous_row_error(tax, row_range):
msgprint((_("Row") + " # %(idx)s [%(taxes_doctype)s]: " + \
_("If") + " '%(inclusive_label)s' " + _("is checked for") + \
" '%(charge_type_label)s' = '%(charge_type)s', " + _("then") + " " + \
_("Row") + " # %(row_range)s " + _("should also have") + \
" '%(inclusive_label)s' = " + _("checked")) % {
"idx": tax.idx,
"taxes_doctype": tax.doctype,
"inclusive_label": self.meta.get_label("included_in_print_rate",
parentfield=self.fmap.taxes_and_charges),
"charge_type_label": self.meta.get_label("charge_type",
parentfield=self.fmap.taxes_and_charges),
"charge_type": tax.charge_type,
"row_range": row_range,
}, raise_exception=True)
if cint(tax.included_in_print_rate):
if tax.charge_type == "Actual":
# now inclusive rate for type 'Actual'
msgprint((_("Row") + " # %(idx)s [%(taxes_doctype)s]: " + \
"'%(charge_type_label)s' = '%(charge_type)s' " + \
_("cannot be included in item's rate")) % {
"idx": tax.idx,
"taxes_doctype": self.meta.get_options(
self.fmap.taxes_and_charges),
"charge_type_label": self.meta.get_label("charge_type",
parentfield=self.fmap.taxes_and_charges),
"charge_type": tax.charge_type,
}, raise_exception=True)
elif tax.charge_type == "On Previous Row Amount" and \
not cint(self.tax_doclist[cint(tax.row_id) - 1]\
.included_in_print_rate):
# for an inclusive tax of type "On Previous Row Amount",
# dependent row should also be inclusive
_on_previous_row_error(tax, tax.row_id)
elif tax.charge_type == "On Previous Row Total" and \
not all([cint(t.included_in_print_rate) \
for t in self.tax_doclist[:tax.idx - 1]]):
# for an inclusive tax of type "On Previous Row Total",
# all rows above it should also be inclusive
_on_previous_row_error(tax, "1 - %d" % (tax.idx - 1))
def determine_exclusive_rate(self):
if not any((cint(tax.included_in_print_rate) for tax in self.tax_doclist)):
# if no tax is marked as included in print rate, no need to proceed further
return
for item in self.item_doclist:
item_tax_map = self._load_item_tax_rate(item.item_tax_rate)
cumulated_tax_fraction = 0
for i, tax in enumerate(self.tax_doclist):
if cint(tax.included_in_print_rate):
tax.tax_fraction_for_current_item = \
self.get_current_tax_fraction(tax, item_tax_map)
else:
tax.tax_fraction_for_current_item = 0
if i==0:
tax.grand_total_fraction_for_current_item = 1 + \
tax.tax_fraction_for_current_item
else:
tax.grand_total_fraction_for_current_item = \
self.tax_doclist[i-1].grand_total_fraction_for_current_item \
+ tax.tax_fraction_for_current_item
cumulated_tax_fraction += tax.tax_fraction_for_current_item
if cumulated_tax_fraction:
item.fields[self.fmap.rate] = \
flt((item.fields.get(self.fmap.print_rate) * \
self.doc.fields.get(self.fmap.exchange_rate)) /
(1 + cumulated_tax_fraction), self.precision.item[self.fmap.rate])
item.amount = flt(item.fields.get(self.fmap.rate) * item.qty,
self.precision.item.amount)
item.fields[self.fmap.ref_rate] = \
flt(item.fields.get(self.fmap.rate) / (1 - \
(item.fields.get(self.fmap.discount) / 100.0)),
self.precision.item[self.fmap.ref_rate])
# print item.print_rate, 1+cumulated_tax_fraction, item.rate, item.amount
# print "-"*10
def get_current_tax_fraction(self, tax, item_tax_map):
"""
Get tax fraction for calculating tax exclusive amount
from tax inclusive amount
"""
current_tax_fraction = 0
if cint(tax.included_in_print_rate):
tax_rate = self._get_tax_rate(tax, item_tax_map)
if tax.charge_type == "On Net Total":
current_tax_fraction = tax_rate / 100.0
elif tax.charge_type == "On Previous Row Amount":
current_tax_fraction = (tax_rate / 100.0) * \
self.tax_doclist[cint(tax.row_id) - 1]\
.tax_fraction_for_current_item
elif tax.charge_type == "On Previous Row Total":
current_tax_fraction = (tax_rate / 100.0) * \
self.tax_doclist[cint(tax.row_id) - 1]\
.grand_total_fraction_for_current_item
# print tax.account_head, tax_rate, current_tax_fraction
return current_tax_fraction
def _load_item_tax_rate(self, item_tax_rate):
if not item_tax_rate:
return {}
return json.loads(item_tax_rate)
def _get_tax_rate(self, tax, item_tax_map):
if item_tax_map.has_key(tax.account_head):
return flt(item_tax_map.get(tax.account_head), self.precision.tax.rate)
else:
return tax.rate

View File

@ -0,0 +1,119 @@
# ERPNext - web based ERP (http://erpnext.com)
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import webnotes
import webnotes.model
from webnotes import _, DictObj
from webnotes.utils import cint
import json
import stock.utils
from webnotes.model.controller import DocListController
class TransactionController(DocListController):
def __init__(self, doc, doclist):
super(TransactionController, self).__init__(doc, doclist)
self.cur_docstatus = cint(webnotes.conn.get_value(self.doc.doctype,
self.doc.name, "docstatus"))
@property
def precision(self):
if not hasattr(self, "_precision"):
self._precision = DictObj()
self._precision.main = self.meta.get_precision_map()
self._precision.item = self.meta.get_precision_map(parentfield = \
self.item_table_field)
if self.meta.get_field(self.fmap.taxes_and_charges):
self._precision.tax = self.meta.get_precision_map(parentfield = \
self.fmap.taxes_and_charges)
return self._precision
@property
def item_doclist(self):
if not hasattr(self, "_item_doclist"):
self._item_doclist = self.doclist.get({"parentfield": self.item_table_field})
return self._item_doclist
@property
def tax_doclist(self):
if not hasattr(self, "_tax_doclist"):
self._tax_doclist = self.doclist.get(
{"parentfield": self.fmap.taxes_and_charges})
return self._tax_doclist
@property
def stock_items(self):
if not hasattr(self, "_stock_items"):
item_codes = list(set(item.item_code for item in self.item_doclist))
self._stock_items = [r[0] for r in webnotes.conn.sql("""select name
from `tabItem` where name in (%s) and is_stock_item='Yes'""" % \
(", ".join((["%s"]*len(item_codes))),), item_codes)]
return self._stock_items
@property
def fmap(self):
if not hasattr(self, "_fmap"):
if self.doc.doctype in ["Lead", "Quotation", "Sales Order", "Sales Invoice",
"Delivery Note"]:
self._fmap = webnotes.DictObj( {
"exchange_rate": "conversion_rate",
"taxes_and_charges": "other_charges",
"taxes_and_charges_master": "charge",
"taxes_and_charges_total": "other_charges_total",
"net_total_print": "net_total_print",
"grand_total_print": "grand_total_export",
"grand_total_in_words": "grand_total_in_words",
"grand_total_in_words_print": "grand_total_in_words_print",
"rounded_total_print": "rounded_total_export",
"rounded_total_in_words": "in_words",
"rounded_total_in_words_print": "in_words_export",
"print_ref_rate": "ref_rate",
"discount": "adj_rate",
"print_rate": "export_rate",
"print_amount": "export_amount",
"ref_rate": "base_ref_rate",
"rate": "basic_rate",
"plc_exchange_rate": "plc_conversion_rate",
"tax_calculation": "other_charges_calculation",
})
else:
self._fmap = webnotes.DictObj({
"exchange_rate": "conversion_rate",
"taxes_and_charges": "purchase_tax_details",
"taxes_and_charges_master": "purchase_other_charges",
"taxes_and_charges_total": "total_tax",
"net_total_print": "net_total_import",
"grand_total_print": "grand_total_import",
"grand_total_in_words": "in_words",
"grand_total_in_words_print": "in_words_import",
"rounded_total_print": "rounded_total_print",
"rounded_total_in_words": "rounded_total_in_words",
"rounded_total_in_words_print": "rounded_total_in_words_print",
"print_ref_rate": "import_ref_rate",
"discount": "discount_rate",
"print_rate": "import_rate",
"print_amount": "import_amount",
"ref_rate": "purchase_ref_rate",
"rate": "purchase_rate",
"valuation_tax_amount": "item_tax_amount"
})
return self._fmap or webnotes.DictObj()

View File

@ -14,24 +14,17 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import cint, cstr
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.doc import Document
from webnotes.model.wrapper import copy_doclist
from webnotes import session
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:

View File

@ -14,24 +14,14 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.wrapper import copy_doclist
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:

View File

@ -14,28 +14,24 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes import session, msgprint, errprint
from webnotes.utils import add_days, cint, cstr, getdate, now, nowdate
from webnotes.model.doc import Document
from webnotes import session, msgprint
sql = webnotes.conn.sql
convert_to_lists = webnotes.conn.convert_to_lists
try: import json
except: import simplejson as json
# -----------------------------------------------------------------------------------------
class DocType:
def __init__(self,d,dl):
self.doc, self.doclist = d,dl
# --------------------------------------------------------------------------------------------------------
---------------
# ------------------------------------- Home page module details -----------------------------------------
def delete_cache(self):

View File

@ -1,4 +1,12 @@
erpnext.updates = [
["30th November 2012", [
"Auto Notifications: System will prompt user with pre-set message for auto-notification.",
"Employee: Users with role Employee will only be able to see their Employee Records.",
"Leave Application: Users with role Employee can now apply for leaves. HR User will be able to set Approval or Rejection.",
]],
["29th November 2012", [
"EMail: Form Emails are now via Communication (with Rich Text Etc.).",
]],
["28th November 2012", [
"Profile: Profile Settings (My Settings...) is now the Profile Form.",
"Financial Analytics: Show Net Profit/Loss",

View File

@ -14,11 +14,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, cstr, flt, getdate, now, nowdate
from webnotes.utils import cstr, flt, getdate
from webnotes.model.wrapper import getlist
from webnotes.model.code import get_obj
from webnotes import msgprint

View File

@ -14,24 +14,17 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import add_days, getdate, now
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.doc import make_autoname
from webnotes.model.wrapper import copy_doclist
from webnotes import msgprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:

View File

@ -14,24 +14,16 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import cint, cstr, date_diff, formatdate, get_defaults, getdate, now
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.wrapper import copy_doclist
from webnotes import form, msgprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:

View File

@ -17,7 +17,7 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import getdate, now, nowdate, validate_email_add
from webnotes.utils import getdate, validate_email_add
from webnotes.model.doc import make_autoname
from webnotes import msgprint
@ -37,6 +37,8 @@ class DocType:
self.doc.name = make_autoname(self.doc.naming_series + '.####')
elif ret[0][0]=='Employee Number':
self.doc.name = make_autoname(self.doc.employee_number)
self.doc.employee = self.doc.name
def get_retirement_date(self):
import datetime
@ -51,6 +53,7 @@ class DocType:
return ret_sal_struct and ret_sal_struct[0][0] or ''
def validate(self):
self.doc.employee = self.doc.name
self.validate_date()
self.validate_email()
self.validate_name()

File diff suppressed because it is too large Load Diff

View File

@ -1,120 +1,75 @@
# DocType, Employee External Work History
[
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:35:59',
'docstatus': 0,
'modified': '2012-03-27 14:35:59',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'colour': u'White:FFF',
'doctype': 'DocType',
'istable': 1,
'module': u'HR',
'name': '__common__',
'section_style': u'Simple',
'server_code_error': u' ',
'show_in_menu': 0,
'version': 3
},
# These values are common for all DocField
{
'doctype': u'DocField',
'name': '__common__',
'parent': u'Employee External Work History',
'parentfield': u'fields',
'parenttype': u'DocType',
'permlevel': 0
},
# These values are common for all DocPerm
{
'create': 1,
'doctype': u'DocPerm',
'name': '__common__',
'parent': u'Employee External Work History',
'parentfield': u'permissions',
'parenttype': u'DocType',
'permlevel': 0,
'read': 1,
'role': u'All',
'write': 1
},
# DocType, Employee External Work History
{
'doctype': 'DocType',
'name': u'Employee External Work History'
},
# DocPerm
{
'doctype': u'DocPerm'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'company_name',
'fieldtype': u'Data',
'label': u'Company',
'oldfieldname': u'company_name',
'oldfieldtype': u'Data'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'designation',
'fieldtype': u'Data',
'label': u'Designation',
'oldfieldname': u'designation',
'oldfieldtype': u'Data'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'salary',
'fieldtype': u'Currency',
'label': u'Salary',
'oldfieldname': u'salary',
'oldfieldtype': u'Currency'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'address',
'fieldtype': u'Small Text',
'label': u'Address',
'oldfieldname': u'address',
'oldfieldtype': u'Small Text'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'contact',
'fieldtype': u'Data',
'label': u'Contact',
'oldfieldname': u'contact',
'oldfieldtype': u'Data'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'total_experience',
'fieldtype': u'Data',
'label': u'Total Experience',
'oldfieldname': u'total_experience',
'oldfieldtype': u'Data'
}
{
"owner": "Administrator",
"docstatus": 0,
"creation": "2012-07-03 13:29:41",
"modified_by": "Administrator",
"modified": "2012-11-30 11:57:58"
},
{
"istable": 1,
"name": "__common__",
"doctype": "DocType",
"module": "HR"
},
{
"name": "__common__",
"parent": "Employee External Work History",
"doctype": "DocField",
"parenttype": "DocType",
"permlevel": 0,
"parentfield": "fields"
},
{
"name": "Employee External Work History",
"doctype": "DocType"
},
{
"oldfieldtype": "Data",
"doctype": "DocField",
"label": "Company",
"oldfieldname": "company_name",
"fieldname": "company_name",
"fieldtype": "Data"
},
{
"oldfieldtype": "Data",
"doctype": "DocField",
"label": "Designation",
"oldfieldname": "designation",
"fieldname": "designation",
"fieldtype": "Data"
},
{
"oldfieldtype": "Currency",
"doctype": "DocField",
"label": "Salary",
"oldfieldname": "salary",
"fieldname": "salary",
"fieldtype": "Currency"
},
{
"oldfieldtype": "Small Text",
"doctype": "DocField",
"label": "Address",
"oldfieldname": "address",
"fieldname": "address",
"fieldtype": "Small Text"
},
{
"oldfieldtype": "Data",
"doctype": "DocField",
"label": "Contact",
"oldfieldname": "contact",
"fieldname": "contact",
"fieldtype": "Data"
},
{
"oldfieldtype": "Data",
"doctype": "DocField",
"label": "Total Experience",
"oldfieldname": "total_experience",
"fieldname": "total_experience",
"fieldtype": "Data"
}
]

View File

@ -100,8 +100,6 @@ cur_frm.cscript.sanctioned_amount = function(doc,cdt,cdn){
cur_frm.cscript.calculate_total(doc,cdt,cdn);
}
wn.require('app/setup/doctype/notification_control/notification_control.js');
cur_frm.cscript.approve = function(doc,cdt,cdn){
cur_frm.cscript.calculate_total(doc,cdt,cdn);
@ -248,12 +246,9 @@ cur_frm.cscript.update_voucher = function(doc){
}
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
var args = {
type: 'Expense Claim',
doctype: 'Expense Claim',
send_to: doc.exp_approver
if(cint(wn.boot.notification_settings.expense_claim)) {
cur_frm.email_doc(wn.boot.notification_settings.expense_claim);
}
cur_frm.cscript.notify(doc, args);
}
cur_frm.fields_dict.employee.get_query = erpnext.utils.employee_query;

View File

@ -14,24 +14,17 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import add_days, cstr
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.code import get_obj
from webnotes import form, msgprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:

View File

@ -14,26 +14,19 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import add_days, add_years, cint, getdate
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.doc import addchild, make_autoname
from webnotes.model.wrapper import copy_doclist
from webnotes import msgprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
import datetime
# -----------------------------------------------------------------------------------------
class DocType:

View File

@ -14,12 +14,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cint, flt
from webnotes import msgprint
set = webnotes.conn.set
sql = webnotes.conn.sql
class DocType:

View File

@ -14,39 +14,49 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// ****************************************** onload ********************************************************
cur_frm.cscript.onload = function(doc, dt, dn) {
if(!doc.posting_date) set_multiple(dt,dn,{posting_date:get_today()});
}
cur_frm.cscript.refresh = function(doc, dt, dn) {
cur_frm.set_intro("");
if(doc.__islocal && !in_list(user_roles, "HR User")) {
cur_frm.set_intro("Fill the form and save it")
} else {
if(in_list(user_roles, "HR User")) {
if(doc.status=="Open") {
cur_frm.set_intro("Please Approve (and Submit) or Reject, or re-assign to applicant for further review.");
}
} else {
if(doc.status=="Open") {
cur_frm.set_intro("Leave application is pending approval.");
} else if(doc.status=="Approved") {
cur_frm.set_intro("Leave application has been approved.");
} else if(doc.status=="Rejected") {
cur_frm.set_intro("Leave application has been rejected.");
}
}
}
if(doc.status=="Approved" && doc.docstatus!=1) {
cur_frm.savesubmit()
}
}
// ************************************** client triggers ***************************************************
// ---------
// employee
// ---------
cur_frm.add_fetch('employee','employee_name','employee_name');
cur_frm.cscript.employee = function (doc, dt, dn){
get_leave_balance(doc, dt, dn);
}
// ------------
// fiscal_year
// ------------
cur_frm.cscript.fiscal_year = function (doc, dt, dn){
get_leave_balance(doc, dt, dn);
}
// -----------
// leave type
// -----------
cur_frm.cscript.leave_type = function (doc, dt, dn){
get_leave_balance(doc, dt, dn);
}
// ---------
// half day
// ---------
cur_frm.cscript.half_day = function(doc, dt, dn) {
if(doc.from_date) {
set_multiple(dt,dn,{to_date:doc.from_date});
@ -54,9 +64,6 @@ cur_frm.cscript.half_day = function(doc, dt, dn) {
}
}
// ---------
// from date
// ---------
cur_frm.cscript.from_date = function(doc, dt, dn) {
if(cint(doc.half_day) == 1){
set_multiple(dt,dn,{to_date:doc.from_date});
@ -64,9 +71,6 @@ cur_frm.cscript.from_date = function(doc, dt, dn) {
calculate_total_days(doc, dt, dn);
}
// --------
// to date
// --------
cur_frm.cscript.to_date = function(doc, dt, dn) {
if(cint(doc.half_day) == 1 && cstr(doc.from_date) && doc.from_date != doc.to_date){
msgprint("To Date should be same as From Date for Half Day leave");
@ -75,20 +79,11 @@ cur_frm.cscript.to_date = function(doc, dt, dn) {
calculate_total_days(doc, dt, dn);
}
// ******************************************* utilities ****************************************************
// ------------------
// get leave balance
// ------------------
get_leave_balance = function(doc, dt, dn) {
if(doc.employee && doc.leave_type && doc.fiscal_year)
get_server_fields('get_leave_balance', '','', doc, dt, dn, 1);
}
// ---------------
// calculate days
// ---------------
calculate_total_days = function(doc, dt, dn) {
if(doc.from_date && doc.to_date){
if(cint(doc.half_day) == 1) set_multiple(dt,dn,{total_leave_days:0.5});

View File

@ -14,36 +14,22 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import cint, cstr, date_diff, flt, formatdate, getdate
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.wrapper import copy_doclist
from webnotes import form, msgprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
import datetime
# -----------------------------------------------------------------------------------------
class DocType:
def __init__(self, doc, doclist):
self.doc = doc
self.doclist = doclist
# ******************************************** client triggers ***********************************************
# ------------------
# get leave balance
# ------------------
def get_leave_balance(self):
leave_all = sql("select total_leaves_allocated from `tabLeave Allocation` where employee = '%s' and leave_type = '%s' and fiscal_year = '%s' and docstatus = 1" % (self.doc.employee, self.doc.leave_type, self.doc.fiscal_year))
leave_all = leave_all and flt(leave_all[0][0]) or 0
@ -52,10 +38,6 @@ class DocType:
ret = {'leave_balance':leave_all - leave_app}
return ret
# ************************************************ utilities *************************************************
# -------------------
def get_holidays(self):
"""
get total holidays
@ -65,10 +47,6 @@ class DocType:
tot_hol = sql("select count(*) from `tabHoliday` h1, `tabHoliday List` h2 where h1.parent = h2.name and h1.holiday_date between '%s' and '%s' and ifnull(h2.is_default,0) = 1 and h2.fiscal_year = %s"% (self.doc.from_date, self.doc.to_date, self.doc.fiscal_year))
return tot_hol and flt(tot_hol[0][0]) or 0
# ---------------------
# get total leave days
# ---------------------
def get_total_leave_days(self):
"""
Calculates total leave days based on input and holidays
@ -82,27 +60,15 @@ class DocType:
}
return ret
# ************************************************ validate *************************************************
# -----------------
# validate to date
# -----------------
def validate_to_date(self):
if self.doc.from_date and self.doc.to_date and (getdate(self.doc.to_date) < getdate(self.doc.from_date)):
msgprint("To date cannot be before from date")
raise Exception
# --------------------------------
# check whether leave type is lwp
# --------------------------------
def is_lwp(self):
lwp = sql("select is_lwp from `tabLeave Type` where name = %s", self.doc.leave_type)
return lwp and cint(lwp[0][0]) or 0
# ------------------------
# validate balance leaves
# ------------------------
def validate_balance_leaves(self):
if self.doc.from_date and self.doc.to_date and not self.is_lwp():
bal = self.get_leave_balance()
@ -111,12 +77,8 @@ class DocType:
set(self.doc,'leave_balance',flt(bal['leave_balance']))
set(self.doc,'total_leave_days',flt(tot_leaves['total_leave_days']))
if flt(bal['leave_balance']) < flt(tot_leaves['total_leave_days']):
msgprint("Employee : %s cannot apply for %s of more than %s days" % (self.doc.employee, self.doc.leave_type, flt(bal['leave_balance'])))
raise Exception
msgprint("Warning : There is not enough leave balance")
#
# validate overlapping leaves
#
def validate_leave_overlap(self):
for d in sql("""select name, leave_type, posting_date, from_date, to_date
from `tabLeave Application`
@ -128,9 +90,6 @@ class DocType:
msgprint("Employee : %s has already applied for %s between %s and %s on %s. Please refer Leave Application : %s" % (self.doc.employee, cstr(d['leave_type']), formatdate(d['from_date']), formatdate(d['to_date']), formatdate(d['posting_date']), d['name']), raise_exception = 1)
# ---------------------------------------------------------------------
# validate max days for which leave can be applied for particular type
# ---------------------------------------------------------------------
def validate_max_days(self):
max_days = sql("select max_days_allowed from `tabLeave Type` where name = '%s'" %(self.doc.leave_type))
max_days = max_days and flt(max_days[0][0]) or 0
@ -138,12 +97,13 @@ class DocType:
msgprint("Sorry ! You cannot apply for %s for more than %s days" % (self.doc.leave_type, max_days))
raise Exception
# ---------
# validate
# ---------
def validate(self):
self.validate_to_date()
self.validate_balance_leaves()
self.validate_leave_overlap()
self.validate_max_days()
def on_submit(self):
if self.doc.status != "Approved":
webnotes.msgprint("""Only Approved Leave Applications can be Submitted.""",
raise_exception=True)

View File

@ -1,285 +1,239 @@
# DocType, Leave Application
[
# These values are common in all dictionaries
{
u'creation': '2012-05-15 12:14:45',
u'docstatus': 0,
u'modified': '2012-10-02 11:19:44',
u'modified_by': u'Administrator',
u'owner': u'Administrator'
},
# These values are common for all DocType
{
'_last_update': u'1310019491',
'autoname': u'LAP/.#####',
'colour': u'White:FFF',
u'doctype': u'DocType',
'document_type': u'Transaction',
'is_submittable': 1,
'module': u'HR',
u'name': u'__common__',
'search_fields': u'employee,employee_name,leave_type,from_date,to_date,total_leave_days,fiscal_year',
'section_style': u'Simple',
'show_in_menu': 0,
'subject': u'From %(employee_name)s, %(designation)s',
'tag_fields': u'leave_type',
'version': 1
},
# These values are common for all DocField
{
u'doctype': u'DocField',
u'name': u'__common__',
'parent': u'Leave Application',
'parentfield': u'fields',
'parenttype': u'DocType'
},
# These values are common for all DocPerm
{
u'doctype': u'DocPerm',
u'name': u'__common__',
'parent': u'Leave Application',
'parentfield': u'permissions',
'parenttype': u'DocType',
'read': 1
},
# DocType, Leave Application
{
u'doctype': u'DocType',
u'name': u'Leave Application'
},
# DocField
{
u'doctype': u'DocField',
'fieldname': u'column_break0',
'fieldtype': u'Column Break',
'permlevel': 0,
'width': u'50%'
},
# DocField
{
u'doctype': u'DocField',
'fieldname': u'employee',
'fieldtype': u'Link',
'in_filter': 1,
'label': u'Employee',
'options': u'Employee',
'permlevel': 0,
'reqd': 1,
'search_index': 1
},
# DocField
{
u'doctype': u'DocField',
'fieldname': u'employee_name',
'fieldtype': u'Data',
'in_filter': 1,
'label': u'Employee Name',
'permlevel': 1,
'search_index': 0
},
# DocField
{
u'doctype': u'DocField',
'fieldname': u'leave_type',
'fieldtype': u'Select',
'in_filter': 1,
'label': u'Leave Type',
'options': u'link:Leave Type',
'permlevel': 0,
'reqd': 1,
'search_index': 1
},
# DocField
{
u'doctype': u'DocField',
'fieldname': u'leave_balance',
'fieldtype': u'Currency',
'label': u'Leave Balance',
'permlevel': 1
},
# DocField
{
'colour': u'White:FFF',
'default': u'Today',
u'doctype': u'DocField',
'fieldname': u'posting_date',
'fieldtype': u'Date',
'label': u'Posting Date',
'no_copy': 1,
'permlevel': 1,
'reqd': 1
},
# DocField
{
u'doctype': u'DocField',
'fieldname': u'fiscal_year',
'fieldtype': u'Select',
'in_filter': 1,
'label': u'Fiscal Year',
'options': u'link:Fiscal Year',
'permlevel': 0,
'reqd': 1,
'search_index': 0
},
# DocField
{
u'doctype': u'DocField',
'fieldname': u'column_break1',
'fieldtype': u'Column Break',
'permlevel': 0,
'width': u'50%'
},
# DocField
{
'colour': u'White:FFF',
u'doctype': u'DocField',
'fieldname': u'half_day',
'fieldtype': u'Check',
'label': u'Half Day',
'permlevel': 0,
'trigger': u'Client'
},
# DocField
{
'colour': u'White:FFF',
u'doctype': u'DocField',
'fieldname': u'from_date',
'fieldtype': u'Date',
'label': u'From Date',
'permlevel': 0,
'search_index': 1,
'trigger': u'Client'
},
# DocField
{
'colour': u'White:FFF',
u'doctype': u'DocField',
'fieldname': u'to_date',
'fieldtype': u'Date',
'label': u'To Date',
'permlevel': 0,
'search_index': 1,
'trigger': u'Client'
},
# DocField
{
u'doctype': u'DocField',
'fieldname': u'total_leave_days',
'fieldtype': u'Currency',
'label': u'Total Leave Days',
'permlevel': 1
},
# DocField
{
u'doctype': u'DocField',
'fieldname': u'description',
'fieldtype': u'Small Text',
'label': u'Description',
'permlevel': 0,
'width': u'300px'
},
# DocField
{
u'doctype': u'DocField',
'fieldname': u'letter_head',
'fieldtype': u'Link',
'label': u'Letter Head',
'options': u'Letter Head',
'permlevel': 0
},
# DocField
{
u'doctype': u'DocField',
'fieldname': u'amended_from',
'fieldtype': u'Data',
'label': u'Amended From',
'permlevel': 1
},
# DocField
{
u'doctype': u'DocField',
'fieldname': u'amendment_date',
'fieldtype': u'Date',
'label': u'Amendment Date',
'permlevel': 1
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
u'doctype': u'DocPerm',
'match': u'owner',
'permlevel': 0,
'role': u'Employee',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 1,
'cancel': 1,
'create': 1,
u'doctype': u'DocPerm',
'permlevel': 0,
'role': u'HR User',
'submit': 1,
'write': 1
},
# DocPerm
{
'amend': 1,
'cancel': 1,
'create': 1,
u'doctype': u'DocPerm',
'permlevel': 0,
'role': u'HR Manager',
'submit': 1,
'write': 1
},
# DocPerm
{
u'doctype': u'DocPerm',
'permlevel': 1,
'role': u'HR User'
},
# DocPerm
{
u'doctype': u'DocPerm',
'permlevel': 1,
'role': u'HR Manager'
},
# DocPerm
{
u'doctype': u'DocPerm',
'permlevel': 1,
'role': u'Employee'
}
{
"owner": "Administrator",
"docstatus": 0,
"creation": "2012-11-02 17:16:54",
"modified_by": "Administrator",
"modified": "2012-11-30 12:17:27"
},
{
"is_submittable": 1,
"autoname": "LAP/.#####",
"name": "__common__",
"search_fields": "employee,employee_name,leave_type,from_date,to_date,total_leave_days,fiscal_year",
"module": "HR",
"doctype": "DocType",
"document_type": "Transaction"
},
{
"name": "__common__",
"parent": "Leave Application",
"doctype": "DocField",
"parenttype": "DocType",
"parentfield": "fields"
},
{
"name": "__common__",
"parent": "Leave Application",
"read": 1,
"doctype": "DocPerm",
"parenttype": "DocType",
"parentfield": "permissions"
},
{
"name": "Leave Application",
"doctype": "DocType"
},
{
"default": "Open",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Status",
"options": "Open\nApproved\nRejected",
"fieldname": "status",
"fieldtype": "Select",
"permlevel": 3
},
{
"search_index": 1,
"doctype": "DocField",
"label": "Leave Type",
"options": "link:Leave Type",
"fieldname": "leave_type",
"fieldtype": "Select",
"reqd": 1,
"permlevel": 0,
"in_filter": 1
},
{
"search_index": 1,
"colour": "White:FFF",
"doctype": "DocField",
"label": "From Date",
"trigger": "Client",
"fieldname": "from_date",
"fieldtype": "Date",
"reqd": 1,
"permlevel": 0
},
{
"search_index": 1,
"colour": "White:FFF",
"doctype": "DocField",
"label": "To Date",
"trigger": "Client",
"fieldname": "to_date",
"fieldtype": "Date",
"reqd": 1,
"permlevel": 0
},
{
"colour": "White:FFF",
"doctype": "DocField",
"label": "Half Day",
"trigger": "Client",
"fieldname": "half_day",
"fieldtype": "Check",
"permlevel": 0
},
{
"doctype": "DocField",
"width": "50%",
"fieldname": "column_break1",
"fieldtype": "Column Break",
"permlevel": 0
},
{
"doctype": "DocField",
"label": "Leave Balance",
"fieldname": "leave_balance",
"fieldtype": "Currency",
"permlevel": 1
},
{
"doctype": "DocField",
"label": "Total Leave Days",
"fieldname": "total_leave_days",
"fieldtype": "Currency",
"permlevel": 1
},
{
"search_index": 1,
"doctype": "DocField",
"label": "Employee",
"options": "Employee",
"fieldname": "employee",
"fieldtype": "Link",
"reqd": 1,
"permlevel": 0,
"in_filter": 1
},
{
"search_index": 0,
"doctype": "DocField",
"label": "Employee Name",
"fieldname": "employee_name",
"fieldtype": "Data",
"permlevel": 1,
"in_filter": 1
},
{
"doctype": "DocField",
"fieldname": "sb10",
"fieldtype": "Section Break",
"permlevel": 0
},
{
"doctype": "DocField",
"label": "Reason",
"width": "300px",
"fieldname": "description",
"fieldtype": "Text Editor",
"permlevel": 0
},
{
"doctype": "DocField",
"label": "HR Details",
"fieldname": "sb12",
"fieldtype": "Section Break",
"permlevel": 2
},
{
"default": "Today",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Posting Date",
"no_copy": 1,
"fieldname": "posting_date",
"fieldtype": "Date",
"reqd": 1,
"permlevel": 2
},
{
"search_index": 0,
"doctype": "DocField",
"label": "Fiscal Year",
"options": "link:Fiscal Year",
"fieldname": "fiscal_year",
"fieldtype": "Select",
"reqd": 1,
"permlevel": 2,
"in_filter": 1
},
{
"doctype": "DocField",
"label": "Letter Head",
"options": "Letter Head",
"fieldname": "letter_head",
"fieldtype": "Link",
"permlevel": 2
},
{
"doctype": "DocField",
"label": "Amended From",
"fieldname": "amended_from",
"fieldtype": "Data",
"permlevel": 2
},
{
"doctype": "DocField",
"label": "Amendment Date",
"fieldname": "amendment_date",
"fieldtype": "Date",
"permlevel": 2
},
{
"create": 1,
"doctype": "DocPerm",
"write": 1,
"role": "Employee",
"permlevel": 0,
"match": "employee"
},
{
"doctype": "DocPerm",
"role": "All",
"permlevel": 1
},
{
"amend": 1,
"create": 1,
"doctype": "DocPerm",
"submit": 1,
"write": 1,
"role": "HR User",
"cancel": 1,
"permlevel": 0
},
{
"amend": 0,
"create": 0,
"doctype": "DocPerm",
"submit": 0,
"write": 1,
"role": "HR User",
"cancel": 0,
"permlevel": 2
},
{
"doctype": "DocPerm",
"role": "All",
"permlevel": 3
},
{
"doctype": "DocPerm",
"write": 1,
"role": "HR User",
"permlevel": 3
}
]

View File

@ -3,6 +3,7 @@ wn.doclistviews['Leave Application'] = wn.views.ListView.extend({
init: function(d) {
this._super(d)
this.fields = this.fields.concat([
"`tabLeave Application`.status",
"`tabLeave Application`.employee_name",
"`tabLeave Application`.total_leave_days",
"`tabLeave Application`.from_date",
@ -12,8 +13,21 @@ wn.doclistviews['Leave Application'] = wn.views.ListView.extend({
this.stats = this.stats.concat(['company']);
},
label_style: {
"status": {
"Open": "danger",
"Approved": "success",
"Rejected": "info",
}
},
prepare_data: function(data) {
this._super(data);
data.label_style = this.label_style.status[data.status];
data.status_html = repl('<span class="label \
label-%(label_style)s">%(status)s</span>', data);
data.from_date = wn.datetime.str_to_user(data.from_date);
data.to_date = wn.datetime.str_to_user(data.to_date);
data.date_range = (data.from_date === data.to_date)
@ -28,10 +42,10 @@ wn.doclistviews['Leave Application'] = wn.views.ListView.extend({
{width: '3%', content: 'check'},
{width: '5%', content:'avatar'},
{width: '3%', content:'docstatus'},
{width: '15%', content:'status_html'},
{width: '12%', content:'name'},
{width: '37%', content:'employee_name+tags'},
{width: '10%', content:'total_leave_days',
css: {'color':'#777'}},
{width: '30%', content:'date_range'},
{width: '25%', content:'employee_name+tags'},
{width: '25%', content:'date_range'},
{width: '12%', content:'modified'},
]
});

View File

@ -14,24 +14,18 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import cint, cstr, flt, now, nowdate
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.doc import Document
from webnotes.model.wrapper import copy_doclist
from webnotes.model.code import get_obj
from webnotes import msgprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:

View File

@ -14,23 +14,18 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import cint, flt
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.doc import Document
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.code import get_obj
from webnotes import msgprint
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:

View File

@ -14,24 +14,18 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import add_days, cint, cstr, flt, getdate
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.doc import make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.code import get_obj
from webnotes import msgprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
from utilities.transaction_base import TransactionBase
class DocType(TransactionBase):

View File

@ -14,24 +14,17 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import cstr, flt
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.doc import addchild, make_autoname
from webnotes.model.wrapper import copy_doclist
from webnotes import msgprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:

View File

@ -1,6 +0,0 @@
from __future__ import unicode_literals
def execute():
import webnotes
webnotes.conn.commit()
webnotes.conn.sql("alter table __CacheItem modify `value` longtext")
webnotes.conn.begin()

View File

@ -21,7 +21,7 @@ from __future__ import unicode_literals
import webnotes
sql = webnotes.conn.sql
from webnotes.utils import cint, cstr
from webnotes.utils import cstr
def create_proper_index():
from webnotes.modules.export_file import export_to_files

View File

@ -2,7 +2,6 @@ from __future__ import unicode_literals
import webnotes
import conf
import webnotes.model
from webnotes.model.code import get_obj
from wnf import replace_code
from termcolor import colored
from webnotes.modules import reload_doc

View File

@ -16,7 +16,6 @@
from __future__ import unicode_literals
import webnotes
from webnotes.model.doc import Document
from webnotes.modules import reload_doc
def execute():

View File

@ -1,12 +0,0 @@
from __future__ import unicode_literals
def execute():
"""drop and create __CacheItem table again"""
import webnotes
webnotes.conn.commit()
webnotes.conn.sql("drop table __CacheItem")
webnotes.conn.sql("""create table __CacheItem(
`key` VARCHAR(180) NOT NULL PRIMARY KEY,
`value` LONGTEXT,
`expires_on` DATETIME
) ENGINE=MyISAM DEFAULT CHARSET=utf8""")
webnotes.conn.begin()

View File

@ -116,8 +116,8 @@ def create_file_list():
obj.make_file_list()
from webnotes.model.db_schema import updatedb
updatedb(obj.doc.name)
from webnotes.utils.cache import CacheItem
CacheItem(obj.doc.name).clear()
webnotes.clear_cache(doctype=obj.doc.name)
def change_to_decimal():
print "in change to decimal"

View File

@ -50,9 +50,8 @@ def move_customizations():
webnotes.conn.sql("""\
delete from `tabProperty Setter`
where doc_type='Communication Log'""")
from webnotes.utils.cache import CacheItem
CacheItem('Communication').clear()
webnotes.clear_cache(doctype="Communication")
def remove_communication_log():
import webnotes

View File

@ -0,0 +1,6 @@
import webnotes
def execute():
webnotes.clear_perms("Employee")
webnotes.reload_doc("hr", "doctype", "employee")
webnotes.conn.sql("""update tabEmployee set employee=name""")

View File

@ -0,0 +1,9 @@
import webnotes
def execute():
webnotes.clear_perms("Leave Application")
webnotes.reload_doc("hr", "doctype", "leave_application")
webnotes.conn.sql("""update `tabLeave Application` set status='Approved'
where docstatus=1""")
webnotes.conn.sql("""update `tabLeave Application` set status='Open'
where docstatus=0""")

View File

@ -0,0 +1,12 @@
def execute():
import webnotes
webnotes.reload_doc("production", "doctype", "production_order")
webnotes.reload_doc("stock", "doctype", "stock_entry")
webnotes.conn.sql("""update `tabProduction Order`
set use_multi_level_bom = if(consider_sa_items='Yes', 0, 1)""")
webnotes.conn.sql("""update `tabStock Entry`
set use_multi_level_bom = if(consider_sa_items_as_raw_materials='Yes', 0, 1)""")

View File

@ -278,11 +278,6 @@ patch_list = [
'patch_file': 'after_sync_cleanup',
'description': 'cleanup after sync'
},
{
'patch_module': 'patches.april_2012',
'patch_file': 'change_cacheitem_schema',
'description': 'Modified datatype of `value` column from text to longtext'
},
{
'patch_module': 'patches.april_2012',
'patch_file': 'remove_default_from_rv_detail',
@ -458,11 +453,6 @@ patch_list = [
'patch_file': 'delete_about_contact',
'description': "delete depracated doctypes of website module"
},
{
'patch_module': 'patches.june_2012',
'patch_file': 'cache_item_table',
'description': "create cache item table again"
},
{
'patch_module': 'patches.july_2012',
'patch_file': 'reload_pr_po_mapper',
@ -699,4 +689,16 @@ patch_list = [
'patch_module': 'patches.november_2012',
'patch_file': 'add_theme_to_profile',
},
{
'patch_module': 'patches.november_2012',
'patch_file': 'add_employee_field_in_employee',
},
{
'patch_module': 'patches.november_2012',
'patch_file': 'leave_application_cleanup',
},
{
'patch_module': 'patches.november_2012',
'patch_file': 'production_order_patch',
},
]

View File

@ -16,17 +16,14 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cint, cstr, flt, get_defaults, getdate, now, nowdate
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.utils import cint, cstr, flt, now, nowdate
from webnotes.model.doc import Document, addchild
from webnotes.model.wrapper import getlist
from webnotes.model.code import get_obj
from webnotes import msgprint, errprint
from webnotes import msgprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
# -----------------------------------------------------------------------------------------
class DocType:
def __init__(self, doc, doclist=[]):

View File

@ -14,24 +14,16 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cint, flt
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.wrapper import copy_doclist
from webnotes.model.code import get_obj
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:

View File

@ -14,24 +14,18 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import cstr, flt, get_defaults, now, nowdate
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.doc import Document
from webnotes.model.wrapper import copy_doclist
from webnotes.model.code import get_obj
from webnotes import msgprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:
@ -73,7 +67,7 @@ class DocType:
# Raise Production Order
def create_production_order(self,company, pp_items):
def create_production_order(self, items):
"""Create production order. Called from Production Planning Tool"""
default_values = {
@ -82,15 +76,20 @@ class DocType:
'wip_warehouse' : '',
'fg_warehouse' : '',
'status' : 'Draft',
'company' : company,
'fiscal_year' : get_defaults()['fiscal_year']
'fiscal_year' : get_defaults()['fiscal_year']
}
pro_list = []
for d in pp_items:
for item_so in items:
if item_so[1]:
self.validate_production_order_against_so(
item_so[0], item_so[1], items[item_so].get("qty"))
pro_doc = Document('Production Order')
for key in d.keys():
pro_doc.fields[key] = d[key]
pro_doc.production_item = item_so[0]
pro_doc.sales_order = item_so[1]
for key in items[item_so]:
pro_doc.fields[key] = items[item_so][key]
for key in default_values:
pro_doc.fields[key] = default_values[key]
@ -100,7 +99,30 @@ class DocType:
return pro_list
def validate_production_order_against_so(self, item, sales_order, qty, pro_order=None):
# already ordered qty
ordered_qty_against_so = webnotes.conn.sql("""select sum(qty) from `tabProduction Order`
where production_item = %s and sales_order = %s and name != %s""",
(item, sales_order, cstr(pro_order)))[0][0]
# qty including current
total_ordered_qty_against_so = flt(ordered_qty_against_so) + flt(qty)
# get qty from Sales Order Item table
so_item_qty = webnotes.conn.sql("""select sum(qty) from `tabSales Order Item`
where parent = %s and item_code = %s""", (sales_order, item))[0][0]
# get qty from Packing Item table
dnpi_qty = webnotes.conn.sql("""select sum(qty) from `tabDelivery Note Packing Item`
where parent = %s and parenttype = 'Sales Order' and item_code = %s""",
(sales_order, item))[0][0]
# total qty in SO
so_qty = flt(so_item_qty) + flt(dnpi_qty)
if total_ordered_qty_against_so > so_qty:
msgprint("""Total production order qty for item: %s against sales order: %s \
will be %s, which is greater than sales order qty (%s).
Please reduce qty or remove the item.""" %
(item, sales_order, total_ordered_qty_against_so, so_qty), raise_exception=1)
def update_bom(self, bom_no):
main_bom_list = self.traverse_bom_tree(bom_no, 1)
main_bom_list.reverse()
@ -113,4 +135,4 @@ class DocType:
bom_obj.update_flat_bom_engine()
bom_obj.doc.docstatus = 1
bom_obj.doc.save()
self.check_bom_list.append(bom)
self.check_bom_list.append(bom)

View File

@ -18,15 +18,7 @@
cur_frm.cscript.onload = function(doc, dt, dn) {
if (!doc.posting_date) doc.transaction_date = dateutil.obj_to_str(new Date());
if (!doc.status) doc.status = 'Draft';
cfn_set_fields(doc, dt, dn);
if (doc.origin != "MRP"){
doc.origin = "Manual";
set_field_permlevel('production_item', 0);
set_field_permlevel('bom_no', 0);
set_field_permlevel('consider_sa_items',0);
}
}
// ================================== Refresh ==========================================
@ -48,15 +40,10 @@ var cfn_set_fields = function(doc, dt, dn) {
}
}
// ==================================================================================================
cur_frm.cscript.production_item = function(doc, dt, dn) {
get_server_fields('get_item_detail',doc.production_item,'',doc,dt,dn,1);
}
// Stop PRODUCTION ORDER
//
cur_frm.cscript['Stop Production Order'] = function() {
var doc = cur_frm.doc;
var check = confirm("Do you really want to stop production order: " + doc.name);
@ -65,8 +52,6 @@ cur_frm.cscript['Stop Production Order'] = function() {
}
}
// Unstop PRODUCTION ORDER
//
cur_frm.cscript['Unstop Production Order'] = function() {
var doc = cur_frm.doc;
var check = confirm("Do really want to unstop production order: " + doc.name);
@ -97,8 +82,6 @@ cur_frm.cscript.make_se = function(doc, process) {
loaddoc('Stock Entry', se.name);
}
// ==================================================================================================
cur_frm.fields_dict['production_item'].get_query = function(doc) {
return 'SELECT DISTINCT `tabItem`.`name`, `tabItem`.`description` FROM `tabItem` WHERE (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` = "0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND `tabItem`.docstatus != 2 AND `tabItem`.is_pro_applicable = "Yes" AND `tabItem`.%(key)s LIKE "%s" ORDER BY `tabItem`.`name` LIMIT 50';
}

View File

@ -14,24 +14,18 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import cstr, flt, now, nowdate
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.doc import make_autoname
from webnotes.model.wrapper import copy_doclist
from webnotes.model.code import get_obj
from webnotes import msgprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:
@ -72,6 +66,14 @@ class DocType:
msgprint("""Incorrect BOM: %s entered.
May be BOM not exists or inactive or not submitted
or for some other item.""" % cstr(self.doc.bom_no), raise_exception=1)
if self.doc.sales_order:
if not webnotes.conn.sql("""select name from `tabSales Order`
where name=%s and docstatus = 1""", self.doc.sales_order):
msgprint("Sales Order: %s is not valid" % self.doc.sales_order, raise_exception=1)
get_obj("Production Control").validate_production_order_against_so(
self.doc.production_item, self.doc.sales_order, self.doc.qty, self.doc.name)
def stop_unstop(self, status):

View File

@ -1,358 +1,324 @@
# DocType, Production Order
[
# These values are common in all dictionaries
{
'creation': '2012-05-15 12:14:48',
'docstatus': 0,
'modified': '2012-05-28 19:03:56',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'_last_update': u'1325837006',
'colour': u'White:FFF',
'default_print_format': u'Standard',
'doctype': 'DocType',
'in_create': 0,
'is_submittable': 1,
'module': u'Production',
'name': '__common__',
'section_style': u'Tabbed',
'server_code_error': u' ',
'show_in_menu': 0,
'version': 1
},
# These values are common for all DocField
{
'doctype': u'DocField',
'name': '__common__',
'parent': u'Production Order',
'parentfield': u'fields',
'parenttype': u'DocType'
},
# These values are common for all DocPerm
{
'doctype': u'DocPerm',
'name': '__common__',
'parent': u'Production Order',
'parentfield': u'permissions',
'parenttype': u'DocType',
'read': 1
},
# DocType, Production Order
{
'doctype': 'DocType',
'name': u'Production Order'
},
# DocPerm
{
'amend': 1,
'cancel': 1,
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'System Manager',
'submit': 1,
'write': 1
},
# DocPerm
{
'doctype': u'DocPerm',
'permlevel': 1,
'role': u'All'
},
# DocPerm
{
'amend': 1,
'cancel': 1,
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Production Manager',
'submit': 1,
'write': 1
},
# DocPerm
{
'amend': 1,
'cancel': 1,
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Production User',
'submit': 1,
'write': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break0',
'fieldtype': u'Column Break',
'permlevel': 0,
'width': u'50%'
},
# DocField
{
'colour': u'White:FFF',
'description': u'Item for which this Production Order is raised.',
'doctype': u'DocField',
'fieldname': u'production_item',
'fieldtype': u'Link',
'in_filter': 1,
'label': u'Production Item',
'oldfieldname': u'production_item',
'oldfieldtype': u'Link',
'options': u'Item',
'permlevel': 1,
'reqd': 1,
'trigger': u'Client'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'description',
'fieldtype': u'Text',
'label': u'Description',
'oldfieldname': u'description',
'oldfieldtype': u'Text',
'permlevel': 0,
'width': u'300px'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'stock_uom',
'fieldtype': u'Data',
'label': u'Stock UOM',
'oldfieldname': u'stock_uom',
'oldfieldtype': u'Data',
'permlevel': 1
},
# DocField
{
'colour': u'White:FFF',
'description': u'Bill of Material which was considered for manufacturing the production item.',
'doctype': u'DocField',
'fieldname': u'bom_no',
'fieldtype': u'Link',
'label': u'BOM No',
'oldfieldname': u'bom_no',
'oldfieldtype': u'Link',
'options': u'BOM',
'permlevel': 1,
'reqd': 1,
'trigger': u'Client'
},
# DocField
{
'colour': u'White:FFF',
'description': u'Quantity of item for which Production Order is raised.',
'doctype': u'DocField',
'fieldname': u'qty',
'fieldtype': u'Currency',
'label': u'Qty',
'oldfieldname': u'qty',
'oldfieldtype': u'Currency',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'colour': u'White:FFF',
'description': u'The warehouse for finished goods where stock of produced items will be updated.',
'doctype': u'DocField',
'fieldname': u'fg_warehouse',
'fieldtype': u'Link',
'in_filter': 1,
'label': u'FG Warehouse',
'oldfieldname': u'fg_warehouse',
'oldfieldtype': u'Link',
'options': u'Warehouse',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'colour': u'White:FFF',
'description': u'The work in progress warehouse where raw materials will be operated upon to create finished goods.',
'doctype': u'DocField',
'fieldname': u'wip_warehouse',
'fieldtype': u'Link',
'in_filter': 1,
'label': u'WIP Warehouse',
'oldfieldname': u'wip_warehouse',
'oldfieldtype': u'Link',
'options': u'Warehouse',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'amended_from',
'fieldtype': u'Data',
'label': u'Amended From',
'no_copy': 1,
'oldfieldname': u'amended_from',
'oldfieldtype': u'Data',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'amendment_date',
'fieldtype': u'Date',
'label': u'Amendment Date',
'no_copy': 1,
'oldfieldname': u'amendment_date',
'oldfieldtype': u'Date',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break1',
'fieldtype': u'Column Break',
'oldfieldtype': u'Column Break',
'permlevel': 0,
'width': u'50%'
},
# DocField
{
'colour': u'White:FFF',
'description': u'The date on which current entry will get or has actually executed.',
'doctype': u'DocField',
'fieldname': u'posting_date',
'fieldtype': u'Date',
'label': u'Posting Date',
'oldfieldname': u'posting_date',
'oldfieldtype': u'Date',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'colour': u'White:FFF',
'description': u'Select "Yes" if stock is maintained and tracked for sub-assembly items. Select "No" if you want child items of sub-assembly for material transfer.',
'doctype': u'DocField',
'fieldname': u'consider_sa_items',
'fieldtype': u'Select',
'in_filter': 1,
'label': u'Consider SA Items as raw material',
'oldfieldname': u'consider_sa_items',
'oldfieldtype': u'Select',
'options': u'\nYes\nNo',
'permlevel': 1,
'reqd': 1
},
# DocField
{
'description': u'Select name of the project if Production Order need to be created against any project',
'doctype': u'DocField',
'fieldname': u'project_name',
'fieldtype': u'Link',
'in_filter': 1,
'label': u'Project Name',
'oldfieldname': u'project_name',
'oldfieldtype': u'Link',
'options': u'Project',
'permlevel': 0,
'trigger': u'Client'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'origin',
'fieldtype': u'Select',
'in_filter': 1,
'label': u'Origin',
'no_copy': 1,
'oldfieldname': u'origin',
'oldfieldtype': u'Select',
'options': u'Manual\nMRP',
'permlevel': 1,
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'status',
'fieldtype': u'Select',
'in_filter': 1,
'label': u'Status',
'no_copy': 1,
'oldfieldname': u'status',
'oldfieldtype': u'Select',
'options': u'\nDraft\nSubmitted\nStopped\nIn Process\nCompleted\nCancelled',
'permlevel': 1,
'reqd': 1,
'search_index': 1
},
# DocField
{
'colour': u'White:FFF',
'description': u'Updated after finished goods are transferred to FG Warehouse through Stock Entry',
'doctype': u'DocField',
'fieldname': u'produced_qty',
'fieldtype': u'Currency',
'label': u'Produced Qty',
'no_copy': 1,
'oldfieldname': u'produced_qty',
'oldfieldtype': u'Currency',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'company',
'fieldtype': u'Link',
'label': u'Company',
'oldfieldname': u'company',
'oldfieldtype': u'Link',
'options': u'Company',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'fiscal_year',
'fieldtype': u'Select',
'in_filter': 1,
'label': u'Fiscal Year',
'oldfieldname': u'fiscal_year',
'oldfieldtype': u'Select',
'options': u'link:Fiscal Year',
'permlevel': 0,
'reqd': 1
}
{
"owner": "Administrator",
"docstatus": 0,
"creation": "2012-07-03 13:30:03",
"modified_by": "Administrator",
"modified": "2012-11-30 14:28:03"
},
{
"is_submittable": 1,
"in_create": 0,
"default_print_format": "Standard",
"doctype": "DocType",
"module": "Production",
"name": "__common__"
},
{
"name": "__common__",
"parent": "Production Order",
"doctype": "DocField",
"parenttype": "DocType",
"parentfield": "fields"
},
{
"name": "__common__",
"parent": "Production Order",
"read": 1,
"doctype": "DocPerm",
"parenttype": "DocType",
"parentfield": "permissions"
},
{
"name": "Production Order",
"doctype": "DocType"
},
{
"doctype": "DocField",
"width": "50%",
"fieldname": "column_break0",
"fieldtype": "Column Break",
"permlevel": 0
},
{
"description": "Item for which this Production Order is raised.",
"oldfieldtype": "Link",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Production Item",
"oldfieldname": "production_item",
"permlevel": 0,
"trigger": "Client",
"fieldname": "production_item",
"fieldtype": "Link",
"reqd": 1,
"in_filter": 1,
"options": "Item"
},
{
"description": "Bill of Material which was considered for manufacturing the production item.",
"oldfieldtype": "Link",
"colour": "White:FFF",
"doctype": "DocField",
"label": "BOM No",
"oldfieldname": "bom_no",
"permlevel": 0,
"trigger": "Client",
"fieldname": "bom_no",
"fieldtype": "Link",
"reqd": 1,
"options": "BOM"
},
{
"description": "Quantity of item for which Production Order is raised.",
"oldfieldtype": "Currency",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Qty",
"oldfieldname": "qty",
"fieldname": "qty",
"fieldtype": "Currency",
"reqd": 1,
"permlevel": 0
},
{
"description": "The date on which current entry will get or has actually executed.",
"oldfieldtype": "Date",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Posting Date",
"oldfieldname": "posting_date",
"fieldname": "posting_date",
"fieldtype": "Date",
"reqd": 1,
"permlevel": 0
},
{
"oldfieldtype": "Column Break",
"doctype": "DocField",
"width": "50%",
"fieldname": "column_break1",
"fieldtype": "Column Break",
"permlevel": 0
},
{
"description": "The warehouse for finished goods where stock of produced items will be updated.",
"oldfieldtype": "Link",
"colour": "White:FFF",
"doctype": "DocField",
"label": "FG Warehouse",
"oldfieldname": "fg_warehouse",
"permlevel": 0,
"fieldname": "fg_warehouse",
"fieldtype": "Link",
"reqd": 1,
"in_filter": 1,
"options": "Warehouse"
},
{
"description": "The work in progress warehouse where raw materials will be operated upon to create finished goods.",
"oldfieldtype": "Link",
"colour": "White:FFF",
"doctype": "DocField",
"label": "WIP Warehouse",
"oldfieldname": "wip_warehouse",
"permlevel": 0,
"fieldname": "wip_warehouse",
"fieldtype": "Link",
"reqd": 1,
"in_filter": 1,
"options": "Warehouse"
},
{
"description": "If checked, BOM for sub-assembly items will be considered for getting raw materials. Otherwise, all sub-assembly items will be treated as a raw material.",
"default": "1",
"oldfieldtype": "Select",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Use Multi-Level BOM",
"oldfieldname": "consider_sa_items",
"fieldname": "use_multi_level_bom",
"fieldtype": "Check",
"reqd": 1,
"in_filter": 1,
"permlevel": 0
},
{
"description": "Updated after finished goods are transferred to FG Warehouse through Stock Entry",
"no_copy": 1,
"oldfieldtype": "Currency",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Produced Qty",
"oldfieldname": "produced_qty",
"fieldname": "produced_qty",
"fieldtype": "Currency",
"permlevel": 1
},
{
"doctype": "DocField",
"label": "More Info",
"fieldname": "more_info",
"fieldtype": "Section Break",
"permlevel": 0
},
{
"doctype": "DocField",
"width": "50%",
"fieldname": "column_break2",
"fieldtype": "Column Break",
"permlevel": 0
},
{
"no_copy": 1,
"oldfieldtype": "Select",
"doctype": "DocField",
"label": "Origin",
"oldfieldname": "origin",
"options": "Manual\nMRP",
"fieldname": "origin",
"fieldtype": "Select",
"reqd": 1,
"permlevel": 0,
"in_filter": 1
},
{
"no_copy": 1,
"oldfieldtype": "Select",
"doctype": "DocField",
"label": "Status",
"oldfieldname": "status",
"permlevel": 1,
"fieldname": "status",
"fieldtype": "Select",
"search_index": 1,
"reqd": 1,
"options": "\nDraft\nSubmitted\nStopped\nIn Process\nCompleted\nCancelled",
"in_filter": 1
},
{
"doctype": "DocField",
"label": "Sales Order",
"options": "Sales Order",
"fieldname": "sales_order",
"fieldtype": "Link",
"permlevel": 0
},
{
"description": "Select name of the project if Production Order need to be created against any project",
"oldfieldtype": "Link",
"label": "Project Name",
"oldfieldname": "project_name",
"trigger": "Client",
"fieldname": "project_name",
"fieldtype": "Link",
"doctype": "DocField",
"options": "Project",
"permlevel": 0,
"in_filter": 1
},
{
"oldfieldtype": "Link",
"doctype": "DocField",
"label": "Company",
"oldfieldname": "company",
"options": "Company",
"fieldname": "company",
"fieldtype": "Link",
"reqd": 1,
"permlevel": 0
},
{
"oldfieldtype": "Select",
"doctype": "DocField",
"label": "Fiscal Year",
"oldfieldname": "fiscal_year",
"options": "link:Fiscal Year",
"fieldname": "fiscal_year",
"fieldtype": "Select",
"reqd": 1,
"permlevel": 0,
"in_filter": 1
},
{
"no_copy": 1,
"oldfieldtype": "Data",
"doctype": "DocField",
"label": "Amended From",
"oldfieldname": "amended_from",
"fieldname": "amended_from",
"fieldtype": "Data",
"permlevel": 1
},
{
"no_copy": 1,
"oldfieldtype": "Date",
"doctype": "DocField",
"label": "Amendment Date",
"oldfieldname": "amendment_date",
"fieldname": "amendment_date",
"fieldtype": "Date",
"permlevel": 1
},
{
"doctype": "DocField",
"width": "50%",
"fieldname": "column_break3",
"fieldtype": "Column Break",
"permlevel": 0
},
{
"oldfieldtype": "Data",
"doctype": "DocField",
"label": "Stock UOM",
"oldfieldname": "stock_uom",
"fieldname": "stock_uom",
"fieldtype": "Data",
"permlevel": 1
},
{
"oldfieldtype": "Text",
"doctype": "DocField",
"label": "Production Item Description",
"oldfieldname": "description",
"width": "300px",
"fieldname": "description",
"fieldtype": "Text",
"permlevel": 0
},
{
"amend": 1,
"create": 1,
"doctype": "DocPerm",
"submit": 1,
"write": 1,
"role": "System Manager",
"cancel": 1,
"permlevel": 0
},
{
"doctype": "DocPerm",
"role": "All",
"permlevel": 1
},
{
"amend": 1,
"create": 1,
"doctype": "DocPerm",
"submit": 1,
"write": 1,
"role": "Production Manager",
"cancel": 1,
"permlevel": 0
},
{
"amend": 1,
"create": 1,
"doctype": "DocPerm",
"submit": 1,
"write": 1,
"role": "Production User",
"cancel": 1,
"permlevel": 0
}
]

View File

@ -1,159 +1,109 @@
# DocType, Production Plan Item
[
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:36:03',
'docstatus': 0,
'modified': '2012-03-27 14:36:03',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'autoname': u'PPID/.#####',
'colour': u'White:FFF',
'default_print_format': u'Standard',
'doctype': 'DocType',
'istable': 1,
'module': u'Production',
'name': '__common__',
'section_style': u'Simple',
'server_code_error': u' ',
'show_in_menu': 0,
'version': 27
},
# These values are common for all DocField
{
'doctype': u'DocField',
'name': '__common__',
'parent': u'Production Plan Item',
'parentfield': u'fields',
'parenttype': u'DocType'
},
# DocType, Production Plan Item
{
'doctype': 'DocType',
'name': u'Production Plan Item'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'sales_order',
'fieldtype': u'Data',
'label': u'Sales Order',
'oldfieldname': u'source_docname',
'oldfieldtype': u'Data',
'permlevel': 1
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'item_code',
'fieldtype': u'Link',
'label': u'Item Code',
'oldfieldname': u'item_code',
'oldfieldtype': u'Link',
'options': u'Item',
'permlevel': 0,
'reqd': 1,
'trigger': u'Client',
'width': u'150px'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'bom_no',
'fieldtype': u'Link',
'label': u'BOM No',
'oldfieldname': u'bom_no',
'oldfieldtype': u'Link',
'options': u'BOM',
'permlevel': 0,
'reqd': 1,
'width': u'100px'
},
# DocField
{
'default': u'0.00',
'doctype': u'DocField',
'fieldname': u'so_pending_qty',
'fieldtype': u'Currency',
'label': u'SO Pending Qty',
'oldfieldname': u'prevdoc_reqd_qty',
'oldfieldtype': u'Currency',
'permlevel': 1,
'reqd': 0,
'width': u'100px'
},
# DocField
{
'default': u'0.00',
'doctype': u'DocField',
'fieldname': u'planned_qty',
'fieldtype': u'Currency',
'label': u'Planned Qty',
'oldfieldname': u'planned_qty',
'oldfieldtype': u'Currency',
'permlevel': 0,
'reqd': 1,
'width': u'100px'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'stock_uom',
'fieldtype': u'Data',
'label': u'UOM',
'oldfieldname': u'stock_uom',
'oldfieldtype': u'Data',
'permlevel': 1,
'reqd': 1,
'width': u'80px'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'description',
'fieldtype': u'Text',
'label': u'Description',
'oldfieldname': u'description',
'oldfieldtype': u'Text',
'permlevel': 1,
'width': u'200px'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'parent_packing_item',
'fieldtype': u'Link',
'label': u'Parent Packing Item',
'oldfieldname': u'parent_item',
'oldfieldtype': u'Link',
'options': u'Item',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'is_pro_created',
'fieldtype': u'Check',
'label': u'Is PRO Created',
'oldfieldname': u'pro_created',
'oldfieldtype': u'Check',
'permlevel': 1
}
{
"owner": "Administrator",
"docstatus": 0,
"creation": "2012-07-03 13:30:04",
"modified_by": "Administrator",
"modified": "2012-11-29 19:02:38"
},
{
"istable": 1,
"autoname": "PPID/.#####",
"name": "__common__",
"default_print_format": "Standard",
"doctype": "DocType",
"module": "Production"
},
{
"name": "__common__",
"parent": "Production Plan Item",
"doctype": "DocField",
"parenttype": "DocType",
"parentfield": "fields"
},
{
"name": "Production Plan Item",
"doctype": "DocType"
},
{
"permlevel": 0,
"oldfieldtype": "Link",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Item Code",
"oldfieldname": "item_code",
"width": "150px",
"trigger": "Client",
"fieldname": "item_code",
"fieldtype": "Link",
"reqd": 1,
"options": "Item"
},
{
"oldfieldtype": "Link",
"doctype": "DocField",
"label": "BOM No",
"oldfieldname": "bom_no",
"width": "100px",
"options": "BOM",
"fieldname": "bom_no",
"fieldtype": "Link",
"reqd": 1,
"permlevel": 0
},
{
"default": "0.00",
"oldfieldtype": "Currency",
"doctype": "DocField",
"label": "Planned Qty",
"oldfieldname": "planned_qty",
"width": "100px",
"fieldname": "planned_qty",
"fieldtype": "Currency",
"reqd": 1,
"permlevel": 0
},
{
"oldfieldtype": "Data",
"doctype": "DocField",
"label": "Sales Order",
"oldfieldname": "source_docname",
"options": "Sales Order",
"fieldname": "sales_order",
"fieldtype": "Link",
"permlevel": 1
},
{
"default": "0.00",
"oldfieldtype": "Currency",
"doctype": "DocField",
"label": "SO Pending Qty",
"oldfieldname": "prevdoc_reqd_qty",
"width": "100px",
"fieldname": "so_pending_qty",
"fieldtype": "Currency",
"reqd": 0,
"permlevel": 1
},
{
"oldfieldtype": "Data",
"doctype": "DocField",
"label": "UOM",
"oldfieldname": "stock_uom",
"width": "80px",
"fieldname": "stock_uom",
"fieldtype": "Data",
"reqd": 1,
"permlevel": 1
},
{
"oldfieldtype": "Text",
"doctype": "DocField",
"label": "Description",
"oldfieldname": "description",
"width": "200px",
"fieldname": "description",
"fieldtype": "Text",
"permlevel": 1
}
]

View File

@ -1,124 +1,84 @@
# DocType, Production Plan Sales Order
[
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:36:04',
'docstatus': 0,
'modified': '2012-03-27 14:36:04',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'autoname': u'PP/.SO/.#####',
'colour': u'White:FFF',
'default_print_format': u'Standard',
'doctype': 'DocType',
'istable': 1,
'module': u'Production',
'name': '__common__',
'section_style': u'Simple',
'server_code_error': u' ',
'show_in_menu': 0,
'version': 5
},
# These values are common for all DocField
{
'doctype': u'DocField',
'name': '__common__',
'parent': u'Production Plan Sales Order',
'parentfield': u'fields',
'parenttype': u'DocType'
},
# These values are common for all DocPerm
{
'doctype': u'DocPerm',
'name': '__common__',
'parent': u'Production Plan Sales Order',
'parentfield': u'permissions',
'parenttype': u'DocType',
'read': 1,
'role': u'System Manager'
},
# DocType, Production Plan Sales Order
{
'doctype': 'DocType',
'name': u'Production Plan Sales Order'
},
# DocPerm
{
'doctype': u'DocPerm',
'permlevel': 0,
'write': 1
},
# DocPerm
{
'doctype': u'DocPerm',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'sales_order',
'fieldtype': u'Link',
'label': u'Sales Order',
'oldfieldname': u'prevdoc_docname',
'oldfieldtype': u'Data',
'options': u'Sales Order',
'permlevel': 0,
'width': u'150px'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'sales_order_date',
'fieldtype': u'Date',
'label': u'Sales Order Date',
'oldfieldname': u'document_date',
'oldfieldtype': u'Date',
'permlevel': 1,
'width': u'100px'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'customer',
'fieldtype': u'Link',
'label': u'Customer',
'options': u'Customer',
'permlevel': 1,
'width': u'150px'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'grand_total',
'fieldtype': u'Currency',
'label': u'Grand Total',
'permlevel': 1,
'width': u'100px'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'include_in_plan',
'fieldtype': u'Check',
'label': u'Include In Plan',
'oldfieldname': u'include_in_plan',
'oldfieldtype': u'Check',
'permlevel': 0,
'width': u'100px'
}
{
"owner": "Administrator",
"docstatus": 0,
"creation": "2012-07-03 13:30:04",
"modified_by": "Administrator",
"modified": "2012-11-29 17:49:15"
},
{
"istable": 1,
"autoname": "PP/.SO/.#####",
"name": "__common__",
"default_print_format": "Standard",
"doctype": "DocType",
"module": "Production"
},
{
"name": "__common__",
"parent": "Production Plan Sales Order",
"doctype": "DocField",
"parenttype": "DocType",
"parentfield": "fields"
},
{
"name": "__common__",
"parent": "Production Plan Sales Order",
"read": 1,
"doctype": "DocPerm",
"parenttype": "DocType",
"role": "System Manager",
"parentfield": "permissions"
},
{
"name": "Production Plan Sales Order",
"doctype": "DocType"
},
{
"oldfieldtype": "Data",
"doctype": "DocField",
"label": "Sales Order",
"oldfieldname": "prevdoc_docname",
"width": "150px",
"options": "Sales Order",
"fieldname": "sales_order",
"fieldtype": "Link",
"permlevel": 0
},
{
"oldfieldtype": "Date",
"doctype": "DocField",
"label": "SO Date",
"oldfieldname": "document_date",
"width": "120px",
"fieldname": "sales_order_date",
"fieldtype": "Date",
"permlevel": 1
},
{
"doctype": "DocField",
"label": "Customer",
"width": "150px",
"options": "Customer",
"fieldname": "customer",
"fieldtype": "Link",
"permlevel": 1
},
{
"doctype": "DocField",
"label": "Grand Total",
"width": "120px",
"fieldname": "grand_total",
"fieldtype": "Currency",
"permlevel": 1
},
{
"write": 1,
"doctype": "DocPerm",
"permlevel": 0
},
{
"doctype": "DocPerm",
"permlevel": 1
}
]

View File

@ -14,11 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
cur_frm.cscript.item_code = function(doc,cdt,cdn) {
var d = locals[cdt][cdn];
if (d.item_code) {
get_server_fields('get_item_details', d.item_code, 'pp_details', doc, cdt, cdn, 1);
}
cur_frm.cscript.onload = function(doc, cdt, cdn) {
doc.company = sys_defaults.company;
refresh_field("company");
}
cur_frm.cscript.sales_order = function(doc,cdt,cdn) {
@ -28,25 +26,35 @@ cur_frm.cscript.sales_order = function(doc,cdt,cdn) {
}
}
cur_frm.cscript.download_raw_material = function(doc, cdt, cdn) {
var callback = function(r, rt){
if (r.message)
$c_obj_csv(make_doclist(cdt, cdn), 'download_raw_materials', '', '');
cur_frm.cscript.item_code = function(doc,cdt,cdn) {
var d = locals[cdt][cdn];
if (d.item_code) {
get_server_fields('get_item_details', d.item_code, 'pp_details', doc, cdt, cdn, 1);
}
$c_obj(make_doclist(cdt, cdn), 'validate_data', '', callback)
}
//-------------------------------------------------------------------------------
//
cur_frm.cscript.download_materials_required = function(doc, cdt, cdn) {
$c_obj(make_doclist(cdt, cdn), 'validate_data', '', function(r, rt) {
if (!r['exc'])
$c_obj_csv(make_doclist(cdt, cdn), 'download_raw_materials', '', '');
});
}
cur_frm.fields_dict['pp_details'].grid.get_field('item_code').get_query = function(doc) {
return 'SELECT DISTINCT `tabItem`.`name`,`tabItem`.`item_name` FROM `tabItem` WHERE (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life`="0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND `tabItem`.is_pro_applicable = "Yes" AND tabItem.%(key)s like "%s" ORDER BY `tabItem`.`name` LIMIT 50';
return 'SELECT DISTINCT `tabItem`.`name`,`tabItem`.`item_name` \
FROM `tabItem` WHERE `tabItem`.is_pro_applicable = "Yes" \
AND (IFNULL(`tabItem`.`end_of_life`,"") = "" \
OR `tabItem`.`end_of_life`="0000-00-00" OR `tabItem`.`end_of_life` > NOW()) \
AND tabItem.%(key)s like "%s" \
ORDER BY `tabItem`.`name` LIMIT 50';
}
cur_frm.fields_dict['pp_details'].grid.get_field('bom_no').get_query = function(doc) {
var d = locals[this.doctype][this.docname];
return 'SELECT DISTINCT `tabBOM`.`name` FROM `tabBOM` WHERE `tabBOM`.`item` = "' + d.item_code + '" AND `tabBOM`.`is_active` = "Yes" AND `tabBOM`.docstatus = 1 AND `tabBOM`.`name` like "%s" ORDER BY `tabBOM`.`name` LIMIT 50';
var d = locals[this.doctype][this.docname];
return 'SELECT DISTINCT `tabBOM`.`name` \
FROM `tabBOM` WHERE `tabBOM`.`item` = "' + d.item_code +
'" AND `tabBOM`.`is_active` = "Yes" AND `tabBOM`.docstatus = 1 \
AND `tabBOM`.`name` like "%s" ORDER BY `tabBOM`.`name` LIMIT 50';
}
cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query;

View File

@ -16,158 +16,142 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cint, cstr, flt, getdate, now, nowdate
from webnotes.utils import cstr, flt
from webnotes.model.doc import addchild
from webnotes.model.wrapper import getlist
from webnotes.model.code import get_obj
from webnotes import msgprint, errprint
from webnotes import msgprint
sql = webnotes.conn.sql
# -----------------------------------------------------------------------------------------
class DocType:
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
self.item_dict = {}
def get_so_details(self, so):
"""Pull other details from so"""
so = sql("""select transaction_date, customer, grand_total
from `tabSales Order` where name = %s""", so, as_dict = 1)
ret = {
'sales_order_date': so and so[0]['transaction_date'] or '',
'customer' : so[0]['customer'] or '',
'grand_total': so[0]['grand_total']
}
return ret
def get_item_details(self, item_code):
""" Pull other item details from item master"""
item = sql("""select description, stock_uom, default_bom from `tabItem` where name = %s
and (ifnull(end_of_life,'')='' or end_of_life = '0000-00-00' or end_of_life > now())""", item_code, as_dict =1 )
item = sql("""select description, stock_uom, default_bom
from `tabItem` where name = %s""", item_code, as_dict =1)
ret = {
'description' : item and item[0]['description'],
'stock_uom' : item and item[0]['stock_uom'],
'bom_no' : item and item[0]['default_bom']
}
return ret
def get_so_details(self, so):
"""Pull other details from so"""
so = sql("select transaction_date, customer, grand_total from `tabSales Order` where name = %s", so, as_dict = 1)
ret = {
'sales_order_date': so and so[0]['transaction_date'] or '',
'customer' : so[0]['customer'] or '',
'grand_total': so[0]['grand_total']
}
return ret
def clear_so_table(self):
""" Clears sales order table"""
self.doclist = self.doc.clear_table(self.doclist, 'pp_so_details')
def clear_item_table(self):
""" Clears item table"""
self.doclist = self.doc.clear_table(self.doclist, 'pp_details')
def get_open_sales_orders(self):
""" Pull sales orders which are pending to deliver based on criteria selected"""
cond = self.get_filter_condition()
open_so = sql("""
select
distinct t1.name, t1.transaction_date, t1.customer, t1.grand_total
from
`tabSales Order` t1, `tabSales Order Item` t2, `tabDelivery Note Packing Item` t3, tabItem t4
where
t1.name = t2.parent and t1.name = t3.parent and t3.parenttype = 'Sales Order' and t1.docstatus = 1 and t2.item_code = t3.parent_item
and t4.name = t3.item_code and t1.status != 'Stopped' and t1.company = '%s' and ifnull(t2.qty, 0) > ifnull(t2.delivered_qty, 0)
and (ifnull(t4.is_pro_applicable, 'No') = 'Yes' or ifnull(t4.is_sub_contracted_item, 'No') = 'Yes') %s
order by t1.name desc
"""% (self.doc.company, cond), as_dict = 1)
self.add_so_in_table(open_so)
def validate_company(self):
if not self.doc.company:
msgprint("Please enter Company", raise_exception=1)
def get_filter_condition(self):
self.validate_company()
cond = ''
def get_open_sales_orders(self):
""" Pull sales orders which are pending to deliver based on criteria selected"""
so_filter = item_filter = ""
if self.doc.from_date:
cond += ' and t1.transaction_date >= "' + self.doc.from_date + '"'
so_filter += ' and so.transaction_date >= "' + self.doc.from_date + '"'
if self.doc.to_date:
cond += ' and t1.transaction_date <= "' + self.doc.to_date + '"'
so_filter += ' and so.transaction_date <= "' + self.doc.to_date + '"'
if self.doc.customer:
cond += ' and t1.customer = "' + self.doc.customer + '"'
so_filter += ' and so.customer = "' + self.doc.customer + '"'
if self.doc.fg_item:
cond += ' and t3.item_code = "' + self.doc.fg_item + '"'
return cond
item_filter += ' and item.name = "' + self.doc.fg_item + '"'
open_so = sql("""
select distinct so.name, so.transaction_date, so.customer, so.grand_total
from `tabSales Order` so, `tabSales Order Item` so_item
where so_item.parent = so.name
and so.docstatus = 1 and so.status != "Stopped"
and so.company = 'Web Notes Technologies Pvt Ltd'
and ifnull(so_item.qty, 0) > ifnull(so_item.delivered_qty, 0) %s
and (exists (select * from `tabItem` item where item.name=so_item.item_code
and (ifnull(item.is_pro_applicable, 'No') = 'Yes'
or ifnull(item.is_sub_contracted_item, 'No') = 'Yes') %s)
or exists (select * from `tabDelivery Note Packing Item` dnpi
where dnpi.parent = so.name and dnpi.parent_item = so_item.item_code
and exists (select * from `tabItem` item where item.name=dnpi.item_code
and (ifnull(item.is_pro_applicable, 'No') = 'Yes'
or ifnull(item.is_sub_contracted_item, 'No') = 'Yes') %s)))
""" % (so_filter, item_filter, item_filter), as_dict=1)
self.add_so_in_table(open_so)
def add_so_in_table(self, open_so):
""" Add sales orders in the table"""
so_list = []
for d in getlist(self.doclist, 'pp_so_details'):
so_list.append(d.sales_order)
so_list = [d.sales_order for d in getlist(self.doclist, 'pp_so_details')]
for r in open_so:
if cstr(r['name']) not in so_list:
pp_so = addchild(self.doc, 'pp_so_details', 'Production Plan Sales Order', 1, self.doclist)
pp_so = addchild(self.doc, 'pp_so_details',
'Production Plan Sales Order', 1, self.doclist)
pp_so.sales_order = r['name']
pp_so.sales_order_date = cstr(r['transaction_date'])
pp_so.customer = cstr(r['customer'])
pp_so.grand_total = flt(r['grand_total'])
def get_items_from_so(self):
""" Pull items from Sales Order, only proction item
and subcontracted item will be pulled from Packing item
and add items in the table
"""
so = self.get_included_so()
items = self.get_packing_items(so)
items = self.get_items()
self.add_items(items)
def get_items(self):
so_list = filter(None, [d.sales_order for d in getlist(self.doclist, 'pp_so_details')])
if not so_list:
msgprint("Please enter sales order in the above table", raise_exception=1)
items = sql("""select distinct parent, item_code,
(qty - ifnull(delivered_qty, 0)) as pending_qty
from `tabSales Order Item` so_item
where parent in (%s) and docstatus = 1 and ifnull(qty, 0) > ifnull(delivered_qty, 0)
and exists (select * from `tabItem` item where item.name=so_item.item_code
and (ifnull(item.is_pro_applicable, 'No') = 'Yes'
or ifnull(item.is_sub_contracted_item, 'No') = 'Yes'))""" % \
(", ".join(["%s"] * len(so_list))), tuple(so_list), as_dict=1)
dnpi_items = sql("""select distinct dnpi.parent, dnpi.item_code,
(((so_item.qty - ifnull(so_item.delivered_qty, 0)) * dnpi.qty) / so_item.qty)
as pending_qty
from `tabSales Order Item` so_item, `tabDelivery Note Packing Item` dnpi
where so_item.parent = dnpi.parent and so_item.docstatus = 1
and dnpi.parent_item = so_item.item_code
and so_item.parent in (%s) and ifnull(so_item.qty, 0) > ifnull(so_item.delivered_qty, 0)
and exists (select * from `tabItem` item where item.name=dnpi.item_code
and (ifnull(item.is_pro_applicable, 'No') = 'Yes'
or ifnull(item.is_sub_contracted_item, 'No') = 'Yes'))""" % \
(", ".join(["%s"] * len(so_list))), tuple(so_list), as_dict=1)
def get_included_so(self):
so = "'" + "','".join([cstr(d.sales_order) for d in getlist(self.doclist, 'pp_so_details') if d.include_in_plan]) + "'"
return so
def get_packing_items(self, so):
packing_items = sql("""
select
t0.name, t2.parent_item, t2.item_code,
(t1.qty - ifnull(t1.delivered_qty,0)) * (ifnull(t2.qty,0) / ifnull(t1.qty,1)) as 'pending_qty'
from
`tabSales Order` t0, `tabSales Order Item` t1, `tabDelivery Note Packing Item` t2, `tabItem` t3
where
t0.name = t1.parent and t0.name = t2.parent and t1.name = t2.parent_detail_docname
and t0.name in (%s) and t0.docstatus = 1 and t1.qty > ifnull(t1.delivered_qty,0) and t3.name = t2.item_code
and (ifnull(t3.is_pro_applicable, 'No') = 'Yes' or ifnull(t3.is_sub_contracted_item, 'No') = 'Yes')
""" % so, as_dict=1)
return packing_items
return items + dnpi_items
def add_items(self, items):
self.clear_item_table()
def add_items(self, packing_items):
for d in getlist(self.doclist, 'pp_details'):
if d.sales_order:
d.parent = ''
for p in packing_items:
item_details = sql("select description, stock_uom, default_bom from tabItem where name=%s", p['item_code'])
for p in items:
item_details = sql("""select description, stock_uom, default_bom
from tabItem where name=%s""", p['item_code'])
pi = addchild(self.doc, 'pp_details', 'Production Plan Item', 1, self.doclist)
pi.sales_order = p['name']
pi.parent_packing_item = p['parent_item']
pi.sales_order = p['parent']
pi.item_code = p['item_code']
pi.description = item_details and item_details[0][0] or ''
pi.stock_uom = item_details and item_details[0][1] or ''
@ -176,129 +160,112 @@ class DocType:
pi.planned_qty = flt(p['pending_qty'])
def validate_data(self):
for d in getlist(self.doclist, 'pp_details'):
if not d.pro_created:
self.validate_bom_no(d)
if not flt(d.planned_qty):
msgprint("Please Enter Planned Qty for item: %s at row no: %s"% (d.item_code, d.idx), raise_exception=1)
return 'validated'
self.validate_bom_no(d)
if not flt(d.planned_qty):
msgprint("Please Enter Planned Qty for item: %s at row no: %s" %
(d.item_code, d.idx), raise_exception=1)
def validate_bom_no(self, d):
if not d.bom_no:
msgprint("Please enter bom no for item: %s at row no: %s" % (d.item_code, d.idx), raise_exception=1)
msgprint("Please enter bom no for item: %s at row no: %s" %
(d.item_code, d.idx), raise_exception=1)
else:
bom = sql("""select name from `tabBOM` where item = %s and docstatus = 1
and name = %s and ifnull(is_active, 'No') = 'Yes'""", (d.item_code, d.bom_no), as_dict = 1)
bom = sql("""select name from `tabBOM` where name = %s and item = %s
and docstatus = 1 and ifnull(is_active, 'No') = 'Yes'""",
(d.bom_no, d.item_code), as_dict = 1)
if not bom:
msgprint("""Incorrect BOM No: %s entered for item: %s at row no: %s
May be BOM is inactive or for other item or does not exists in the system"""% (d.bom_no, d.item_doce, d.idx))
May be BOM is inactive or for other item or does not exists in the system""" %
(d.bom_no, d.item_doce, d.idx), raise_exception=1)
def raise_production_order(self):
"""It will raise production order (Draft) for all distinct FG items"""
self.validate_company()
self.validate_data()
items = self.get_distinct_items_and_boms()[1]
pro = get_obj('Production Control').create_production_order(items)
if pro:
msgprint("Following Production Order has been generated:\n" + '\n'.join(pro))
else :
msgprint("No Production Order generated.")
def get_distinct_items_and_boms(self):
""" Club similar BOM and item for processing"""
item_dict, bom_dict = {}, {}
for d in self.doclist.get({"parentfield": "pp_details"}):
bom_dict[d.bom_no] = bom_dict.get(d.bom_no, 0) + flt(d.planned_qty)
item_dict[(d.item_code, d.sales_order)] = {
"qty" : flt(item_dict.get((d.item_code, d.sales_order), {}).get("qty")) + \
flt(d.planned_qty),
"bom_no": d.bom_no,
"description": d.description,
"stock_uom": d.stock_uom,
"use_multi_level_bom": self.doc.use_multi_level_bom,
"company": self.doc.company,
}
return bom_dict, item_dict
def download_raw_materials(self):
""" Create csv data for required raw material to produce finished goods"""
bom_dict = self.get_distinct_bom(action = 'download_rm')
bom_dict = self.get_distinct_items_and_boms()[0]
self.get_raw_materials(bom_dict)
return self.get_csv()
def get_raw_materials(self, bom_dict):
""" Get raw materials considering sub-assembly items """
for bom in bom_dict:
if self.doc.consider_sa_items == 'Yes':
if self.doc.use_multi_level_bom:
# get all raw materials with sub assembly childs
fl_bom_items = sql("""
select
item_code,ifnull(sum(qty_consumed_per_unit),0)*%s as qty,
description, stock_uom
from
(
select distinct fb.name, fb.description, fb.item_code,
fb.qty_consumed_per_unit, fb.stock_uom
from `tabBOM Explosion Item` fb,`tabItem` it
where it.name = fb.item_code
and ifnull(it.is_pro_applicable, 'No') = 'No'
and ifnull(it.is_sub_contracted_item, 'No') = 'No'
and fb.docstatus<2 and fb.parent=%s
) a
group by item_code,stock_uom
""" , (flt(bom_dict[bom]), bom))
else:
# Get all raw materials considering SA items as raw materials,
# so no childs of SA items
fl_bom_items = sql("""
select item_code, ifnull(sum(qty_consumed_per_unit), 0) * '%s', description, stock_uom
select item_code, ifnull(sum(qty_consumed_per_unit), 0) * '%s',
description, stock_uom
from `tabBOM Item`
where parent = '%s' and docstatus < 2
group by item_code
""" % (flt(bom_dict[bom]), bom))
else:
# get all raw materials with sub assembly childs
fl_bom_items = sql("""
select
item_code,ifnull(sum(qty_consumed_per_unit),0)*%s as qty, description, stock_uom
from
(
select distinct fb.name, fb.description, fb.item_code, fb.qty_consumed_per_unit, fb.stock_uom
from `tabBOM Explosion Item` fb,`tabItem` it
where it.name = fb.item_code and ifnull(it.is_pro_applicable, 'No') = 'No'
and ifnull(it.is_sub_contracted_item, 'No') = 'No' and fb.docstatus<2 and fb.parent=%s
) a
group by item_code,stock_uom
""" , (flt(bom_dict[bom]), bom))
self.make_items_dict(fl_bom_items)
def make_items_dict(self, item_list):
for i in item_list:
self.item_dict[i[0]] = [(flt(self.item_dict.get(i[0], [0])[0]) + flt(i[1])), i[2], i[3]]
def get_csv(self):
item_list = [['Item Code', 'Description', 'Stock UOM', 'Required Qty', 'Warehouse', 'Quantity Requested for Purchase', 'Ordered Qty', 'Actual Qty']]
item_list = [['Item Code', 'Description', 'Stock UOM', 'Required Qty', 'Warehouse',
'Quantity Requested for Purchase', 'Ordered Qty', 'Actual Qty']]
for d in self.item_dict:
item_list.append([d, self.item_dict[d][1], self.item_dict[d][2], self.item_dict[d][0]]),
item_qty= sql("select warehouse, indented_qty, ordered_qty, actual_qty from `tabBin` where item_code = %s", d)
i_qty, o_qty, a_qty = 0,0,0
item_list.append([d, self.item_dict[d][1], self.item_dict[d][2], self.item_dict[d][0]])
item_qty= sql("""select warehouse, indented_qty, ordered_qty, actual_qty
from `tabBin` where item_code = %s""", d)
i_qty, o_qty, a_qty = 0, 0, 0
for w in item_qty:
i_qty, o_qty, a_qty = i_qty + flt(w[1]), o_qty + flt(w[2]), a_qty + flt(w[3])
item_list.append(['', '', '', '', w[0], flt(w[1]), flt(w[2]), flt(w[3])])
if item_qty:
item_list.append(['', '', '', '', 'Total', i_qty, o_qty, a_qty])
return item_list
def raise_production_order(self):
"""It will raise production order (Draft) for all distinct FG items"""
self.validate_company()
self.validate_data()
pp_items = self.get_distinct_bom(action = 'raise_pro_order')
pro = get_obj(dt = 'Production Control').create_production_order(self.doc.company, pp_items)
if pro:
for d in getlist(self.doclist, 'pp_details'):
d.is_pro_created = 1
msgprint("Following Production Order has been generated:\n" + '\n'.join(pro))
else :
msgprint("No Production Order is generated.")
def get_distinct_bom(self, action):
""" Club similar BOM and item for processing"""
bom_dict, item_dict, pp_items = {}, {}, []
for d in getlist(self.doclist, 'pp_details'):
if action == 'download_rm':
bom_dict[d.bom_no] = bom_dict.get(d.bom_no, 0) + flt(d.planned_qty)
elif not d.is_pro_created:
item_dict[d.item_code] = [
(flt(item_dict.get(d.item_code, [0])[0]) + flt(d.planned_qty)),
d.bom_no, d.description, d.stock_uom]
if action == 'raise_pro_order':
for d in item_dict:
pp_items.append({
'production_item' : d,
'qty' : item_dict[d][0],
'bom_no' : item_dict[d][1],
'description' : item_dict[d][2],
'stock_uom' : item_dict[d][3],
'consider_sa_items' : self.doc.consider_sa_items
})
return action == 'download_rm' and bom_dict or pp_items
return item_list

View File

@ -1,318 +1,219 @@
# DocType, Production Planning Tool
[
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:36:05',
'docstatus': 0,
'modified': '2012-03-27 14:36:05',
'modified_by': u'Administrator',
'owner': u'jai@webnotestech.com'
},
# These values are common for all DocType
{
'_last_update': u'1326188323',
'colour': u'White:FFF',
'default_print_format': u'Standard',
'doctype': 'DocType',
'in_create': 1,
'issingle': 1,
'module': u'Production',
'name': '__common__',
'read_only': 1,
'section_style': u'Tabbed',
'server_code_error': u' ',
'show_in_menu': 1,
'version': 106
},
# These values are common for all DocField
{
'doctype': u'DocField',
'name': '__common__',
'parent': u'Production Planning Tool',
'parentfield': u'fields',
'parenttype': u'DocType',
'permlevel': 0
},
# These values are common for all DocPerm
{
'create': 1,
'doctype': u'DocPerm',
'name': '__common__',
'parent': u'Production Planning Tool',
'parentfield': u'permissions',
'parenttype': u'DocType',
'permlevel': 0,
'read': 1,
'write': 1
},
# DocType, Production Planning Tool
{
'doctype': 'DocType',
'name': u'Production Planning Tool'
},
# DocPerm
{
'doctype': u'DocPerm',
'role': u'System Manager'
},
# DocPerm
{
'doctype': u'DocPerm',
'role': u'Production User'
},
# DocPerm
{
'doctype': u'DocPerm',
'role': u'Production Manager'
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'select_sales_orders',
'fieldtype': u'Section Break',
'label': u'Select Sales Orders'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break0',
'fieldtype': u'Column Break',
'width': u'50%'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'from_date',
'fieldtype': u'Date',
'label': u'From Date'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'to_date',
'fieldtype': u'Date',
'label': u'To Date'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'fg_item',
'fieldtype': u'Link',
'label': u'FG Item',
'options': u'Item'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break1',
'fieldtype': u'Column Break',
'width': u'50%'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'customer',
'fieldtype': u'Link',
'label': u'Customer',
'options': u'Customer'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'company',
'fieldtype': u'Link',
'label': u'Company',
'options': u'Company',
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'section_break0',
'fieldtype': u'Section Break',
'options': u'Simple'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break2',
'fieldtype': u'Column Break',
'width': u'50%'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'get_sales_orders',
'fieldtype': u'Button',
'label': u'Get Sales Orders',
'options': u'get_open_sales_orders'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break3',
'fieldtype': u'Column Break',
'width': u'50%'
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'clear_so_table',
'fieldtype': u'Button',
'label': u'Clear SO Table',
'options': u'clear_so_table',
'trigger': u'Client'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'section_break1',
'fieldtype': u'Section Break',
'options': u'Simple'
},
# DocField
{
'description': u'Select Sales Orders from which you want to create Production Orders. You can get sales orders based on above criteria.',
'doctype': u'DocField',
'fieldname': u'pp_so_details',
'fieldtype': u'Table',
'label': u'Production Plan Sales Orders',
'options': u'Production Plan Sales Order'
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'items',
'fieldtype': u'Section Break',
'label': u'Items'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'get_items_from_so',
'fieldtype': u'Button',
'label': u'Get Items from SO',
'options': u'get_items_from_so'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break4',
'fieldtype': u'Column Break',
'width': u'50%'
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'clear_item_table',
'fieldtype': u'Button',
'label': u'Clear Item Table',
'options': u'clear_item_table',
'trigger': u'Client'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'section_break2',
'fieldtype': u'Section Break',
'options': u'Simple'
},
# DocField
{
'description': u'Enter items and planned qty for which you want to raise production orders or download raw materials for analysis. You can pull items (which are pending to deliver) from SO as well by adding SO in plan.',
'doctype': u'DocField',
'fieldname': u'pp_details',
'fieldtype': u'Table',
'label': u'Production Plan Items',
'options': u'Production Plan Item'
},
# DocField
{
'colour': u'White:FFF',
'default': u'No',
'description': u'Select "Yes" if stock is maintained and tracked for sub assembly items.',
'doctype': u'DocField',
'fieldname': u'consider_sa_items',
'fieldtype': u'Select',
'label': u'Consider Sub Assemblies as Raw Material',
'options': u'No\nYes',
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'section_break3',
'fieldtype': u'Section Break',
'options': u'Simple'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break5',
'fieldtype': u'Column Break',
'width': u'50%'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'raise_production_order',
'fieldtype': u'Button',
'label': u'Raise Production Order',
'options': u'raise_production_order'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break6',
'fieldtype': u'Column Break',
'width': u'50%'
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'download_raw_material',
'fieldtype': u'Button',
'label': u'Download Raw Material',
'trigger': u'Client'
}
{
"owner": "jai@webnotestech.com",
"docstatus": 0,
"creation": "2012-07-03 13:30:03",
"modified_by": "Administrator",
"modified": "2012-11-30 14:08:55"
},
{
"read_only": 1,
"issingle": 1,
"in_create": 1,
"default_print_format": "Standard",
"doctype": "DocType",
"module": "Production",
"name": "__common__"
},
{
"name": "__common__",
"parent": "Production Planning Tool",
"doctype": "DocField",
"parenttype": "DocType",
"permlevel": 0,
"parentfield": "fields"
},
{
"name": "__common__",
"parent": "Production Planning Tool",
"read": 1,
"create": 1,
"doctype": "DocPerm",
"write": 1,
"parenttype": "DocType",
"permlevel": 0,
"parentfield": "permissions"
},
{
"name": "Production Planning Tool",
"doctype": "DocType"
},
{
"description": "Select Sales Orders from which you want to create Production Orders.",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Select Sales Orders",
"fieldname": "select_sales_orders",
"fieldtype": "Section Break"
},
{
"doctype": "DocField",
"width": "50%",
"fieldname": "column_break0",
"fieldtype": "Column Break"
},
{
"doctype": "DocField",
"label": "Filter based on item",
"fieldname": "fg_item",
"fieldtype": "Link",
"options": "Item"
},
{
"doctype": "DocField",
"label": "Filter based on customer",
"fieldname": "customer",
"fieldtype": "Link",
"options": "Customer"
},
{
"doctype": "DocField",
"label": "Company",
"reqd": 1,
"fieldname": "company",
"fieldtype": "Link",
"options": "Company"
},
{
"doctype": "DocField",
"width": "50%",
"fieldname": "column_break1",
"fieldtype": "Column Break"
},
{
"doctype": "DocField",
"label": "From Date",
"fieldname": "from_date",
"fieldtype": "Date"
},
{
"doctype": "DocField",
"label": "To Date",
"fieldname": "to_date",
"fieldtype": "Date"
},
{
"doctype": "DocField",
"fieldname": "section_break1",
"fieldtype": "Section Break",
"options": "Simple"
},
{
"description": "Pull sales orders (pending to deliver) based on the above criteria",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Get Sales Orders",
"fieldname": "get_sales_orders",
"fieldtype": "Button",
"options": "get_open_sales_orders"
},
{
"colour": "White:FFF",
"doctype": "DocField",
"label": "Production Plan Sales Orders",
"fieldname": "pp_so_details",
"fieldtype": "Table",
"options": "Production Plan Sales Order"
},
{
"colour": "White:FFF",
"doctype": "DocField",
"label": "Clear Table",
"trigger": "Client",
"fieldname": "clear_so_table",
"fieldtype": "Button",
"options": "clear_so_table"
},
{
"description": "Enter items and planned qty for which you want to raise production orders or download raw materials for analysis.",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Create Production Orders",
"fieldname": "create_production_orders",
"fieldtype": "Section Break"
},
{
"description": "Pull items from Sales Order mentioned in the above table.",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Get Items",
"fieldname": "get_items_from_so",
"fieldtype": "Button",
"options": "get_items_from_so"
},
{
"colour": "White:FFF",
"doctype": "DocField",
"label": "Production Plan Items",
"fieldname": "pp_details",
"fieldtype": "Table",
"options": "Production Plan Item"
},
{
"colour": "White:FFF",
"doctype": "DocField",
"label": "Clear Table",
"trigger": "Client",
"fieldname": "clear_item_table",
"fieldtype": "Button",
"options": "clear_item_table"
},
{
"description": "If checked, BOM for sub-assembly items will be considered for raw materials. Otherwise, all sub-assembly items will be treated as a raw material.",
"default": "1",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Use Multi-Level BOM",
"reqd": 1,
"fieldname": "use_multi_level_bom",
"fieldtype": "Check"
},
{
"doctype": "DocField",
"fieldname": "section_break3",
"fieldtype": "Section Break",
"options": "Simple"
},
{
"doctype": "DocField",
"width": "50%",
"fieldname": "column_break5",
"fieldtype": "Column Break"
},
{
"description": "Separate production order will be created for each finished good item.",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Raise Production Order",
"fieldname": "raise_production_order",
"fieldtype": "Button",
"options": "raise_production_order"
},
{
"doctype": "DocField",
"width": "50%",
"fieldname": "column_break6",
"fieldtype": "Column Break"
},
{
"description": "Download a report containing all raw materials with their latest inventory status",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Download Materials Required",
"trigger": "Client",
"fieldname": "download_materials_required",
"fieldtype": "Button"
},
{
"role": "System Manager",
"doctype": "DocPerm"
},
{
"role": "Production User",
"doctype": "DocPerm"
},
{
"role": "Production Manager",
"doctype": "DocPerm"
}
]

View File

@ -14,24 +14,15 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import flt
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.wrapper import copy_doclist
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:

View File

@ -14,24 +14,17 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import flt, getdate
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.doc import Document
from webnotes.model.wrapper import copy_doclist
from webnotes import msgprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:

View File

@ -14,24 +14,16 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, set_default, str_esc_quote, user_format, validate_email_add, add_days
from webnotes.utils import add_days, cint, cstr, date_diff, flt, now, nowdate, add_days
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.wrapper import copy_doclist
from webnotes import msgprint
from webnotes.utils.email_lib import sendmail
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:

View File

@ -14,21 +14,16 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils.email_lib import sendmail
from webnotes.utils import getdate
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.wrapper import copy_doclist
from webnotes import msgprint
sql = webnotes.conn.sql
# -----------------------------------------------------------------------------------------
class DocType:

View File

@ -14,24 +14,16 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import cint, cstr, getdate, now, nowdate
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes import msgprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:

View File

@ -1,144 +0,0 @@
// ERPNext - web based ERP (http://erpnext.com)
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// opts - parent, list, doc, email
erpnext.CommunicationView = Class.extend({
init: function(opts) {
this.comm_list = [];
$.extend(this, opts);
if(this.doc.__islocal) {
return;
}
this.list.sort(function(a, b) { return
(new Date(a.modified) > new Date(b.modified))
? -1 : 1; })
this.make();
},
make: function() {
var me = this;
this.make_body();
if(this.list && this.list.length) {
$.each(this.list, function(i, d) {
me.prepare(d);
me.make_line(d);
});
// show first
this.comm_list[0].find('.comm-content').toggle(true);
} else {
this.body.remove()
$("<div class='alert'>No Communication with this "
+ this.doc.doctype +" yet.</div>").appendTo(this.wrapper);
}
},
make_body: function() {
$(this.parent)
.html("")
.css({"margin":"10px 0px"});
this.wrapper = $("<div><h4>Communication History</h4>\
<div style='margin-bottom: 8px;'>\
<button class='btn btn-small' \
onclick='cur_frm.communication_view.add_reply()'>\
<i class='icon-plus'></i> Add Reply</button></div>\
</div>")
.appendTo(this.parent);
this.body = $("<table class='table table-bordered table-hover table-striped'>")
.appendTo(this.wrapper);
},
add_reply: function() {
var me = this;
var d = new wn.ui.Dialog({
width: 640,
title: "Add Reply: " + (this.doc.subject || ""),
fields: [
{label:"Subject", fieldtype:"Data", reqd: 1},
{label:"Message", fieldtype:"Text Editor", reqd: 1, fieldname:"content"},
{label:"Send Email", fieldtype:"Check"},
{label:"Add Reply", fieldtype:"Button"},
]
});
$(d.fields_dict.send_email.input).attr("checked", "checked")
$(d.fields_dict.add_reply.input).click(function() {
var args = d.get_values();
if(!args) return;
$(this).set_working();
wn.call({
method:"support.doctype.communication.communication.make",
args: $.extend(args, {
doctype: me.doc.doctype,
name: me.doc.name,
lead: me.doc.lead,
contact: me.doc.contact,
recipients: me.email
}),
callback: function(r) {
d.hide();
cur_frm.reload_doc();
}
});
});
if(me.list.length > 0) {
d.fields_dict.content.input.set_input("<p></p>"
+ (wn.boot.profile.email_signature || "")
+"<p></p>"
+"-----In response to-----<p></p>"
+ me.list[0].content)
} else {
}
$(d.fields_dict.subject.input).val(this.doc.subject || "").change();
d.show();
},
prepare: function(doc) {
//doc.when = comment_when(this.doc.modified);
doc.when = doc.modified;
if(doc.content.indexOf("<br>")== -1 && doc.content.indexOf("<p>")== -1) {
doc.content = doc.content.replace(/\n/g, "<br>");
}
if(!doc.sender) doc.sender = "[unknown sender]";
doc.sender = doc.sender.replace(/</, "&lt;").replace(/>/, "&gt;");
doc.content = doc.content.split("-----In response to-----")[0];
doc.content = doc.content.split("-----Original Message-----")[0];
},
make_line: function(doc) {
var me = this;
var comm = $(repl('<tr><td title="Click to Expand / Collapse">\
<p><b>%(sender)s on %(when)s</b> \
<a href="#Form/Communication/%(name)s" style="font-size: 90%">\
Show Details</a></p>\
<div class="comm-content" style="border-top: 1px solid #ddd; \
padding: 10px; overflow-x: auto; display: none;"></div>\
</td></tr>', doc))
.appendTo(this.body)
.css({"cursor":"pointer"})
.click(function() {
$(this).find(".comm-content").toggle();
});
this.comm_list.push(comm);
comm.find(".comm-content").html(doc.content);
}
})

View File

@ -22,10 +22,7 @@ import webnotes.profile
webnotes.user = webnotes.profile.Profile()
from webnotes.model.doc import Document
from webnotes.model.code import get_obj
from webnotes.utils import cstr, flt
from webnotes.model.wrapper import getlist
sql = webnotes.conn.sql
from sandbox.testdata import leaves

View File

@ -22,10 +22,7 @@ import webnotes.profile
webnotes.user = webnotes.profile.Profile()
from webnotes.model.doc import Document
from webnotes.model.code import get_obj
from webnotes.utils import cstr, flt
from webnotes.model.wrapper import getlist
sql = webnotes.conn.sql
from sandbox.testdata.masters import *

View File

@ -22,10 +22,7 @@ import webnotes.profile
webnotes.user = webnotes.profile.Profile()
from webnotes.model.doc import Document
from webnotes.model.code import get_obj
from webnotes.utils import cstr, flt
from webnotes.model.wrapper import getlist
sql = webnotes.conn.sql
from sandbox.testdata.masters import *

View File

@ -15,9 +15,6 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
wn.require('app/setup/doctype/contact_control/contact_control.js');
wn.require('app/support/doctype/communication/communication.js');
/* ********************************* onload ********************************************* */
cur_frm.cscript.onload = function(doc,dt,dn){
// history doctypes and scripts
@ -32,8 +29,6 @@ cur_frm.cscript.onload = function(doc,dt,dn){
//cur_frm.cscript.make_sl_body();
cur_frm.cscript.load_defaults(doc, dt, dn);
cur_frm.cscript.make_communication_body();
}
cur_frm.cscript.load_defaults = function(doc, dt, dn) {
@ -47,8 +42,6 @@ cur_frm.cscript.load_defaults = function(doc, dt, dn) {
cur_frm.add_fetch('lead_name', 'company_name', 'customer_name');
cur_frm.add_fetch('default_sales_partner','commission_rate','default_commission_rate');
/* ********************************* refresh ********************************************* */
cur_frm.cscript.refresh = function(doc,dt,dn) {
if(sys_defaults.cust_master_name == 'Customer Name')
hide_field('naming_series');
@ -57,16 +50,18 @@ cur_frm.cscript.refresh = function(doc,dt,dn) {
if(doc.__islocal){
hide_field(['address_html','contact_html']);
//cur_frm.cscript.set_hl_msg(doc);
//cur_frm.cscript.set_sl_msg(doc);
}else{
unhide_field(['address_html','contact_html']);
// make lists
cur_frm.cscript.make_address(doc,dt,dn);
cur_frm.cscript.make_contact(doc,dt,dn);
cur_frm.cscript.make_history(doc,dt,dn);
cur_frm.cscript.render_communication_list(doc, cdt, cdn);
//cur_frm.cscript.make_shipping_address(doc,dt,dn);
cur_frm.communication_view = new wn.views.CommunicationList({
list: wn.model.get("Communication", {"customer": doc.name}),
parent: cur_frm.fields_dict.communication_html.wrapper,
doc: doc
});
}
}
@ -117,11 +112,6 @@ cur_frm.cscript.make_contact = function() {
}
/* ********************************* client triggers ************************************** */
// ---------------
// customer group
// ---------------
cur_frm.fields_dict['customer_group'].get_query = function(doc,dt,dn) {
return 'SELECT `tabCustomer Group`.`name`, `tabCustomer Group`.`parent_customer_group` FROM `tabCustomer Group` WHERE `tabCustomer Group`.`is_group` = "No" AND `tabCustomer Group`.`docstatus`!= 2 AND `tabCustomer Group`.%(key)s LIKE "%s" ORDER BY `tabCustomer Group`.`name` ASC LIMIT 50';
}
@ -130,8 +120,6 @@ cur_frm.fields_dict['customer_group'].get_query = function(doc,dt,dn) {
cur_frm.fields_dict.lead_name.get_query = erpnext.utils.lead_query;
// Transaction History
// functions called by these functions are defined in communication.js
cur_frm.cscript.make_qtn_list = function(parent, doc) {
cur_frm.cscript.get_common_list_view(parent, doc, 'Quotation');
}
@ -173,7 +161,6 @@ cur_frm.cscript.get_common_list_view = function(parent, doc, doctype) {
cur_frm.cscript.render_list(doc, doctype, parent, ListView);
}
cur_frm.cscript.make_si_list = function(parent, doc) {
var ListView = wn.views.ListView.extend({
init: function(doclistview) {

View File

@ -14,28 +14,26 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cstr, date_diff, flt, formatdate, get_defaults, getdate, has_common, now, nowdate, replace_newlines, sendmail, set_default, user_format, validate_email_add
from webnotes.utils import cstr, get_defaults
from webnotes.model.doc import Document, make_autoname
from webnotes.model.code import get_obj
from webnotes import msgprint, errprint
from webnotes import msgprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
from utilities.transaction_base import TransactionBase
class DocType:
class DocType(TransactionBase):
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
# ******************************************************* autoname ***********************************************************
def onload(self):
self.add_communication_list()
def autoname(self):
cust_master_name = get_defaults().get('cust_master_name')
if cust_master_name == 'Customer Name':
@ -53,17 +51,9 @@ class DocType:
else:
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
# ******************************************************* triggers ***********************************************************
# ----------------
# get company abbr
# -----------------
def get_company_abbr(self):
return get_value('Company', self.doc.company, 'abbr')
# -----------------------------------------------------------------------------------------------------
# get parent account(i.e receivables group from company where default account head need to be created)
# -----------------------------------------------------------------------------------------------------
def get_receivables_group(self):
g = sql("select receivables_group from tabCompany where name=%s", self.doc.company)
g = g and g[0][0] or ''
@ -72,26 +62,15 @@ class DocType:
raise Exception
return g
# ******************************************************* validate *********************************************************
# ----------------
# validate values
# ----------------
def validate_values(self):
# Master name by naming series -> Series field mandatory
if get_defaults().get('cust_master_name') == 'Naming Series' and not self.doc.naming_series:
msgprint("Series is Mandatory.")
raise Exception
# ---------
# validate
# ---------
def validate(self):
self.validate_values()
# ******************************************************* on update *********************************************************
# ------------------------
# create customer address
# ------------------------
def create_customer_address(self):
addr_flds = [self.doc.address_line1, self.doc.address_line2, self.doc.city, self.doc.state, self.doc.country, self.doc.pincode]
address_line = "\n".join(filter(lambda x : (x!='' and x!=None),addr_flds))
@ -100,15 +79,11 @@ class DocType:
address_line = address_line + "\n" + "Phone: " + cstr(self.doc.phone_1)
if self.doc.email_id:
address_line = address_line + "\n" + "E-mail: " + cstr(self.doc.email_id)
set(self.doc,'address', address_line)
webnotes.conn.set(self.doc,'address', address_line)
telephone = "(O): " + cstr(self.doc.phone_1) +"\n"+ cstr(self.doc.phone_2) + "\n" + "(M): " + "\n" + "(fax): " + cstr(self.doc.fax_1)
set(self.doc,'telephone',telephone)
webnotes.conn.set(self.doc,'telephone',telephone)
# ------------------------------------
# create primary contact for customer
# ------------------------------------
def create_p_contact(self,nm,phn_no,email_id,mob_no,fax,cont_addr):
c1 = Document('Contact')
c1.first_name = nm
@ -126,10 +101,6 @@ class DocType:
c1.customer_group = self.doc.customer_group
c1.save(1)
# ------------------------
# create customer contact
# ------------------------
def create_customer_contact(self):
contact = sql("select distinct name from `tabContact` where customer_name=%s", (self.doc.customer_name))
contact = contact and contact[0][0] or ''
@ -143,18 +114,10 @@ class DocType:
c_detail = sql("select lead_name, company_name, contact_no, mobile_no, email_id, fax, address from `tabLead` where name =%s", self.doc.lead_name, as_dict=1)
self.create_p_contact(c_detail and c_detail[0]['lead_name'] or '', c_detail and c_detail[0]['contact_no'] or '', c_detail and c_detail[0]['email_id'] or '', c_detail and c_detail[0]['mobile_no'] or '', c_detail and c_detail[0]['fax'] or '', c_detail and c_detail[0]['address'] or '')
# -------------------
# update lead status
# -------------------
def update_lead_status(self):
if self.doc.lead_name:
sql("update `tabLead` set status='Converted' where name = %s", self.doc.lead_name)
# -------------------------------------------------------------------------
# create accont head - in tree under receivables_group of selected company
# -------------------------------------------------------------------------
def create_account_head(self):
if self.doc.company :
abbr = self.get_company_abbr()
@ -167,15 +130,9 @@ class DocType:
else :
msgprint("Please Select Company under which you want to create account head")
# ----------------------------------------
# update credit days and limit in account
# ----------------------------------------
def update_credit_days_limit(self):
sql("update tabAccount set credit_days = '%s', credit_limit = '%s' where name = '%s'" % (self.doc.credit_days, self.doc.credit_limit, self.doc.name + " - " + self.get_company_abbr()))
#create address and contact from lead
def create_lead_address_contact(self):
if self.doc.lead_name:
details = sql("select name, lead_name, address_line1, address_line2, city, country, state, pincode, phone, mobile_no, fax, email_id from `tabLead` where name = '%s'" %(self.doc.lead_name), as_dict = 1)
@ -211,9 +168,6 @@ class DocType:
except NameError, e:
pass
# ----------
# on update
# ----------
def on_update(self):
# create customer addr
#self.create_customer_address()
@ -257,8 +211,6 @@ class DocType:
if self.doc.lead_name:
sql("update `tabLead` set status='Interested' where name=%s",self.doc.lead_name)
# on rename
# ---------
def on_rename(self,newdn,olddn):
#update customer_name if not naming series
if get_defaults().get('cust_master_name') == 'Customer Name':

View File

@ -2,11 +2,12 @@
{
"owner": "Administrator",
"docstatus": 0,
"creation": "2012-10-02 11:27:30",
"creation": "2012-11-02 17:16:46",
"modified_by": "Administrator",
"modified": "2012-09-28 12:31:42"
"modified": "2012-11-30 10:54:38"
},
{
"autoname": "naming_series:",
"name": "__common__",
"default_print_format": "Standard",
"allow_print": 0,
@ -34,6 +35,17 @@
"name": "Customer",
"doctype": "DocType"
},
{
"description": "Note: You Can Manage Multiple Address or Contacts via Addresses & Contacts",
"oldfieldtype": "Section Break",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Basic Info",
"fieldname": "basic_info",
"fieldtype": "Section Break",
"reqd": 0,
"permlevel": 0
},
{
"print_hide": 0,
"no_copy": 1,
@ -183,7 +195,6 @@
},
{
"doctype": "DocField",
"label": "Communication History",
"fieldname": "communication_history",
"fieldtype": "Section Break",
"permlevel": 0

View File

@ -14,24 +14,18 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import cstr, getdate
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.doc import make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.code import get_obj
from webnotes import msgprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
from utilities.transaction_base import TransactionBase

View File

@ -16,7 +16,6 @@
// Module CRM
wn.require("public/app/js/communication.js");
wn.require('app/utilities/doctype/sms_control/sms_control.js');
cur_frm.cscript.onload = function(doc, cdt, cdn) {
@ -68,13 +67,12 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.cscript.refresh_custom_buttons(doc);
erpnext.hide_naming_series();
cur_frm.communication_view = new erpnext.CommunicationView({
cur_frm.communication_view = new wn.views.CommunicationList({
list: wn.model.get("Communication", {"lead": doc.name}),
parent: cur_frm.fields_dict.communication_html.wrapper,
doc: doc,
email: doc.email_id
})
}

View File

@ -14,11 +14,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cint, cstr, flt, validate_email_add
from webnotes.utils import cstr, validate_email_add
from webnotes.model.doc import Document, addchild
from webnotes import session, msgprint

View File

@ -15,7 +15,6 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
wn.require('app/utilities/doctype/sms_control/sms_control.js');
wn.require('app/support/doctype/communication/communication.js');
cur_frm.cscript.refresh = function(doc, cdt, cdn){
erpnext.hide_naming_series();
@ -26,7 +25,6 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn){
cur_frm.add_custom_button('Opportunity Lost', cur_frm.cscript['Declare Opportunity Lost']);
cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
}
if(!doc.__islocal) cur_frm.cscript.render_communication_list(doc, cdt, cdn);
}
// ONLOAD
@ -48,7 +46,14 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
}
}
cur_frm.cscript.make_communication_body();
if(!doc.__islocal) {
cur_frm.communication_view = new wn.views.CommunicationList({
list: wn.model.get("Communication", {"opportunity": doc.name}),
parent: cur_frm.fields_dict.communication_html.wrapper,
doc: doc,
email: doc.contact_email
});
}
if(cur_frm.fields_dict.contact_by.df.options.match(/^Profile/)) {
cur_frm.fields_dict.contact_by.get_query = erpnext.utils.profile_query;

View File

@ -14,25 +14,17 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import add_days, cstr, getdate
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.doc import Document, addchild
from webnotes.model.wrapper import getlist
from webnotes import msgprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
from utilities.transaction_base import TransactionBase
class DocType(TransactionBase):
@ -42,8 +34,8 @@ class DocType(TransactionBase):
self.fname = 'enq_details'
self.tname = 'Opportunity Item'
def autoname(self):
self.doc.name = make_autoname(self.doc.naming_series+'.####')
def onload(self):
self.add_communication_list()
def get_item_details(self, item_code):
item = sql("""select item_name, stock_uom, description_html, description, item_group, brand
@ -94,8 +86,8 @@ class DocType(TransactionBase):
if self.doc.contact_date and self.doc.contact_date_ref != self.doc.contact_date:
if self.doc.contact_by:
self.add_calendar_event()
set(self.doc, 'contact_date_ref',self.doc.contact_date)
set(self.doc, 'status', 'Draft')
webnotes.conn.set(self.doc, 'contact_date_ref',self.doc.contact_date)
webnotes.conn.set(self.doc, 'status', 'Draft')
def add_calendar_event(self):
desc=''
@ -169,7 +161,7 @@ class DocType(TransactionBase):
self.validate_lead_cust()
def on_submit(self):
set(self.doc, 'status', 'Submitted')
webnotes.conn.set(self.doc, 'status', 'Submitted')
def on_cancel(self):
chk = sql("select t1.name from `tabQuotation` t1, `tabQuotation Item` t2 where t2.parent = t1.name and t1.docstatus=1 and (t1.status!='Order Lost' and t1.status!='Cancelled') and t2.prevdoc_docname = %s",self.doc.name)
@ -177,7 +169,7 @@ class DocType(TransactionBase):
msgprint("Quotation No. "+cstr(chk[0][0])+" is submitted against this Opportunity. Thus can not be cancelled.")
raise Exception
else:
set(self.doc, 'status', 'Cancelled')
webnotes.conn.set(self.doc, 'status', 'Cancelled')
def declare_enquiry_lost(self,arg):
chk = sql("select t1.name from `tabQuotation` t1, `tabQuotation Item` t2 where t2.parent = t1.name and t1.docstatus=1 and (t1.status!='Order Lost' and t1.status!='Cancelled') and t2.prevdoc_docname = %s",self.doc.name)
@ -185,6 +177,6 @@ class DocType(TransactionBase):
msgprint("Quotation No. "+cstr(chk[0][0])+" is submitted against this Opportunity. Thus 'Opportunity Lost' can not be declared against it.")
raise Exception
else:
set(self.doc, 'status', 'Opportunity Lost')
set(self.doc, 'order_lost_reason', arg)
webnotes.conn.set(self.doc, 'status', 'Opportunity Lost')
webnotes.conn.set(self.doc, 'order_lost_reason', arg)
return 'true'

View File

@ -2,12 +2,13 @@
{
"owner": "Administrator",
"docstatus": 0,
"creation": "2012-11-28 11:26:19",
"creation": "2012-11-24 17:21:44",
"modified_by": "Administrator",
"modified": "2012-11-16 12:27:49"
"modified": "2012-11-30 10:54:00"
},
{
"is_submittable": 1,
"autoname": "naming_series:",
"name": "__common__",
"default_print_format": "Standard",
"search_fields": "status,transaction_date,customer,lead,enquiry_type,territory,company",
@ -34,6 +35,16 @@
"name": "Opportunity",
"doctype": "DocType"
},
{
"description": "Enter customer enquiry for which you might raise a quotation in future",
"oldfieldtype": "Section Break",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Basic Info",
"fieldname": "basic_info",
"fieldtype": "Section Break",
"permlevel": 0
},
{
"description": "To manage multiple series please go to Setup > Manage Series",
"no_copy": 1,
@ -154,15 +165,14 @@
"oldfieldtype": "Section Break",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Communication History",
"fieldname": "communication_history",
"fieldtype": "Section Break",
"permlevel": 0
},
{
"allow_on_submit": 1,
"oldfieldtype": "Table",
"colour": "White:FFF",
"allow_on_submit": 1,
"doctype": "DocField",
"label": "Communication HTML",
"oldfieldname": "follow_up",

View File

@ -14,24 +14,15 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.utils import cint, cstr, get_defaults, now
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint
from webnotes.model.wrapper import copy_doclist
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:

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