Compare commits

...

72 Commits

Author SHA1 Message Date
Anand Doshi
e91b3ea407 Merge branch 'develop' 2015-08-26 17:43:27 +05:30
Anand Doshi
28d53be50c bumped to version 5.8.1 2015-08-26 18:13:26 +06:00
Anand Doshi
cb2f9a863d [hotfix] reload Sales and Purchase Order Item 2015-08-26 17:42:40 +05:30
Anand Doshi
2b6bdc1edb [fix] filter and validation of Debit To and Credit To accounts 2015-08-26 17:42:40 +05:30
Anand Doshi
f326c63588 Merge branch 'develop' 2015-08-26 16:55:08 +05:30
Anand Doshi
8ca72d8883 bumped to version 5.8.0 2015-08-26 17:25:08 +06:00
Anand Doshi
ab9f03d557 Merge pull request #3952 from neilLasrado/variant-duplication
Fixed validation to prevent duplication of Item Variants in case of Numeric Attributes
2015-08-26 16:52:25 +05:30
Anand Doshi
7fa8fb984e [fix] Show write off account 2015-08-26 16:48:41 +05:30
Anand Doshi
f29628072f [change-log] 2015-08-26 14:50:05 +05:30
Anand Doshi
cb3a4caa44 [fix] removed validate due date in Journal Entry 2015-08-26 14:50:04 +05:30
Neil Trini Lasrado
755f1f6841 Fixed validation to prevent duplication of Item Variants in case of Numeric Attributes 2015-08-26 12:59:29 +05:30
Anand Doshi
80a784fdc5 Merge pull request #3943 from nabinhait/fix4
[fix] Print Delivery Note without amount
2015-08-26 12:29:24 +05:30
Rushabh Mehta
b6398be232 [minor] [fix] project query 2015-08-26 10:51:04 +05:30
Anand Doshi
007e2d0015 Merge branch 'nabinhait-return_improvements' into develop 2015-08-25 19:11:29 +05:30
Anand Doshi
fe13bfed44 Fixes to Return Improvements pull request
- Added "Returned Qty" in Sales and Purchase Order
- Map Expense Account in Return Delivery Note
- Defined some No Copy fields
- Added "Credit Note" and "Debit Note" Print Headings
- Fixed patch
2015-08-25 19:07:04 +05:30
Nabin Hait
b719c469c8 Allow different rate in Return Entry 2015-08-25 14:11:13 +05:30
Nabin Hait
3f321ebfde utilities/repost_stock file renamed to stock/stock_balance 2015-08-25 14:11:13 +05:30
Nabin Hait
047ecd1eb9 Update order reference in return entries and repost reserved / ordered qty 2015-08-25 14:11:13 +05:30
Nabin Hait
1f94fa25a8 Update delivered / ordered qty in sales/purchase order from return entry
Reserved Qty logic cleaned up
2015-08-25 14:11:12 +05:30
Rushabh Mehta
ddd79f43d2 [fix] [hot] erpnext contact page 2015-08-25 14:03:43 +05:30
Nabin Hait
a7c013c030 [fix] Print Delivery Note without amount 2015-08-24 18:43:19 +05:30
Anand Doshi
f7cfaf58b5 Merge pull request #3927 from neilLasrado/default-warehouse
Fetch default  WIP Warehouse and FG Warehouse on load of Production Order
2015-08-24 18:17:30 +05:30
Anand Doshi
82366e4b3f Merge pull request #3941 from nabinhait/fix2
[fix] Stock Entry additional costs patch fix for v4 accounts
2015-08-24 17:49:47 +05:30
Anand Doshi
b0d4162ca6 Merge pull request #3942 from nabinhait/fix3
[fix] In general ledger report, consider cost center in group by voucher
2015-08-24 17:42:51 +05:30
Anand Doshi
b968772e97 Merge pull request #3939 from neilLasrado/variant
Fixes in Item Variants
2015-08-24 17:42:23 +05:30
Nabin Hait
3a990d946d [fix] In general ledger report, consider cost center in group by voucher 2015-08-24 17:21:01 +05:30
Neil Trini Lasrado
db189d7f19 Fixed test case for Item Variants 2015-08-24 16:59:24 +05:30
Nabin Hait
b69eb84936 [fix] Stock Entry additional costs patch fix for v4 accounts 2015-08-24 16:55:10 +05:30
Anand Doshi
00c5875ff7 Merge branch 'develop' 2015-08-24 16:53:51 +05:30
Anand Doshi
5c9bd5e650 bumped to version 5.7.7 2015-08-24 17:23:51 +06:00
Neil Trini Lasrado
92a3dbb5d3 Fixes in Default Warehouse 2015-08-24 15:52:56 +05:30
Neil Trini Lasrado
75d90b1c00 Fixed Produciton Planning Tool 2015-08-24 15:23:58 +05:30
Neil Trini Lasrado
72e4cdcb25 Added default WIP Warehouse and FG Warehouse to Manufacturing Settings
Fetch default  WIP Warehouse and FG Warehouse on load of Production Order
2015-08-24 15:23:58 +05:30
Neil Trini Lasrado
4c614bd59a Fixed validation for numeric variants to check with values from template instead of master 2015-08-24 15:13:01 +05:30
Neil Trini Lasrado
7a6f048928 Fixed issue while creating item variants with decimal values (precision error) 2015-08-24 15:13:01 +05:30
Anand Doshi
96773bdc0e Merge pull request #3926 from neilLasrado/prod-order
Production Order - Validation Added
2015-08-24 14:44:44 +05:30
Anand Doshi
d092fd918a Merge pull request #3937 from rmehta/purchase-order-fix
[hot] make_stock_entry button in purchase order
2015-08-24 14:41:40 +05:30
Anand Doshi
50e2e1d9af Merge pull request #3936 from rmehta/customer-report-fix
[fix] Customer Address and Contact report
2015-08-24 14:35:42 +05:30
Rushabh Mehta
da24698cf7 [minor] in ap, ar renamed label for date as 'as on date' as it was confusing 2015-08-24 14:31:07 +05:30
Rushabh Mehta
d999dd1bb9 [minor] fix setup wizard buying_items query 2015-08-24 14:23:55 +05:30
Rushabh Mehta
c8a5a2cc4a [hot] make_stock_entry button in purchase order 2015-08-24 13:12:45 +05:30
Rushabh Mehta
12fb0d998f [fix] Customer Address and Contact report 2015-08-24 12:21:04 +05:30
Neil Trini Lasrado
17231e39cc Added validation in Production Order. Operations Time made mandatory 2015-08-21 16:52:04 +05:30
Anand Doshi
4451db2db4 Merge branch 'develop' 2015-08-21 14:57:19 +05:30
Anand Doshi
d7a6c11a92 bumped to version 5.7.6 2015-08-21 15:27:19 +06:00
Anand Doshi
bcb386fb64 Merge pull request #3922 from nabinhait/fraction_gle
Divisonal loss adjustment in purchase receipt
2015-08-21 14:55:44 +05:30
Anand Doshi
3709668464 Merge pull request #3925 from nabinhait/uom_replace
[fix]Stock UOM Replace Utility: Multiply Qty after Transaction by conversion factor as well, as there is no qty mentioned for stock reconciliation
2015-08-21 14:47:27 +05:30
Nabin Hait
7c2901fb56 [fix]Stock UOM Replace Utility: Multiply Qty after Transaction by conversion factor as well, as there is no qty mentioned for stock reconciliation 2015-08-21 14:45:59 +05:30
Anand Doshi
b5d9ab24ec Merge pull request #3921 from nabinhait/uom_replace
[fix]Stock UOM Replace Utility: Multiply Qty after Transaction by conversion factor as well, as there is no qty mentioned for stock reconciliation
2015-08-21 14:39:25 +05:30
Nabin Hait
597a402dff Divisonal loss adjustment in purchase receipt 2015-08-21 14:13:55 +05:30
Nabin Hait
1b6fd1ba5b [fix]Stock UOM Replace Utility: Multiply Qty after Transaction by conversion factor as well, as there is no qty mentioned for stock reconciliation 2015-08-21 13:05:19 +05:30
Anand Doshi
ac35b8af55 Merge pull request #3912 from nabinhait/jv1
[fix] payment amt against invoice outstanding
2015-08-21 13:01:53 +05:30
Anand Doshi
9b02aa722c Merge pull request #3920 from nabinhait/advances
[fix] Fetch advances in Sales/Purchase Invoice
2015-08-21 13:01:39 +05:30
Anand Doshi
32f3426007 Merge pull request #3919 from nabinhait/conv_factor
[fix] UOM Conversion factor mandatory in stock entry
2015-08-21 12:59:19 +05:30
Nabin Hait
046db626a2 [fix] Fetch advances in Sales/Purchase Invoice 2015-08-21 12:34:41 +05:30
Nabin Hait
d7ed197131 [fix] UOM Conversion factor mandatory in stock entry 2015-08-21 12:00:32 +05:30
Anand Doshi
f37884472d Merge branch 'develop' 2015-08-20 18:47:19 +05:30
Anand Doshi
e9cebd4de3 bumped to version 5.7.5 2015-08-20 19:17:19 +06:00
Anand Doshi
db1a9edbdf [minor] removed test case of template cannot have stock 2015-08-20 18:20:06 +05:30
Anand Doshi
5c85740aab [minor] don't validate stock for template item 2015-08-20 17:43:35 +05:30
Anand Doshi
8554cbf001 [minor] fixed patch item template attributes 2015-08-20 17:43:35 +05:30
Anand Doshi
0e90e8e8dc Merge branch 'develop' 2015-08-20 15:45:07 +05:30
Anand Doshi
30d3eb3d4b bumped to version 5.7.4 2015-08-20 16:15:07 +06:00
Anand Doshi
cf7adb5c02 [patch] re-run repost_reserved_qty 2015-08-20 15:42:58 +05:30
Anand Doshi
a5dce0adea Merge branch 'develop' 2015-08-20 15:42:23 +05:30
Anand Doshi
ac9a94f421 bumped to version 5.7.3 2015-08-20 16:12:23 +06:00
Anand Doshi
62cae01542 Merge branch 'develop' 2015-08-20 15:34:47 +05:30
Anand Doshi
4488764cd0 bumped to version 5.7.2 2015-08-20 16:04:47 +06:00
Anand Doshi
f6abfbffbc Merge pull request #3914 from nabinhait/patchfix
[fix][patch] Repost reserved qty for stock item
2015-08-20 15:33:49 +05:30
Nabin Hait
24998a6ca7 [fix][patch] Delete Bin for non-stock item 2015-08-20 15:21:42 +05:30
Nabin Hait
712fccd876 [fix][patch] Repost reserved qty for stock item 2015-08-20 14:59:44 +05:30
Nabin Hait
efc89f4395 [fix] payment amt against invoice outstanding 2015-08-20 11:30:44 +05:30
65 changed files with 2467 additions and 648 deletions

View File

@@ -1,2 +1,2 @@
from __future__ import unicode_literals
__version__ = '5.7.1'
__version__ = '5.8.1'

View File

@@ -32,7 +32,6 @@ class JournalEntry(AccountsController):
self.set_against_account()
self.create_remarks()
self.set_print_format_fields()
self.check_due_date()
self.validate_expense_claim()
self.validate_credit_debit_note()
self.validate_empty_accounts_table()
@@ -83,20 +82,6 @@ class JournalEntry(AccountsController):
for customer in customers:
check_credit_limit(customer, self.company)
def check_due_date(self):
if self.cheque_date:
for d in self.get("accounts"):
if d.party_type and d.party and d.get("credit" if d.party_type=="Customer" else "debit") > 0:
due_date = None
if d.reference_type in ("Sales Invoice", "Purchase Invoice"):
due_date = frappe.db.get_value(d.reference_type, d.reference_name, "due_date")
if due_date and getdate(self.cheque_date) > getdate(due_date):
diff = date_diff(self.cheque_date, due_date)
if diff > 0:
msgprint(_("Note: Reference Date exceeds invoice due date by {0} days for {1} {2}")
.format(diff, d.party_type, d.party))
def validate_cheque_info(self):
if self.voucher_type in ['Bank Entry']:
if not self.cheque_no or not self.cheque_date:
@@ -236,7 +221,7 @@ class JournalEntry(AccountsController):
if voucher_properties[0] != 1:
frappe.throw(_("{0} {1} is not submitted").format(reference_type, reference_name))
if flt(voucher_properties[1]) < total:
if total and flt(voucher_properties[1]) < total:
frappe.throw(_("Payment against {0} {1} cannot be greater \
than Outstanding Amount {2}").format(reference_type, reference_name, voucher_properties[1]))

View File

@@ -148,12 +148,22 @@ cur_frm.fields_dict['items'].grid.get_field("item_code").get_query = function(do
}
cur_frm.fields_dict['credit_to'].get_query = function(doc) {
return{
filters:{
'account_type': 'Payable',
'root_type': 'Liability',
'is_group': 0,
'company': doc.company
// filter on Account
if (doc.supplier) {
return {
filters: {
'account_type': 'Payable',
'is_group': 0,
'company': doc.company
}
}
} else {
return {
filters: {
'report_type': 'Balance Sheet',
'is_group': 0,
'company': doc.company
}
}
}
}

View File

@@ -91,8 +91,12 @@ class PurchaseInvoice(BuyingController):
throw(_("Conversion rate cannot be 0 or 1"))
def validate_credit_to_acc(self):
account_type = frappe.db.get_value("Account", self.credit_to, "account_type")
if account_type != "Payable":
account = frappe.db.get_value("Account", self.credit_to, ["account_type", "report_type"], as_dict=True)
if account.report_type != "Balance Sheet":
frappe.throw(_("Credit To account must be a Balance Sheet account"))
if self.supplier and account.account_type != "Payable":
frappe.throw(_("Credit To account must be a Payable account"))
def check_for_stopped_status(self):
@@ -127,7 +131,7 @@ class PurchaseInvoice(BuyingController):
}
})
if cint(frappe.db.get_single_value('Buying Settings', 'maintain_same_rate')):
if cint(frappe.db.get_single_value('Buying Settings', 'maintain_same_rate')) and not self.is_return:
self.validate_rate_with_reference_doc([
["Purchase Order", "purchase_order", "po_detail"],
["Purchase Receipt", "purchase_receipt", "pr_detail"]

View File

@@ -7,7 +7,7 @@ frappe.listview_settings['Purchase Invoice'] = {
"currency", "is_return"],
get_indicator: function(doc) {
if(cint(doc.is_return)==1) {
return [__("Return"), "darkgrey", "is_return,=,1"];
return [__("Return"), "darkgrey", "is_return,=,Yes"];
} else if(flt(doc.outstanding_amount) > 0 && doc.docstatus==1) {
if(frappe.datetime.get_diff(doc.due_date) < 0) {
return [__("Overdue"), "red", "outstanding_amount,>,0|due_date,<,Today"];

View File

@@ -64,6 +64,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
if(doc.outstanding_amount!=0 && !cint(doc.is_return)) {
cur_frm.add_custom_button(__('Payment'), cur_frm.cscript.make_bank_entry).addClass("btn-primary");
}
}
// Show buttons only when pos view is active
@@ -404,10 +405,22 @@ cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
}
cur_frm.set_query("debit_to", function(doc) {
return{
filters: [
['Account', 'root_type', '=', 'Asset'],
['Account', 'account_type', '=', 'Receivable']
]
// filter on Account
if (doc.customer) {
return {
filters: {
'account_type': 'Receivable',
'is_group': 0,
'company': doc.company
}
}
} else {
return {
filters: {
'report_type': 'Balance Sheet',
'is_group': 0,
'company': doc.company
}
}
}
});

File diff suppressed because it is too large Load Diff

View File

@@ -81,9 +81,14 @@ class SalesInvoice(SellingController):
self.check_prev_docstatus()
if self.is_return:
# NOTE status updating bypassed for is_return
self.status_updater = []
self.update_status_updater_args()
self.update_prevdoc_status()
if not self.is_return:
self.update_status_updater_args()
self.update_prevdoc_status()
self.update_billing_status_for_zero_amount_refdoc("Sales Order")
self.check_credit_limit()
@@ -107,9 +112,14 @@ class SalesInvoice(SellingController):
from erpnext.accounts.utils import remove_against_link_from_jv
remove_against_link_from_jv(self.doctype, self.name)
if self.is_return:
# NOTE status updating bypassed for is_return
self.status_updater = []
self.update_status_updater_args()
self.update_prevdoc_status()
if not self.is_return:
self.update_status_updater_args()
self.update_prevdoc_status()
self.update_billing_status_for_zero_amount_refdoc("Sales Order")
self.validate_c_form_on_cancel()
@@ -118,7 +128,7 @@ class SalesInvoice(SellingController):
def update_status_updater_args(self):
if cint(self.update_stock):
self.status_updater.append({
self.status_updater.extend([{
'source_dt':'Sales Invoice Item',
'target_dt':'Sales Order Item',
'target_parent_dt':'Sales Order',
@@ -136,7 +146,21 @@ class SalesInvoice(SellingController):
'overflow_type': 'delivery',
'extra_cond': """ and exists(select name from `tabSales Invoice`
where name=`tabSales Invoice Item`.parent and ifnull(update_stock, 0) = 1)"""
})
},
{
'source_dt': 'Sales Invoice Item',
'target_dt': 'Sales Order Item',
'join_field': 'so_detail',
'target_field': 'returned_qty',
'target_parent_dt': 'Sales Order',
# 'target_parent_field': 'per_delivered',
# 'target_ref_field': 'qty',
'source_field': '-1 * qty',
# 'percent_join_field': 'sales_order',
# 'overflow_type': 'delivery',
'extra_cond': """ and exists (select name from `tabSales Invoice` where name=`tabSales Invoice Item`.parent and update_stock=1 and is_return=1)"""
}
])
def set_missing_values(self, for_validate=False):
pos = self.set_pos_fields(for_validate)
@@ -247,8 +271,12 @@ class SalesInvoice(SellingController):
reconcile_against_document(lst)
def validate_debit_to_acc(self):
account_type = frappe.db.get_value("Account", self.debit_to, "account_type")
if account_type != "Receivable":
account = frappe.db.get_value("Account", self.debit_to, ["account_type", "report_type"], as_dict=True)
if account.report_type != "Balance Sheet":
frappe.throw(_("Debit To account must be a Balance Sheet account"))
if self.customer and account.account_type != "Receivable":
frappe.throw(_("Debit To account must be a Receivable account"))
def validate_fixed_asset_account(self):
@@ -273,7 +301,7 @@ class SalesInvoice(SellingController):
},
})
if cint(frappe.db.get_single_value('Selling Settings', 'maintain_same_sales_rate')):
if cint(frappe.db.get_single_value('Selling Settings', 'maintain_same_sales_rate')) and not self.is_return:
self.validate_rate_with_reference_doc([
["Sales Order", "sales_order", "so_detail"],
["Delivery Note", "delivery_note", "dn_detail"]
@@ -294,8 +322,6 @@ class SalesInvoice(SellingController):
def so_dn_required(self):
"""check in manage account if sales order / delivery note required or not."""
if self.is_return:
return
dic = {'Sales Order':'so_required','Delivery Note':'dn_required'}
for i in dic:
if frappe.db.get_value('Selling Settings', None, dic[i]) == 'Yes':
@@ -408,35 +434,11 @@ class SalesInvoice(SellingController):
def check_prev_docstatus(self):
for d in self.get('items'):
if d.sales_order:
submitted = frappe.db.sql("""select name from `tabSales Order`
where docstatus = 1 and name = %s""", d.sales_order)
if not submitted:
frappe.throw(_("Sales Order {0} is not submitted").format(d.sales_order))
if d.sales_order and frappe.db.get_value("Sales Order", d.sales_order, "docstatus") != 1:
frappe.throw(_("Sales Order {0} is not submitted").format(d.sales_order))
if d.delivery_note:
submitted = frappe.db.sql("""select name from `tabDelivery Note`
where docstatus = 1 and name = %s""", d.delivery_note)
if not submitted:
throw(_("Delivery Note {0} is not submitted").format(d.delivery_note))
def update_stock_ledger(self):
sl_entries = []
for d in self.get_item_list():
if frappe.db.get_value("Item", d.item_code, "is_stock_item") == 1 and d.warehouse and flt(d['qty']):
self.update_reserved_qty(d)
incoming_rate = 0
if cint(self.is_return) and self.return_against and self.docstatus==1:
incoming_rate = self.get_incoming_rate_for_sales_return(d.item_code,
self.return_against)
sl_entries.append(self.get_sl_entries(d, {
"actual_qty": -1*flt(d.qty),
"stock_uom": frappe.db.get_value("Item", d.item_code, "stock_uom"),
"incoming_rate": incoming_rate
}))
self.make_sl_entries(sl_entries)
if d.delivery_note and frappe.db.get_value("Delivery Note", d.delivery_note, "docstatus") != 1:
throw(_("Delivery Note {0} is not submitted").format(d.delivery_note))
def make_gl_entries(self, repost_future_gle=True):
gl_entries = self.get_gl_entries()

View File

@@ -7,7 +7,7 @@ frappe.listview_settings['Sales Invoice'] = {
"currency", "is_return"],
get_indicator: function(doc) {
if(cint(doc.is_return)==1) {
return [__("Return"), "darkgrey", "is_return,=,1"];
return [__("Return"), "darkgrey", "is_return,=,Yes"];
} else if(flt(doc.outstanding_amount)==0) {
return [__("Paid"), "green", "outstanding_amount,=,0"]
} else if (flt(doc.outstanding_amount) > 0 && doc.due_date > frappe.datetime.get_today()) {

View File

@@ -1,17 +0,0 @@
{
"creation": "2015-07-22 17:45:22.220567",
"custom_format": 1,
"disabled": 0,
"doc_type": "Sales Invoice",
"docstatus": 0,
"doctype": "Print Format",
"font": "Default",
"html": "<style>\n\t.print-format table, .print-format tr, \n\t.print-format td, .print-format div, .print-format p {\n\t\tfont-family: Monospace;\n\t\tline-height: 200%;\n\t\tvertical-align: middle;\n\t}\n\t@media screen {\n\t\t.print-format {\n\t\t\twidth: 4in;\n\t\t\tpadding: 0.25in;\n\t\t\tmin-height: 6in;\n\t\t}\n\t}\n</style>\n\n<p class=\"text-center\">\n\t{{ doc.company }}<br>\n\t{{ doc.select_print_heading or _(\"Credit Note\") }}<br>\n</p>\n\n<hr>\n\n{%- for label, value in (\n (_(\"Receipt No\"), doc.name),\n (_(\"Date\"), doc.get_formatted(\"posting_date\")),\n\t(_(\"Customer\"), doc.customer_name),\n (_(\"Amount\"), \"<strong>\" + doc.get_formatted(\"grand_total\", absolute_value=True) + \"</strong><br>\" + (doc.in_words or \"\")),\n\t(_(\"Against\"), doc.return_against),\n (_(\"Remarks\"), doc.remarks)\n) -%}\n\n\t\t<div class=\"row\">\n\t\t <div class=\"col-xs-4\"><label class=\"text-right\">{{ label }}</label></div>\n\t\t <div class=\"col-xs-8\">{{ value }}</div>\n\t\t</div>\n{%- endfor -%}\n\n<hr>\n<br>\n<p class=\"strong\">\n {{ _(\"For\") }} {{ doc.company }},<br>\n <br>\n <br>\n <br>\n {{ _(\"Authorized Signatory\") }}\n</p>",
"modified": "2015-07-22 17:45:22.220567",
"modified_by": "Administrator",
"name": "Credit Note - Negative Invoice",
"owner": "Administrator",
"print_format_builder": 0,
"print_format_type": "Server",
"standard": "Yes"
}

View File

@@ -18,7 +18,7 @@ frappe.query_reports["Accounts Payable"] = {
},
{
"fieldname":"report_date",
"label": __("Date"),
"label": __("As on Date"),
"fieldtype": "Date",
"default": get_today()
},

View File

@@ -18,7 +18,7 @@ frappe.query_reports["Accounts Receivable"] = {
},
{
"fieldname":"report_date",
"label": __("Date"),
"label": __("As on Date"),
"fieldtype": "Date",
"default": get_today()
},

View File

@@ -61,7 +61,7 @@ def get_result(filters, account_details):
return result
def get_gl_entries(filters):
group_by_condition = "group by voucher_type, voucher_no, account" \
group_by_condition = "group by voucher_type, voucher_no, account, cost_center" \
if filters.get("group_by_voucher") else "group by name"
gl_entries = frappe.db.sql("""select posting_date, account, party_type, party,

View File

@@ -32,7 +32,8 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
cur_frm.add_custom_button(__('Receive'), this.make_purchase_receipt).addClass("btn-primary");
if(doc.is_subcontracted==="Yes") {
cur_frm.add_custom_button(__('Transfer Material to Supplier'), this.make_stock_entry);
cur_frm.add_custom_button(__('Transfer Material to Supplier'),
function() { me.make_stock_entry(); });
}
}

View File

@@ -9,6 +9,7 @@ from frappe import msgprint, _, throw
from frappe.model.mapper import get_mapped_doc
from erpnext.controllers.buying_controller import BuyingController
from erpnext.stock.doctype.item.item import get_last_purchase_details
from erpnext.stock.stock_balance import update_bin_qty, get_ordered_qty
form_grid_templates = {
@@ -136,20 +137,6 @@ class PurchaseOrder(BuyingController):
def update_ordered_qty(self, po_item_rows=None):
"""update requested qty (before ordered_qty is updated)"""
from erpnext.stock.utils import get_bin
def _update_ordered_qty(item_code, warehouse):
ordered_qty = frappe.db.sql("""
select sum((po_item.qty - ifnull(po_item.received_qty, 0))*po_item.conversion_factor)
from `tabPurchase Order Item` po_item, `tabPurchase Order` po
where po_item.item_code=%s and po_item.warehouse=%s
and po_item.qty > ifnull(po_item.received_qty, 0) and po_item.parent=po.name
and po.status!='Stopped' and po.docstatus=1""", (item_code, warehouse))
bin_doc = get_bin(item_code, warehouse)
bin_doc.ordered_qty = flt(ordered_qty[0][0]) if ordered_qty else 0
bin_doc.save()
item_wh_list = []
for d in self.get("items"):
if (not po_item_rows or d.name in po_item_rows) and [d.item_code, d.warehouse] not in item_wh_list \
@@ -157,7 +144,9 @@ class PurchaseOrder(BuyingController):
item_wh_list.append([d.item_code, d.warehouse])
for item_code, warehouse in item_wh_list:
_update_ordered_qty(item_code, warehouse)
update_bin_qty(item_code, warehouse, {
"ordered_qty": get_ordered_qty(item_code, warehouse)
})
def check_modified_date(self):
mod_db = frappe.db.sql("select modified from `tabPurchase Order` where name = %s",

View File

@@ -1002,6 +1002,27 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"depends_on": "returned_qty",
"fieldname": "returned_qty",
"fieldtype": "Float",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Returned Qty",
"no_copy": 1,
"permlevel": 0,
"precision": "",
"print_hide": 1,
"read_only": 1,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"fieldname": "billed_amt",
@@ -1074,7 +1095,7 @@
"is_submittable": 0,
"issingle": 0,
"istable": 1,
"modified": "2015-08-19 12:46:32.384796",
"modified": "2015-08-25 06:42:00.898647",
"modified_by": "Administrator",
"module": "Buying",
"name": "Purchase Order Item",

View File

@@ -0,0 +1,5 @@
- Fixes in Sales and Purchase Return
- Update Delivered, Ordered and Returned Quantity based on Return transaction
- Allow different Rate in Return transaction
- Set default Finished Goods and Work-in-Progress Warehouse in Manufacturing Settings
- Fixed range validation for numeric attributes in Item Variants

View File

@@ -215,14 +215,15 @@ class AccountsController(TransactionBase):
"""Returns list of advances against Account, Party, Reference"""
order_list = list(set([d.get(against_order_field) for d in self.get("items") if d.get(against_order_field)]))
if not order_list:
return
in_placeholder = ', '.join(['%s'] * len(order_list))
# conver sales_order to "Sales Order"
reference_type = against_order_field.replace("_", " ").title()
condition = ""
if order_list:
in_placeholder = ', '.join(['%s'] * len(order_list))
condition = "or (t2.reference_type = '{0}' and ifnull(t2.reference_name, '') in ({1}))"\
.format(reference_type, in_placeholder)
res = frappe.db.sql("""
select
t1.name as jv_no, t1.remark, t2.{0} as amount, t2.name as jv_detail_no,
@@ -233,11 +234,9 @@ class AccountsController(TransactionBase):
t1.name = t2.parent and t2.account = %s
and t2.party_type = %s and t2.party = %s
and t2.is_advance = 'Yes' and t1.docstatus = 1
and (
ifnull(t2.reference_type, '')=''
or (t2.reference_type = %s and ifnull(t2.reference_name, '') in ({1})))
order by t1.posting_date""".format(dr_or_cr, in_placeholder),
[account_head, party_type, party, reference_type] + order_list, as_dict=1)
and (ifnull(t2.reference_type, '')='' {1})
order by t1.posting_date""".format(dr_or_cr, condition),
[account_head, party_type, party] + order_list, as_dict=1)
self.set(parentfield, [])
for d in res:

View File

@@ -205,10 +205,10 @@ def get_project_name(doctype, txt, searchfield, start, page_len, filters):
return frappe.db.sql("""select `tabProject`.name from `tabProject`
where `tabProject`.status not in ("Completed", "Cancelled")
and %(cond)s `tabProject`.name like "%(txt)s" %(mcond)s
and {cond} `tabProject`.name like %s {match_cond}
order by `tabProject`.name asc
limit %(start)s, %(page_len)s """ % {'cond': cond,'txt': "%%%s%%" % frappe.db.escape(txt),
'mcond':get_match_cond(doctype),'start': start, 'page_len': page_len})
limit {start}, {page_len}""".format(cond=cond, match_cond=get_match_cond(doctype),
start=start, page_len=page_len), "%{0}%".format(txt))
def get_delivery_notes_to_be_billed(doctype, txt, searchfield, start, page_len, filters):
return frappe.db.sql("""select `tabDelivery Note`.name, `tabDelivery Note`.customer_name
@@ -232,7 +232,7 @@ def get_batch_no(doctype, txt, searchfield, start, page_len, filters):
cond = ""
if filters.get("posting_date"):
cond = "and (ifnull(batch.expiry_date, '')='' or batch.expiry_date >= %(posting_date)s)"
batch_nos = None
args = {
'item_code': filters.get("item_code"),

View File

@@ -11,10 +11,10 @@ class StockOverReturnError(frappe.ValidationError): pass
def validate_return(doc):
if not doc.meta.get_field("is_return") or not doc.is_return:
return
validate_return_against(doc)
validate_returned_items(doc)
def validate_return_against(doc):
if not doc.return_against:
frappe.throw(_("{0} is mandatory for Return").format(doc.meta.get_label("return_against")))
@@ -24,49 +24,49 @@ def validate_return_against(doc):
filters["customer"] = doc.customer
elif doc.meta.get_field("supplier"):
filters["supplier"] = doc.supplier
if not frappe.db.exists(filters):
frappe.throw(_("Invalid {0}: {1}")
.format(doc.meta.get_label("return_against"), doc.return_against))
else:
ref_doc = frappe.get_doc(doc.doctype, doc.return_against)
# validate posting date time
return_posting_datetime = "%s %s" % (doc.posting_date, doc.get("posting_time") or "00:00:00")
ref_posting_datetime = "%s %s" % (ref_doc.posting_date, ref_doc.get("posting_time") or "00:00:00")
if get_datetime(return_posting_datetime) < get_datetime(ref_posting_datetime):
frappe.throw(_("Posting timestamp must be after {0}").format(format_datetime(ref_posting_datetime)))
# validate same exchange rate
if doc.conversion_rate != ref_doc.conversion_rate:
frappe.throw(_("Exchange Rate must be same as {0} {1} ({2})")
.format(doc.doctype, doc.return_against, ref_doc.conversion_rate))
# validate update stock
if doc.doctype == "Sales Invoice" and doc.update_stock and not ref_doc.update_stock:
frappe.throw(_("'Update Stock' can not be checked because items are not delivered via {0}")
.format(doc.return_against))
def validate_returned_items(doc):
from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos
valid_items = frappe._dict()
select_fields = "item_code, sum(qty) as qty, rate" if doc.doctype=="Purchase Invoice" \
else "item_code, sum(qty) as qty, rate, serial_no, batch_no"
for d in frappe.db.sql("""select {0} from `tab{1} Item` where parent = %s
for d in frappe.db.sql("""select {0} from `tab{1} Item` where parent = %s
group by item_code""".format(select_fields, doc.doctype), doc.return_against, as_dict=1):
valid_items.setdefault(d.item_code, d)
valid_items.setdefault(d.item_code, d)
if doc.doctype in ("Delivery Note", "Sales Invoice"):
for d in frappe.db.sql("""select item_code, sum(qty) as qty, serial_no, batch_no from `tabPacked Item`
for d in frappe.db.sql("""select item_code, sum(qty) as qty, serial_no, batch_no from `tabPacked Item`
where parent = %s group by item_code""".format(doc.doctype), doc.return_against, as_dict=1):
valid_items.setdefault(d.item_code, d)
already_returned_items = get_already_returned_items(doc)
items_returned = False
for d in doc.get("items"):
if flt(d.qty) < 0:
@@ -77,15 +77,12 @@ def validate_returned_items(doc):
ref = valid_items.get(d.item_code, frappe._dict())
already_returned_qty = flt(already_returned_items.get(d.item_code))
max_return_qty = flt(ref.qty) - already_returned_qty
if already_returned_qty >= ref.qty:
frappe.throw(_("Item {0} has already been returned").format(d.item_code), StockOverReturnError)
elif abs(d.qty) > max_return_qty:
frappe.throw(_("Row # {0}: Cannot return more than {1} for Item {2}")
.format(d.idx, ref.qty, d.item_code), StockOverReturnError)
elif ref.rate and flt(d.rate) != ref.rate:
frappe.throw(_("Row # {0}: Rate must be same as {1} {2}")
.format(d.idx, doc.doctype, doc.return_against))
elif ref.batch_no and d.batch_no != ref.batch_no:
frappe.throw(_("Row # {0}: Batch No must be same as {1} {2}")
.format(d.idx, doc.doctype, doc.return_against))
@@ -99,24 +96,24 @@ def validate_returned_items(doc):
if s not in ref_serial_nos:
frappe.throw(_("Row # {0}: Serial No {1} does not match with {2} {3}")
.format(d.idx, s, doc.doctype, doc.return_against))
items_returned = True
if not items_returned:
frappe.throw(_("Atleast one item should be entered with negative quantity in return document"))
def get_already_returned_items(doc):
return frappe._dict(frappe.db.sql("""
select
select
child.item_code, sum(abs(child.qty)) as qty
from
`tab{0} Item` child, `tab{1}` par
where
from
`tab{0} Item` child, `tab{1}` par
where
child.parent = par.name and par.docstatus = 1
and ifnull(par.is_return, 0) = 1 and par.return_against = %s and child.qty < 0
and ifnull(par.is_return, 0) = 1 and par.return_against = %s and child.qty < 0
group by item_code
""".format(doc.doctype, doc.doctype), doc.return_against))
def make_return_doc(doctype, source_name, target_doc=None):
from frappe.model.mapper import get_mapped_doc
def set_missing_values(source, target):
@@ -126,25 +123,50 @@ def make_return_doc(doctype, source_name, target_doc=None):
doc.ignore_pricing_rule = 1
if doctype == "Sales Invoice":
doc.is_pos = 0
# look for Print Heading "Credit Note"
if not doc.select_print_heading:
doc.select_print_heading = frappe.db.get_value("Print Heading", _("Credit Note"))
elif doctype == "Purchase Invoice":
# look for Print Heading "Debit Note"
doc.select_print_heading = frappe.db.get_value("Print Heading", _("Debit Note"))
for tax in doc.get("taxes"):
if tax.charge_type == "Actual":
tax.tax_amount = -1 * tax.tax_amount
doc.run_method("calculate_taxes_and_totals")
def update_item(source_doc, target_doc, source_parent):
target_doc.qty = -1* source_doc.qty
if doctype == "Purchase Receipt":
target_doc.received_qty = -1* source_doc.qty
target_doc.prevdoc_doctype = source_doc.prevdoc_doctype
target_doc.prevdoc_docname = source_doc.prevdoc_docname
target_doc.prevdoc_detail_docname = source_doc.prevdoc_detail_docname
elif doctype == "Purchase Invoice":
target_doc.purchase_order = source_doc.purchase_order
target_doc.purchase_receipt = source_doc.purchase_receipt
target_doc.po_detail = source_doc.po_detail
target_doc.pr_detail = source_doc.pr_detail
elif doctype == "Delivery Note":
target_doc.against_sales_order = source_doc.against_sales_order
target_doc.against_sales_invoice = source_doc.against_sales_invoice
target_doc.so_detail = source_doc.so_detail
target_doc.si_detail = source_doc.si_detail
target_doc.expense_account = source_doc.expense_account
elif doctype == "Sales Invoice":
target_doc.sales_order = source_doc.sales_order
target_doc.delivery_note = source_doc.delivery_note
target_doc.so_detail = source_doc.so_detail
target_doc.dn_detail = source_doc.dn_detail
target_doc.expense_account = source_doc.expense_account
doclist = get_mapped_doc(doctype, source_name, {
doctype: {
"doctype": doctype,
"validation": {
"docstatus": ["=", 1],
}
@@ -152,8 +174,6 @@ def make_return_doc(doctype, source_name, target_doc=None):
doctype +" Item": {
"doctype": doctype + " Item",
"field_map": {
"purchase_order": "purchase_order",
"purchase_receipt": "purchase_receipt",
"serial_no": "serial_no",
"batch_no": "batch_no"
},

View File

@@ -163,42 +163,17 @@ class SellingController(StockController):
def get_item_list(self):
il = []
for d in self.get("items"):
reserved_warehouse = ""
reserved_qty_for_main_item = 0
if d.qty is None:
frappe.throw(_("Row {0}: Qty is mandatory").format(d.idx))
if self.doctype == "Sales Order":
reserved_warehouse = d.warehouse
if flt(d.qty) > flt(d.delivered_qty):
reserved_qty_for_main_item = flt(d.qty) - flt(d.delivered_qty)
elif (((self.doctype == "Delivery Note" and d.against_sales_order)
or (self.doctype == "Sales Invoice" and d.sales_order and self.update_stock))
and not self.is_return):
# if SO qty is 10 and there is tolerance of 20%, then it will allow DN of 12.
# But in this case reserved qty should only be reduced by 10 and not 12
already_delivered_qty = self.get_already_delivered_qty(self.name,
d.against_sales_order if self.doctype=="Delivery Note" else d.sales_order, d.so_detail)
so_qty, reserved_warehouse = self.get_so_qty_and_warehouse(d.so_detail)
if already_delivered_qty + d.qty > so_qty:
reserved_qty_for_main_item = -(so_qty - already_delivered_qty)
else:
reserved_qty_for_main_item = -flt(d.qty)
if self.has_product_bundle(d.item_code):
for p in self.get("packed_items"):
if p.parent_detail_docname == d.name and p.parent_item == d.item_code:
# the packing details table's qty is already multiplied with parent's qty
il.append(frappe._dict({
'warehouse': p.warehouse,
'reserved_warehouse': reserved_warehouse,
'item_code': p.item_code,
'qty': flt(p.qty),
'reserved_qty': (flt(p.qty)/flt(d.qty)) * reserved_qty_for_main_item,
'uom': p.uom,
'batch_no': cstr(p.batch_no).strip(),
'serial_no': cstr(p.serial_no).strip(),
@@ -207,10 +182,8 @@ class SellingController(StockController):
else:
il.append(frappe._dict({
'warehouse': d.warehouse,
'reserved_warehouse': reserved_warehouse,
'item_code': d.item_code,
'qty': d.qty,
'reserved_qty': reserved_qty_for_main_item,
'uom': d.stock_uom,
'stock_uom': d.stock_uom,
'batch_no': cstr(d.get("batch_no")).strip(),

View File

@@ -90,6 +90,10 @@ class StatusUpdater(Document):
self.global_tolerance = None
for args in self.status_updater:
if "target_ref_field" not in args:
# if target_ref_field is not specified, the programmer does not want to validate qty / amount
continue
# get unique transactions to update
for d in self.get_all_children():
if d.doctype == args['source_dt'] and d.get(args["join_field"]):
@@ -140,8 +144,9 @@ class StatusUpdater(Document):
.format(_(item["target_ref_field"].title()), item["reduce_by"]))
def update_qty(self, change_modified=True):
"""
Updates qty at row level
"""Updates qty or amount at row level
:param change_modified: If true, updates `modified` and `modified_by` for target parent doc
"""
for args in self.status_updater:
# condition to include current record (if submit or no if cancel)
@@ -150,58 +155,74 @@ class StatusUpdater(Document):
else:
args['cond'] = ' and parent!="%s"' % self.name.replace('"', '\"')
args['modified_cond'] = ''
args['set_modified'] = ''
if change_modified:
args['modified_cond'] = ', modified = now()'
args['set_modified'] = ', modified = now(), modified_by = "{0}"'\
.format(frappe.db.escape(frappe.session.user))
# update quantities in child table
for d in self.get_all_children():
if d.doctype == args['source_dt']:
# updates qty in the child table
args['detail_id'] = d.get(args['join_field'])
self._update_children(args)
args['second_source_condition'] = ""
if args.get('second_source_dt') and args.get('second_source_field') \
and args.get('second_join_field'):
if not args.get("second_source_extra_cond"):
args["second_source_extra_cond"] = ""
if "percent_join_field" in args:
self._update_percent_field(args)
args['second_source_condition'] = """ + ifnull((select sum(%(second_source_field)s)
from `tab%(second_source_dt)s`
where `%(second_join_field)s`="%(detail_id)s"
and (`tab%(second_source_dt)s`.docstatus=1) %(second_source_extra_cond)s), 0) """ % args
def _update_children(self, args):
"""Update quantities or amount in child table"""
for d in self.get_all_children():
if d.doctype != args['source_dt']:
continue
if args['detail_id']:
if not args.get("extra_cond"): args["extra_cond"] = ""
# updates qty in the child table
args['detail_id'] = d.get(args['join_field'])
frappe.db.sql("""update `tab%(target_dt)s`
set %(target_field)s = (select sum(%(source_field)s)
from `tab%(source_dt)s` where `%(join_field)s`="%(detail_id)s"
and (docstatus=1 %(cond)s) %(extra_cond)s) %(second_source_condition)s
where name='%(detail_id)s'""" % args)
args['second_source_condition'] = ""
if args.get('second_source_dt') and args.get('second_source_field') \
and args.get('second_join_field'):
if not args.get("second_source_extra_cond"):
args["second_source_extra_cond"] = ""
# get unique transactions to update
for name in set([d.get(args['percent_join_field']) for d in self.get_all_children(args['source_dt'])]):
if name:
args['name'] = name
args['second_source_condition'] = """ + ifnull((select sum(%(second_source_field)s)
from `tab%(second_source_dt)s`
where `%(second_join_field)s`="%(detail_id)s"
and (`tab%(second_source_dt)s`.docstatus=1) %(second_source_extra_cond)s), 0) """ % args
# update percent complete in the parent table
if args.get('target_parent_field'):
frappe.db.sql("""update `tab%(target_parent_dt)s`
set %(target_parent_field)s = (select sum(if(%(target_ref_field)s >
ifnull(%(target_field)s, 0), %(target_field)s,
%(target_ref_field)s))/sum(%(target_ref_field)s)*100
from `tab%(target_dt)s` where parent="%(name)s") %(modified_cond)s
where name='%(name)s'""" % args)
if args['detail_id']:
if not args.get("extra_cond"): args["extra_cond"] = ""
# update field
if args.get('status_field'):
frappe.db.sql("""update `tab%(target_parent_dt)s`
set %(status_field)s = if(ifnull(%(target_parent_field)s,0)<0.001,
'Not %(keyword)s', if(%(target_parent_field)s>=99.99,
'Fully %(keyword)s', 'Partly %(keyword)s'))
where name='%(name)s'""" % args)
frappe.db.sql("""update `tab%(target_dt)s`
set %(target_field)s = (select sum(%(source_field)s)
from `tab%(source_dt)s` where `%(join_field)s`="%(detail_id)s"
and (docstatus=1 %(cond)s) %(extra_cond)s) %(second_source_condition)s
where name='%(detail_id)s'""" % args)
def _update_percent_field(self, args):
"""Update percent field in parent transaction"""
unique_transactions = set([d.get(args['percent_join_field']) for d in self.get_all_children(args['source_dt'])])
for name in unique_transactions:
if not name:
continue
args['name'] = name
# update percent complete in the parent table
if args.get('target_parent_field'):
frappe.db.sql("""update `tab%(target_parent_dt)s`
set %(target_parent_field)s = (select sum(if(%(target_ref_field)s >
ifnull(%(target_field)s, 0), %(target_field)s,
%(target_ref_field)s))/sum(%(target_ref_field)s)*100
from `tab%(target_dt)s` where parent="%(name)s") %(set_modified)s
where name='%(name)s'""" % args)
# update field
if args.get('status_field'):
frappe.db.sql("""update `tab%(target_parent_dt)s`
set %(status_field)s = if(ifnull(%(target_parent_field)s,0)<0.001,
'Not %(keyword)s', if(%(target_parent_field)s>=99.99,
'Fully %(keyword)s', 'Partly %(keyword)s'))
where name='%(name)s'""" % args)
if args.get("set_modified"):
frappe.get_doc(args["target_parent_dt"], name).notify_modified()
def update_billing_status_for_zero_amount_refdoc(self, ref_dt):
ref_fieldname = ref_dt.lower().replace(" ", "_")

View File

@@ -6,11 +6,9 @@ import frappe
from frappe.utils import cint, flt, cstr
from frappe import msgprint, _
import frappe.defaults
from erpnext.accounts.general_ledger import make_gl_entries, delete_gl_entries, process_gl_map
from erpnext.controllers.accounts_controller import AccountsController
from erpnext.accounts.general_ledger import make_gl_entries, delete_gl_entries, process_gl_map
from erpnext.stock.utils import update_bin
class StockController(AccountsController):
def make_gl_entries(self, repost_future_gle=True):
@@ -229,23 +227,44 @@ class StockController(AccountsController):
incoming_rate = incoming_rate[0][0] if incoming_rate else 0.0
return incoming_rate
def update_reserved_qty(self):
so_map = {}
for d in self.get("items"):
if d.so_detail:
if self.doctype == "Delivery Note" and d.against_sales_order:
so_map.setdefault(d.against_sales_order, []).append(d.so_detail)
elif self.doctype == "Sales Invoice" and d.sales_order and self.update_stock:
so_map.setdefault(d.sales_order, []).append(d.so_detail)
def update_reserved_qty(self, d):
if d['reserved_qty'] < 0 :
# Reduce reserved qty from reserved warehouse mentioned in so
if not d["reserved_warehouse"]:
frappe.throw(_("Delivery Warehouse is missing in Sales Order"))
for so, so_item_rows in so_map.items():
if so and so_item_rows:
sales_order = frappe.get_doc("Sales Order", so)
args = {
"item_code": d['item_code'],
"warehouse": d["reserved_warehouse"],
"voucher_type": self.doctype,
"voucher_no": self.name,
"reserved_qty": (self.docstatus==1 and 1 or -1)*flt(d['reserved_qty']),
"posting_date": self.posting_date,
"is_amended": self.amended_from and 'Yes' or 'No'
}
update_bin(args)
if sales_order.status in ["Stopped", "Cancelled"]:
frappe.throw(_("Sales Order {0} is cancelled or stopped").format(so), frappe.InvalidStatusError)
sales_order.update_reserved_qty(so_item_rows)
def update_stock_ledger(self):
self.update_reserved_qty()
sl_entries = []
for d in self.get_item_list():
if frappe.db.get_value("Item", d.item_code, "is_stock_item") == 1 \
and d.warehouse and flt(d['qty']):
incoming_rate = 0
if cint(self.is_return) and self.return_against and self.docstatus==1:
incoming_rate = self.get_incoming_rate_for_sales_return(d.item_code, self.return_against)
sl_entries.append(self.get_sl_entries(d, {
"actual_qty": -1*flt(d['qty']),
"stock_uom": frappe.db.get_value("Item", d.item_code, "stock_uom"),
"incoming_rate": incoming_rate
}))
self.make_sl_entries(sl_entries)
def update_gl_entries_after(posting_date, posting_time, for_warehouses=None, for_items=None,
warehouse_account=None):

View File

@@ -27,7 +27,7 @@ blogs.
"""
app_icon = "icon-th"
app_color = "#e74c3c"
app_version = "5.7.1"
app_version = "5.8.1"
github_link = "https://github.com/frappe/erpnext"
error_report_email = "support@erpnext.com"

View File

@@ -1,123 +1,320 @@
{
"allow_copy": 0,
"allow_import": 0,
"allow_rename": 0,
"creation": "2014-11-27 14:12:07.542534",
"custom": 0,
"docstatus": 0,
"doctype": "DocType",
"document_type": "Master",
"allow_copy": 0,
"allow_import": 0,
"allow_rename": 0,
"creation": "2014-11-27 14:12:07.542534",
"custom": 0,
"docstatus": 0,
"doctype": "DocType",
"document_type": "Document",
"fields": [
{
"fieldname": "capacity_planning",
"fieldtype": "Section Break",
"label": "Capacity Planning",
"permlevel": 0,
"precision": ""
},
"allow_on_submit": 0,
"fieldname": "capacity_planning",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Capacity Planning",
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"description": "Disables creation of time logs against Production Orders.\nOperations shall not be tracked against Production Order",
"fieldname": "disable_capacity_planning",
"fieldtype": "Check",
"label": "Disable Capacity Planning and Time Tracking",
"permlevel": 0,
"precision": ""
},
"allow_on_submit": 0,
"description": "Disables creation of time logs against Production Orders.\nOperations shall not be tracked against Production Order",
"fieldname": "disable_capacity_planning",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Disable Capacity Planning and Time Tracking",
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"description": "Plan time logs outside Workstation Working Hours.",
"fieldname": "allow_overtime",
"fieldtype": "Check",
"label": "Allow Overtime",
"permlevel": 0,
"precision": ""
},
"allow_on_submit": 0,
"description": "Plan time logs outside Workstation Working Hours.",
"fieldname": "allow_overtime",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Allow Overtime",
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"default": "",
"fieldname": "allow_production_on_holidays",
"fieldtype": "Check",
"in_list_view": 1,
"label": "Allow Production on Holidays",
"options": "",
"permlevel": 0,
"precision": ""
},
"allow_on_submit": 0,
"default": "",
"fieldname": "allow_production_on_holidays",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 1,
"label": "Allow Production on Holidays",
"no_copy": 0,
"options": "",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"default": "BOM",
"fieldname": "backflush_raw_materials_based_on",
"fieldtype": "Select",
"label": "Backflush Raw Materials Based On",
"options": "BOM\nMaterial Transferred for Manufacture",
"permlevel": 0,
"precision": ""
},
"allow_on_submit": 0,
"fieldname": "column_break_3",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"fieldname": "column_break_3",
"fieldtype": "Column Break",
"permlevel": 0,
"precision": ""
},
"allow_on_submit": 0,
"default": "30",
"description": "Try planning operations for X days in advance.",
"fieldname": "capacity_planning_for_days",
"fieldtype": "Int",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Capacity Planning For (Days)",
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"default": "30",
"description": "Try planning operations for X days in advance.",
"fieldname": "capacity_planning_for_days",
"fieldtype": "Int",
"label": "Capacity Planning For (Days)",
"permlevel": 0,
"precision": ""
},
"allow_on_submit": 0,
"description": "Default 10 mins",
"fieldname": "mins_between_operations",
"fieldtype": "Int",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Time Between Operations (in mins)",
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"description": "Default 10 mins",
"fieldname": "mins_between_operations",
"fieldtype": "Int",
"label": "Time Between Operations (in mins)",
"permlevel": 0,
"precision": ""
},
"allow_on_submit": 0,
"fieldname": "section_break_6",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"fieldname": "over_production_allowance_percentage",
"fieldtype": "Percent",
"label": "Over Production Allowance Percentage",
"permlevel": 0,
"precision": ""
"allow_on_submit": 0,
"fieldname": "over_production_allowance_percentage",
"fieldtype": "Percent",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Over Production Allowance Percentage",
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"default": "BOM",
"fieldname": "backflush_raw_materials_based_on",
"fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Backflush Raw Materials Based On",
"no_copy": 0,
"options": "BOM\nMaterial Transferred for Manufacture",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"fieldname": "column_break_11",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"fieldname": "default_wip_warehouse",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Default Work In Progress Warehouse",
"no_copy": 0,
"options": "Warehouse",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"fieldname": "default_fg_warehouse",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Default Finished Goods Warehouse",
"no_copy": 0,
"options": "Warehouse",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
}
],
"hide_heading": 0,
"hide_toolbar": 0,
"icon": "icon-wrench",
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 1,
"istable": 0,
"modified": "2015-08-12 08:12:33.889753",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "Manufacturing Settings",
"name_case": "",
"owner": "Administrator",
],
"hide_heading": 0,
"hide_toolbar": 0,
"icon": "icon-wrench",
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 1,
"istable": 0,
"modified": "2015-08-21 08:27:03.794133",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "Manufacturing Settings",
"name_case": "",
"owner": "Administrator",
"permissions": [
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 0,
"email": 0,
"export": 0,
"import": 0,
"permlevel": 0,
"print": 0,
"read": 1,
"report": 0,
"role": "Manufacturing Manager",
"set_user_permissions": 0,
"share": 1,
"submit": 0,
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 0,
"email": 0,
"export": 0,
"if_owner": 0,
"import": 0,
"permlevel": 0,
"print": 0,
"read": 1,
"report": 0,
"role": "Manufacturing Manager",
"set_user_permissions": 0,
"share": 1,
"submit": 0,
"write": 1
}
],
"read_only": 0,
"read_only_onload": 0,
"sort_field": "modified",
],
"read_only": 0,
"read_only_onload": 0,
"sort_field": "modified",
"sort_order": "DESC"
}
}

View File

@@ -12,6 +12,7 @@ frappe.ui.form.on("Production Order", "onload", function(frm) {
"actual_start_date": "",
"actual_end_date": ""
});
erpnext.production_order.set_default_warehouse(frm);
}
erpnext.production_order.set_custom_buttons(frm);
@@ -138,10 +139,22 @@ erpnext.production_order = {
}
} else msgprint(__("Please enter Production Item first"));
});
},
set_default_warehouse: function(frm) {
frappe.call({
method: "erpnext.manufacturing.doctype.production_order.production_order.get_default_warehouse",
callback: function(r) {
if(!r.exe) {
frm.set_value("wip_warehouse", r.message.wip_warehouse);
frm.set_value("fg_warehouse", r.message.fg_warehouse)
}
}
});
}
}
$.extend(cur_frm.cscript, {
before_submit: function() {
cur_frm.toggle_reqd(["fg_warehouse", "wip_warehouse"], true);

View File

@@ -42,6 +42,8 @@ class ProductionOrder(Document):
self.validate_warehouse()
self.calculate_operating_cost()
self.validate_delivery_date()
self.validate_qty()
self.validate_operation_time()
from erpnext.utilities.transaction_base import validate_uom_is_integer
validate_uom_is_integer(self, "stock_uom", ["qty", "produced_qty"])
@@ -327,6 +329,15 @@ class ProductionOrder(Document):
frappe.throw(_("Production Order cannot be raised against a Item Template"), ItemHasVariantError)
validate_end_of_life(self.production_item)
def validate_qty(self):
if not self.qty > 0:
frappe.throw(_("Quantity to Manufacture must be greater than 0."))
def validate_operation_time(self):
for d in self.operations:
if not d.time_in_mins > 0:
frappe.throw(_("Operation Time must be greater than 0 for Operation {0}".format(d.operation)))
@frappe.whitelist()
def get_item_details(item):
@@ -411,3 +422,9 @@ def make_time_log(name, operation, from_time=None, to_time=None, qty=None, proj
if from_time and to_time :
time_log.calculate_total_hours()
return time_log
@frappe.whitelist()
def get_default_warehouse():
wip_warehouse = frappe.db.get_single_value("Manufacturing Settings", "default_wip_warehouse")
fg_warehouse = frappe.db.get_single_value("Manufacturing Settings", "default_fg_warehouse")
return {"wip_warehouse": wip_warehouse, "fg_warehouse": fg_warehouse}

View File

@@ -276,7 +276,7 @@
"print_hide": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"unique": 0
@@ -476,7 +476,7 @@
"is_submittable": 0,
"issingle": 0,
"istable": 1,
"modified": "2015-08-19 12:45:53.834920",
"modified": "2015-08-21 07:17:18.185276",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "Production Order Operation",

View File

@@ -200,15 +200,19 @@ class ProductionPlanningTool(Document):
def create_production_order(self, items):
"""Create production order. Called from Production Planning Tool"""
from erpnext.manufacturing.doctype.production_order.production_order import OverProductionError
from erpnext.manufacturing.doctype.production_order.production_order import OverProductionError, get_default_warehouse
warehouse = get_default_warehouse()
pro_list = []
for key in items:
pro = frappe.new_doc("Production Order")
pro.update(items[key])
pro.set_production_order_operations()
if warehouse:
pro.wip_warehouse = warehouse.get('wip_warehouse')
if not pro.fg_warehouse:
pro.fg_warehouse = warehouse.get('fg_warehouse')
frappe.flags.mute_messages = True
try:
pro.insert()
pro_list.append(pro.name)
@@ -216,7 +220,6 @@ class ProductionPlanningTool(Document):
pass
frappe.flags.mute_messages = False
return pro_list
def download_raw_materials(self):

View File

@@ -191,5 +191,10 @@ erpnext.patches.v5_4.stock_entry_additional_costs
erpnext.patches.v5_4.cleanup_journal_entry #2015-08-14
execute:frappe.db.sql("update `tabProduction Order` pro set description = (select description from tabItem where name=pro.production_item) where ifnull(description, '') = ''")
erpnext.patches.v5_7.item_template_attributes
erpnext.patches.v4_2.repost_reserved_qty #2015-08-17
execute:frappe.delete_doc_if_exists("DocType", "Manage Variants")
execute:frappe.delete_doc_if_exists("DocType", "Manage Variants Item")
erpnext.patches.v4_2.repost_reserved_qty #2015-08-20
erpnext.patches.v5_4.update_purchase_cost_against_project
erpnext.patches.v5_8.update_order_reference_in_return_entries
erpnext.patches.v5_8.add_credit_note_print_heading
execute:frappe.delete_doc_if_exists("Print Format", "Credit Note - Negative Invoice")

View File

@@ -5,7 +5,7 @@ from __future__ import unicode_literals
import frappe
def execute():
from erpnext.utilities.repost_stock import set_stock_balance_as_per_serial_no
from erpnext.stock.stock_balance import set_stock_balance_as_per_serial_no
frappe.db.auto_commit_on_many_writes = 1
set_stock_balance_as_per_serial_no()

View File

@@ -6,7 +6,7 @@ import frappe
from frappe.utils import flt
def execute():
from erpnext.utilities.repost_stock import repost
from erpnext.stock.stock_balance import repost
repost(allow_zero_rate=True, only_actual=True)
frappe.reload_doctype("Account")

View File

@@ -3,7 +3,7 @@
from __future__ import unicode_literals
import frappe
from erpnext.utilities.repost_stock import update_bin_qty, get_reserved_qty
from erpnext.stock.stock_balance import update_bin_qty, get_reserved_qty
def execute():
repost_for = frappe.db.sql("""
@@ -18,10 +18,18 @@ def execute():
select distinct item_code, warehouse
from `tabPacked Item` where docstatus=1 and parenttype='Sales Order'
)
) items
) so_item
where
exists(select name from tabItem where name=so_item.item_code and ifnull(is_stock_item, 0)=1)
""")
for item_code, warehouse in repost_for:
update_bin_qty(item_code, warehouse, {
"reserved_qty": get_reserved_qty(item_code, warehouse)
})
})
frappe.db.sql("""delete from tabBin
where exists(
select name from tabItem where name=tabBin.item_code and ifnull(is_stock_item, 0) = 0
)
""")

View File

@@ -5,7 +5,7 @@ from __future__ import unicode_literals
import frappe
def execute():
from erpnext.utilities.repost_stock import update_bin_qty, get_indented_qty, get_ordered_qty
from erpnext.stock.stock_balance import update_bin_qty, get_indented_qty, get_ordered_qty
count=0
for item_code, warehouse in frappe.db.sql("""select distinct item_code, warehouse from

View File

@@ -5,7 +5,7 @@ from __future__ import unicode_literals
import frappe
def execute():
from erpnext.utilities.repost_stock import update_bin_qty, get_indented_qty
from erpnext.stock.stock_balance import update_bin_qty, get_indented_qty
count=0
for item_code, warehouse in frappe.db.sql("""select distinct item_code, warehouse

View File

@@ -3,7 +3,7 @@
from __future__ import unicode_literals
import frappe
from erpnext.utilities.repost_stock import repost_actual_qty
from erpnext.stock.stock_balance import repost_actual_qty
def execute():
cancelled_invoices = frappe.db.sql_list("""select name from `tabSales Invoice`

View File

@@ -10,12 +10,6 @@ def execute():
frappe.reload_doctype("Stock Entry Detail")
frappe.reload_doctype("Landed Cost Taxes and Charges")
frappe.db.sql("""update `tabStock Entry Detail` sed, `tabStock Entry` se
set sed.valuation_rate=sed.incoming_rate, sed.basic_rate=sed.incoming_rate, sed.basic_amount=sed.amount
where sed.parent = se.name
and (se.purpose not in ('Manufacture', 'Repack') or ifnull(additional_operating_cost, 0)=0)
""")
stock_entry_db_columns = frappe.db.get_table_columns("Stock Entry")
if "additional_operating_cost" in stock_entry_db_columns:
operating_cost_fieldname = "additional_operating_cost"
@@ -25,6 +19,13 @@ def execute():
return
frappe.db.sql("""update `tabStock Entry Detail` sed, `tabStock Entry` se
set sed.valuation_rate=sed.incoming_rate, sed.basic_rate=sed.incoming_rate, sed.basic_amount=sed.amount
where sed.parent = se.name
and (se.purpose not in ('Manufacture', 'Repack') or ifnull({0}, 0)=0)
""".format(operating_cost_fieldname))
stock_entries = frappe.db.sql_list("""select name from `tabStock Entry`
where purpose in ('Manufacture', 'Repack') and ifnull({0}, 0)!=0
and docstatus < 2""".format(operating_cost_fieldname))

View File

@@ -55,9 +55,6 @@ def migrate_manage_variants():
template.set('attributes', attributes)
template.save()
frappe.delete_doc("DocType", "Manage Variants")
frappe.delete_doc("DocType", "Manage Variants Item")
# patch old style
def migrate_item_variants():
for item in frappe.get_all("Item", filters={"has_variants": 1}):
@@ -65,6 +62,12 @@ def migrate_item_variants():
item_attributes = frappe.db.sql("""select distinct item_attribute, item_attribute_value
from `tabItem Variant` where parent=%s""", item.name)
if not item_attributes and not all_variants:
item = frappe.get_doc("Item", item.name)
item.has_variants = 0
item.save()
continue
attribute_value_options = {}
for attribute, value in item_attributes:
attribute_value_options.setdefault(attribute, []).append(value)

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,14 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
from frappe import _
def execute():
for print_heading in (_("Credit Note"), _("Debit Note")):
if not frappe.db.exists("Print Heading", print_heading):
frappe.get_doc({
"doctype": "Print Heading",
"print_heading": print_heading
}).insert()

View File

@@ -0,0 +1,88 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doctype("Sales Order Item")
frappe.reload_doctype("Purchase Order Item")
# sales return
return_entries = list(frappe.db.sql("""
select dn.name as name, dn_item.name as row_id, dn.return_against,
dn_item.item_code, "Delivery Note" as doctype
from `tabDelivery Note Item` dn_item, `tabDelivery Note` dn
where dn_item.parent=dn.name and dn.is_return=1 and dn.docstatus < 2
""", as_dict=1))
return_entries += list(frappe.db.sql("""
select si.name as name, si_item.name as row_id, si.return_against,
si_item.item_code, "Sales Invoice" as doctype, update_stock
from `tabSales Invoice Item` si_item, `tabSales Invoice` si
where si_item.parent=si.name and si.is_return=1 and si.docstatus < 2
""", as_dict=1))
for d in return_entries:
ref_field = "against_sales_order" if d.doctype == "Delivery Note" else "sales_order"
order_details = frappe.db.sql("""
select {ref_field} as sales_order, so_detail,
(select transaction_date from `tabSales Order` where name=item.{ref_field}) as sales_order_date
from `tab{doctype} Item` item
where
parent=%s
and item_code=%s
and ifnull(so_detail, '') !=''
order by sales_order_date DESC limit 1
""".format(ref_field=ref_field, doctype=d.doctype), (d.return_against, d.item_code), as_dict=1)
if order_details:
frappe.db.sql("""
update `tab{doctype} Item`
set {ref_field}=%s, so_detail=%s
where name=%s
""".format(doctype=d.doctype, ref_field=ref_field),
(order_details[0].sales_order, order_details[0].so_detail, d.row_id))
if (d.doctype=="Sales Invoice" and d.update_stock) or d.doctype=="Delivery Note":
doc = frappe.get_doc(d.doctype, d.name)
doc.update_reserved_qty()
if d.doctype=="Sales Invoice":
doc.status_updater = []
doc.update_status_updater_args()
doc.update_prevdoc_status()
#--------------------------
# purchase return
return_entries = frappe.db.sql("""
select pr.name as name, pr_item.name as row_id, pr.return_against, pr_item.item_code
from `tabPurchase Receipt Item` pr_item, `tabPurchase Receipt` pr
where pr_item.parent=pr.name and pr.is_return=1 and pr.docstatus < 2
""", as_dict=1)
for d in return_entries:
order_details = frappe.db.sql("""
select prevdoc_docname as purchase_order, prevdoc_detail_docname as po_detail,
(select transaction_date from `tabPurchase Order` where name=item.prevdoc_detail_docname) as purchase_order_date
from `tabPurchase Receipt Item` item
where
parent=%s
and item_code=%s
and ifnull(prevdoc_detail_docname, '') !=''
and ifnull(prevdoc_doctype, '') = 'Purchase Order' and ifnull(prevdoc_detail_docname, '') != ''
order by purchase_order_date DESC limit 1
""", (d.return_against, d.item_code), as_dict=1)
if order_details:
frappe.db.sql("""
update `tabPurchase Receipt Item`
set prevdoc_doctype='Purchase Order', prevdoc_docname=%s, prevdoc_detail_docname=%s
where name=%s
""", (order_details[0].purchase_order, order_details[0].po_detail, d.row_id))
pr = frappe.get_doc("Purchase Receipt", d.name)
pr.update_ordered_qty()
pr.update_prevdoc_status()

View File

@@ -88,6 +88,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
this.set_dynamic_labels();
erpnext.pos.make_pos_btn(this.frm);
this.setup_sms();
this.make_show_payments_btn();
},
apply_default_taxes: function() {
@@ -123,6 +124,22 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
var sms_man = new SMSManager(this.frm.doc);
},
make_show_payments_btn: function() {
var me = this;
if (in_list(["Purchase Invoice", "Sales Invoice"], this.frm.doctype)) {
if(this.frm.doc.outstanding_amount !== this.frm.doc.base_grand_total) {
this.frm.add_custom_button(__("Show Payments"), function() {
frappe.route_options = {
"Journal Entry Account.reference_type": me.frm.doc.doctype,
"Journal Entry Account.reference_name": me.frm.doc.name
};
frappe.set_route("List", "Journal Entry");
});
}
}
},
hide_currency_and_price_list: function() {
if(this.frm.doc.conversion_rate == 1 && this.frm.doc.docstatus > 0) {
hide_field("currency_and_price_list");

View File

@@ -8,6 +8,7 @@ import frappe.utils
from frappe.utils import cstr, flt, getdate, comma_and
from frappe import _
from frappe.model.mapper import get_mapped_doc
from erpnext.stock.stock_balance import update_bin_qty, get_reserved_qty
from erpnext.controllers.selling_controller import SellingController
@@ -151,7 +152,7 @@ class SalesOrder(SellingController):
super(SalesOrder, self).on_submit()
self.check_credit_limit()
self.update_stock_ledger(update_stock = 1)
self.update_reserved_qty()
frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype, self.base_grand_total, self)
@@ -164,7 +165,7 @@ class SalesOrder(SellingController):
frappe.throw(_("Stopped order cannot be cancelled. Unstop to cancel."))
self.check_nextdoc_docstatus()
self.update_stock_ledger(update_stock = -1)
self.update_reserved_qty()
self.update_prevdoc_status('cancel')
@@ -213,32 +214,38 @@ class SalesOrder(SellingController):
def stop_sales_order(self):
self.check_modified_date()
self.update_stock_ledger(-1)
frappe.db.set(self, 'status', 'Stopped')
self.update_reserved_qty()
frappe.msgprint(_("{0} {1} status is Stopped").format(self.doctype, self.name))
self.notify_modified()
def unstop_sales_order(self):
self.check_modified_date()
self.update_stock_ledger(1)
frappe.db.set(self, 'status', 'Submitted')
self.update_reserved_qty()
frappe.msgprint(_("{0} {1} status is Unstopped").format(self.doctype, self.name))
def update_reserved_qty(self, so_item_rows=None):
"""update requested qty (before ordered_qty is updated)"""
item_wh_list = []
def _valid_for_reserve(item_code, warehouse):
if item_code and warehouse and [item_code, warehouse] not in item_wh_list \
and frappe.db.get_value("Item", item_code, "is_stock_item"):
item_wh_list.append([item_code, warehouse])
for d in self.get("items"):
if (not so_item_rows or d.name in so_item_rows):
_valid_for_reserve(d.item_code, d.warehouse)
if self.has_product_bundle(d.item_code):
for p in self.get("packed_items"):
if p.parent_detail_docname == d.name and p.parent_item == d.item_code:
_valid_for_reserve(p.item_code, p.warehouse)
def update_stock_ledger(self, update_stock):
from erpnext.stock.utils import update_bin
for d in self.get_item_list():
if frappe.db.get_value("Item", d['item_code'], "is_stock_item")==1:
args = {
"item_code": d['item_code'],
"warehouse": d['reserved_warehouse'],
"reserved_qty": flt(update_stock) * flt(d['reserved_qty']),
"posting_date": self.transaction_date,
"voucher_type": self.doctype,
"voucher_no": self.name,
"is_amended": self.amended_from and 'Yes' or 'No'
}
update_bin(args)
for item_code, warehouse in item_wh_list:
update_bin_qty(item_code, warehouse, {
"reserved_qty": get_reserved_qty(item_code, warehouse)
})
def on_update(self):
pass

View File

@@ -840,6 +840,27 @@
"unique": 0,
"width": "100px"
},
{
"allow_on_submit": 0,
"depends_on": "returned_qty",
"fieldname": "returned_qty",
"fieldtype": "Float",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Returned Qty",
"no_copy": 1,
"permlevel": 0,
"precision": "",
"print_hide": 1,
"read_only": 1,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"fieldname": "billed_amt",
@@ -960,7 +981,7 @@
"is_submittable": 0,
"issingle": 0,
"istable": 1,
"modified": "2015-08-19 12:46:32.930498",
"modified": "2015-08-25 06:42:11.062909",
"modified_by": "Administrator",
"module": "Selling",
"name": "Sales Order Item",

View File

@@ -1,17 +1,19 @@
{
"apply_user_permissions": 1,
"creation": "2012-10-04 18:45:27",
"docstatus": 0,
"doctype": "Report",
"idx": 1,
"is_standard": "Yes",
"modified": "2014-07-14 07:18:17.006732",
"modified_by": "Administrator",
"module": "Selling",
"name": "Customer Addresses and Contacts",
"owner": "Administrator",
"query": "SELECT\n\t`tabCustomer`.name as customer_id,\n\t`tabCustomer`.customer_name,\n\t`tabCustomer`.customer_group,\n\t`tabAddress`.address_line1,\n\t`tabAddress`.address_line2,\n\t`tabAddress`.city,\n\t`tabAddress`.state,\n\t`tabAddress`.pincode,\n\t`tabAddress`.country,\n\t`tabAddress`.is_primary_address, \n\t`tabContact`.first_name,\n\t`tabContact`.last_name,\n\t`tabContact`.phone,\n\t`tabContact`.mobile_no,\n\t`tabContact`.email_id,\n\t`tabContact`.is_primary_contact\nFROM\n\t`tabCustomer`\n\tleft join `tabAddress` on (\n\t\t`tabAddress`.customer=`tabCustomer`.name\n\t)\n\tleft join `tabContact` on (\n\t\t`tabContact`.customer=`tabCustomer`.name\n\t)\nWHERE\n\t`tabCustomer`.docstatus<2\nORDER BY\n\t`tabCustomer`.name asc",
"ref_doctype": "Customer",
"report_name": "Customer Addresses And Contacts",
"add_total_row": 0,
"apply_user_permissions": 1,
"creation": "2012-10-04 18:45:27",
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"idx": 1,
"is_standard": "Yes",
"modified": "2015-08-24 11:44:00.711112",
"modified_by": "Administrator",
"module": "Selling",
"name": "Customer Addresses And Contacts",
"owner": "Administrator",
"query": "SELECT\n\t`tabCustomer`.name as \"Customer ID:Link/Customer\",\n\t`tabCustomer`.customer_name as \"Customer Name\",\n\t`tabCustomer`.customer_group as \"Customer Group:Link/Customer Group\",\n\t`tabAddress`.address_line1 as \"Address Line 1\",\n\t`tabAddress`.address_line2 as \"Address Line 2\",\n\t`tabAddress`.city as \"City\",\n\t`tabAddress`.state as \"State\",\n\t`tabAddress`.pincode as \"Postal Code\",\n\t`tabAddress`.country as \"Country\",\n\t`tabAddress`.is_primary_address as \"Is Primary Address:Check\", \n\t`tabContact`.first_name as \"First Name\",\n\t`tabContact`.last_name as \"Last Name\",\n\t`tabContact`.phone as \"Phone\",\n\t`tabContact`.mobile_no as \"Mobile No\",\n\t`tabContact`.email_id as \"Email Id\",\n\t`tabContact`.is_primary_contact as \"Is Primary Contact:Check\"\nFROM\n\t`tabCustomer`\n\tleft join `tabAddress` on (\n\t\t`tabAddress`.customer=`tabCustomer`.name\n\t)\n\tleft join `tabContact` on (\n\t\t`tabContact`.customer=`tabCustomer`.name\n\t)\nWHERE\n\t`tabCustomer`.docstatus<2\nORDER BY\n\t`tabCustomer`.name asc",
"ref_doctype": "Customer",
"report_name": "Customer Addresses And Contacts",
"report_type": "Query Report"
}
}

View File

@@ -41,15 +41,15 @@ def install(country=None):
{'doctype': 'Expense Claim Type', 'name': _('Travel'), 'expense_type': _('Travel')},
# leave type
{'doctype': 'Leave Type', 'leave_type_name': _('Casual Leave'), 'name': _('Casual Leave'),
{'doctype': 'Leave Type', 'leave_type_name': _('Casual Leave'), 'name': _('Casual Leave'),
'is_encash': 1, 'is_carry_forward': 1, 'max_days_allowed': '3', 'include_holiday': 1},
{'doctype': 'Leave Type', 'leave_type_name': _('Compensatory Off'), 'name': _('Compensatory Off'),
{'doctype': 'Leave Type', 'leave_type_name': _('Compensatory Off'), 'name': _('Compensatory Off'),
'is_encash': 0, 'is_carry_forward': 0, 'include_holiday': 1},
{'doctype': 'Leave Type', 'leave_type_name': _('Sick Leave'), 'name': _('Sick Leave'),
{'doctype': 'Leave Type', 'leave_type_name': _('Sick Leave'), 'name': _('Sick Leave'),
'is_encash': 0, 'is_carry_forward': 0, 'include_holiday': 1},
{'doctype': 'Leave Type', 'leave_type_name': _('Privilege Leave'), 'name': _('Privilege Leave'),
{'doctype': 'Leave Type', 'leave_type_name': _('Privilege Leave'), 'name': _('Privilege Leave'),
'is_encash': 0, 'is_carry_forward': 0, 'include_holiday': 1},
{'doctype': 'Leave Type', 'leave_type_name': _('Leave Without Pay'), 'name': _('Leave Without Pay'),
{'doctype': 'Leave Type', 'leave_type_name': _('Leave Without Pay'), 'name': _('Leave Without Pay'),
'is_encash': 0, 'is_carry_forward': 0, 'is_lwp':1, 'include_holiday': 1},
# Employment Type
@@ -173,6 +173,8 @@ def install(country=None):
{"doctype": "Offer Term", "offer_term": _("Notice Period")},
{"doctype": "Offer Term", "offer_term": _("Incentives")},
{'doctype': "Print Heading", 'print_heading': _("Credit Note")},
{'doctype': "Print Heading", 'print_heading': _("Debit Note")}
]
from erpnext.setup.page.setup_wizard.fixtures import industry_type

View File

@@ -12,7 +12,7 @@ def make_sample_data():
to help the user get started"""
selling_items = frappe.get_all("Item", filters = {"is_sales_item": 1})
buying_items = frappe.get_all("Item", filters = {"is_sales_item": 0})
buying_items = frappe.get_all("Item", filters = {"is_purchase_item": 1})
if selling_items:
for i in range(3):

View File

@@ -7,7 +7,7 @@
"custom": 0,
"docstatus": 0,
"doctype": "DocType",
"document_type": "Transaction",
"document_type": "Document",
"fields": [
{
"allow_on_submit": 0,
@@ -1080,7 +1080,7 @@
"options": "\nGrand Total\nNet Total",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide": 1,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
@@ -2179,7 +2179,7 @@
"is_submittable": 1,
"issingle": 0,
"istable": 0,
"modified": "2015-08-04 11:56:59.782517",
"modified": "2015-08-24 09:09:59.298127",
"modified_by": "Administrator",
"module": "Stock",
"name": "Delivery Note",

View File

@@ -47,6 +47,19 @@ class DeliveryNote(SellingController):
'source_field': 'qty',
'percent_join_field': 'against_sales_invoice',
'overflow_type': 'delivery'
},
{
'source_dt': 'Delivery Note Item',
'target_dt': 'Sales Order Item',
'join_field': 'so_detail',
'target_field': 'returned_qty',
'target_parent_dt': 'Sales Order',
# 'target_parent_field': 'per_delivered',
# 'target_ref_field': 'qty',
'source_field': '-1 * qty',
# 'percent_join_field': 'against_sales_order',
# 'overflow_type': 'delivery',
'extra_cond': """ and exists (select name from `tabDelivery Note` where name=`tabDelivery Note Item`.parent and is_return=1)"""
}]
def onload(self):
@@ -66,7 +79,7 @@ class DeliveryNote(SellingController):
item_meta = frappe.get_meta("Delivery Note Item")
print_hide_fields = {
"parent": ["grand_total", "rounded_total", "in_words", "currency", "net_total"],
"parent": ["grand_total", "rounded_total", "in_words", "currency", "total", "taxes"],
"items": ["rate", "amount", "price_list_rate", "discount_percentage"]
}
@@ -83,7 +96,7 @@ class DeliveryNote(SellingController):
def so_required(self):
"""check in manage account if sales order required or not"""
if not self.is_return and frappe.db.get_value("Selling Settings", None, 'so_required') == 'Yes':
if frappe.db.get_value("Selling Settings", None, 'so_required') == 'Yes':
for d in self.get('items'):
if not d.against_sales_order:
frappe.throw(_("Sales Order required for Item {0}").format(d.item_code))
@@ -118,7 +131,7 @@ class DeliveryNote(SellingController):
},
})
if cint(frappe.db.get_single_value('Selling Settings', 'maintain_same_sales_rate')):
if cint(frappe.db.get_single_value('Selling Settings', 'maintain_same_sales_rate')) and not self.is_return:
self.validate_rate_with_reference_doc([["Sales Order", "sales_order", "so_detail"],
["Sales Invoice", "sales_invoice", "si_detail"]])
@@ -174,10 +187,10 @@ class DeliveryNote(SellingController):
# Check for Approving Authority
frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype, self.company, self.base_grand_total, self)
if not self.is_return:
# update delivered qty in sales order
self.update_prevdoc_status()
# update delivered qty in sales order
self.update_prevdoc_status()
if not self.is_return:
self.check_credit_limit()
self.update_stock_ledger()
@@ -190,8 +203,7 @@ class DeliveryNote(SellingController):
self.check_stop_sales_order("against_sales_order")
self.check_next_docstatus()
if not self.is_return:
self.update_prevdoc_status()
self.update_prevdoc_status()
self.update_stock_ledger()
@@ -242,25 +254,6 @@ class DeliveryNote(SellingController):
ps.cancel()
frappe.msgprint(_("Packing Slip(s) cancelled"))
def update_stock_ledger(self):
sl_entries = []
for d in self.get_item_list():
if frappe.db.get_value("Item", d.item_code, "is_stock_item") == 1 \
and d.warehouse and flt(d['qty']):
self.update_reserved_qty(d)
incoming_rate = 0
if cint(self.is_return) and self.return_against and self.docstatus==1:
incoming_rate = self.get_incoming_rate_for_sales_return(d.item_code, self.return_against)
sl_entries.append(self.get_sl_entries(d, {
"actual_qty": -1*flt(d['qty']),
"incoming_rate": incoming_rate
}))
self.make_sl_entries(sl_entries)
def get_list_context(context=None):
from erpnext.controllers.website_list_for_contact import get_list_context
list_context = get_list_context(context)
@@ -374,8 +367,8 @@ def make_packing_slip(source_name, target_doc=None):
return doclist
@frappe.whitelist()
def make_sales_return(source_name, target_doc=None):
from erpnext.controllers.sales_and_purchase_return import make_return_doc
return make_return_doc("Delivery Note", source_name, target_doc)
return make_return_doc("Delivery Note", source_name, target_doc)

View File

@@ -3,7 +3,7 @@ frappe.listview_settings['Delivery Note'] = {
"transporter_name", "grand_total", "is_return"],
get_indicator: function(doc) {
if(cint(doc.is_return)==1) {
return [__("Return"), "darkgrey", "is_return,=,1"];
return [__("Return"), "darkgrey", "is_return,=,Yes"];
}
}
};

View File

@@ -912,7 +912,7 @@
"in_filter": 0,
"in_list_view": 1,
"label": "Against Sales Order",
"no_copy": 0,
"no_copy": 1,
"options": "Sales Order",
"permlevel": 0,
"print_hide": 1,
@@ -932,7 +932,7 @@
"in_filter": 0,
"in_list_view": 0,
"label": "Against Sales Invoice",
"no_copy": 0,
"no_copy": 1,
"options": "Sales Invoice",
"permlevel": 0,
"print_hide": 1,
@@ -1039,7 +1039,7 @@
"is_submittable": 0,
"issingle": 0,
"istable": 1,
"modified": "2015-08-19 12:46:31.447022",
"modified": "2015-08-25 07:15:19.811365",
"modified_by": "Administrator",
"module": "Stock",
"name": "Delivery Note Item",

View File

@@ -64,7 +64,7 @@ class Item(WebsiteGenerator):
self.update_item_desc()
self.synced_with_hub = 0
self.validate_has_variants()
self.validate_stock_for_template_must_be_zero()
# self.validate_stock_for_template_must_be_zero()
self.validate_attributes()
self.validate_variant_attributes()
@@ -269,7 +269,7 @@ class Item(WebsiteGenerator):
frappe.db.set_value("Item", newdn, "last_purchase_rate", last_purchase_rate)
def recalculate_bin_qty(self, newdn):
from erpnext.utilities.repost_stock import repost_stock
from erpnext.stock.stock_balance import repost_stock
frappe.db.auto_commit_on_many_writes = 1
existing_allow_negative_stock = frappe.db.get_value("Stock Settings", None, "allow_negative_stock")
frappe.db.set_value("Stock Settings", None, "allow_negative_stock", 1)
@@ -513,12 +513,10 @@ def validate_item_variant_attributes(item, args):
filters={"parent": ["in", args.keys()]}):
(attribute_values.setdefault(t.parent, [])).append(t.attribute_value)
numeric_attributes = frappe._dict((t.name, t) for t in frappe.get_list("Item Attribute", filters={"numeric_values":1,
"name": ["in", args.keys()]}, fields=["name", "from_range", "to_range", "increment"]))
template_item = frappe.get_doc("Item", item)
template_item_attributes = frappe._dict((d.attribute, d) for d in template_item.attributes)
numeric_attributes = frappe._dict((t.attribute, t) for t in \
frappe.db.sql("""select attribute, from_range, to_range, increment from `tabItem Variant Attribute`
where parent = %s and numeric_values=1""", (item), as_dict=1))
for attribute, value in args.items():
if attribute in numeric_attributes:
@@ -531,10 +529,17 @@ def validate_item_variant_attributes(item, args):
if increment == 0:
# defensive validation to prevent ZeroDivisionError
frappe.throw(_("Increment for Attribute {0} cannot be 0").format(attribute))
is_in_range = from_range <= flt(value) <= to_range
precision = len(cstr(increment).split(".")[-1].rstrip("0"))
#avoid precision error by rounding the remainder
remainder = flt((flt(value) - from_range) % increment, precision)
is_incremental = remainder==0 or remainder==0 or remainder==increment
if not ( (from_range <= flt(value) <= to_range) and (flt(value) - from_range) % increment == 0 ):
frappe.throw(_("Value for Attribute {0} must be within the range of {1} to {2} in the increments of {3}").format(attribute, from_range, to_range, increment), InvalidItemAttributeValueError)
if not (is_in_range and is_incremental):
frappe.throw(_("Value for Attribute {0} must be within the range of {1} to {2} in the increments of {3}")\
.format(attribute, from_range, to_range, increment), InvalidItemAttributeValueError)
elif value not in attribute_values[attribute]:
frappe.throw(_("Value {0} for Attribute {1} does not exist in the list of valid Item Attribute Values").format(
@@ -567,7 +572,7 @@ def find_variant(item, args):
for attribute, value in args.items():
for row in variant.attributes:
if row.attribute==attribute and row.attribute_value==value:
if row.attribute==attribute and row.attribute_value== cstr(value):
# this row matches
match_count += 1
break

View File

@@ -6,9 +6,8 @@ import unittest
import frappe
from frappe.test_runner import make_test_records
from erpnext.stock.doctype.item.item import (WarehouseNotSet, ItemTemplateCannotHaveStock, create_variant,
from erpnext.stock.doctype.item.item import (WarehouseNotSet, create_variant,
ItemVariantExistsError, InvalidItemAttributeValueError)
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry
test_ignore = ["BOM"]
test_dependencies = ["Warehouse"]
@@ -46,11 +45,11 @@ class TestItem(unittest.TestCase):
item = frappe.get_doc("Item", item_code)
return item
def test_template_cannot_have_stock(self):
item = self.get_item(10)
make_stock_entry(item_code=item.name, target="Stores - _TC", qty=1, basic_rate=1)
item.has_variants = 1
self.assertRaises(ItemTemplateCannotHaveStock, item.save)
# def test_template_cannot_have_stock(self):
# item = self.get_item(10)
# make_stock_entry(item_code=item.name, target="Stores - _TC", qty=1, basic_rate=1)
# item.has_variants = 1
# self.assertRaises(ItemTemplateCannotHaveStock, item.save)
def test_default_warehouse(self):
item = frappe.copy_doc(test_records[0])
@@ -129,8 +128,16 @@ class TestItem(unittest.TestCase):
# make template item
make_item("_Test Numeric Template Item", {
"attributes": [
{"attribute": "Test Size"},
{"attribute": "Test Item Length"}
{
"attribute": "Test Size"
},
{
"attribute": "Test Item Length",
"numeric_values": 1,
"from_range": 0.0,
"to_range": 100.0,
"increment": 0.5
}
],
"default_warehouse": "_Test Warehouse - _TC"
})

View File

@@ -10,9 +10,11 @@ import frappe
from frappe.utils import cstr, flt, getdate
from frappe import _
from frappe.model.mapper import get_mapped_doc
from erpnext.stock.stock_balance import update_bin_qty, get_indented_qty
from erpnext.controllers.buying_controller import BuyingController
form_grid_templates = {
"items": "templates/form_grid/material_request_grid.html"
}
@@ -136,19 +138,6 @@ class MaterialRequest(BuyingController):
def update_requested_qty(self, mr_item_rows=None):
"""update requested qty (before ordered_qty is updated)"""
from erpnext.stock.utils import get_bin
def _update_requested_qty(item_code, warehouse):
requested_qty = frappe.db.sql("""select sum(mr_item.qty - ifnull(mr_item.ordered_qty, 0))
from `tabMaterial Request Item` mr_item, `tabMaterial Request` mr
where mr_item.item_code=%s and mr_item.warehouse=%s
and mr_item.qty > ifnull(mr_item.ordered_qty, 0) and mr_item.parent=mr.name
and mr.status!='Stopped' and mr.docstatus=1""", (item_code, warehouse))
bin_doc = get_bin(item_code, warehouse)
bin_doc.indented_qty = flt(requested_qty[0][0]) if requested_qty else 0
bin_doc.save()
item_wh_list = []
for d in self.get("items"):
if (not mr_item_rows or d.name in mr_item_rows) and [d.item_code, d.warehouse] not in item_wh_list \
@@ -156,7 +145,9 @@ class MaterialRequest(BuyingController):
item_wh_list.append([d.item_code, d.warehouse])
for item_code, warehouse in item_wh_list:
_update_requested_qty(item_code, warehouse)
update_bin_qty(item_code, warehouse, {
"indented_qty": get_indented_qty(item_code, warehouse)
})
def update_completed_and_requested_qty(stock_entry, method):
if stock_entry.doctype == "Stock Entry":

View File

@@ -29,6 +29,19 @@ class PurchaseReceipt(BuyingController):
'source_field': 'qty',
'percent_join_field': 'prevdoc_docname',
'overflow_type': 'receipt'
},
{
'source_dt': 'Purchase Receipt Item',
'target_dt': 'Purchase Order Item',
'join_field': 'prevdoc_detail_docname',
'target_field': 'returned_qty',
'target_parent_dt': 'Purchase Order',
# 'target_parent_field': 'per_received',
# 'target_ref_field': 'qty',
'source_field': '-1 * qty',
# 'percent_join_field': 'prevdoc_docname',
# 'overflow_type': 'receipt',
'extra_cond': """ and exists (select name from `tabPurchase Receipt` where name=`tabPurchase Receipt Item`.parent and is_return=1)"""
}]
def onload(self):
@@ -68,12 +81,12 @@ class PurchaseReceipt(BuyingController):
from `tabLanded Cost Item`
where docstatus = 1 and purchase_receipt_item = %s""", d.name)
d.landed_cost_voucher_amount = lc_voucher_amount[0][0] if lc_voucher_amount else 0.0
def validate_purchase_return(self):
for d in self.get("items"):
if self.is_return and flt(d.rejected_qty) != 0:
frappe.throw(_("Row #{0}: Rejected Qty can not be entered in Purchase Return").format(d.idx))
# validate rate with ref PR
def validate_rejected_warehouse(self):
@@ -113,11 +126,11 @@ class PurchaseReceipt(BuyingController):
}
})
if cint(frappe.db.get_single_value('Buying Settings', 'maintain_same_rate')):
if cint(frappe.db.get_single_value('Buying Settings', 'maintain_same_rate')) and not self.is_return:
self.validate_rate_with_reference_doc([["Purchase Order", "prevdoc_docname", "prevdoc_detail_docname"]])
def po_required(self):
if not self.is_return and frappe.db.get_value("Buying Settings", None, "po_required") == 'Yes':
if frappe.db.get_value("Buying Settings", None, "po_required") == 'Yes':
for d in self.get('items'):
if not d.prevdoc_docname:
frappe.throw(_("Purchase Order number required for Item {0}").format(d.item_code))
@@ -221,9 +234,10 @@ class PurchaseReceipt(BuyingController):
# Set status as Submitted
frappe.db.set(self, 'status', 'Submitted')
self.update_prevdoc_status()
self.update_ordered_qty()
if not self.is_return:
self.update_prevdoc_status()
self.update_ordered_qty()
purchase_controller.update_last_purchase_rate(self, 1)
self.update_stock_ledger()
@@ -257,12 +271,11 @@ class PurchaseReceipt(BuyingController):
self.update_stock_ledger()
self.update_prevdoc_status()
# Must be called after updating received qty in PO
self.update_ordered_qty()
if not self.is_return:
self.update_prevdoc_status()
# Must be called after updating received qty in PO
self.update_ordered_qty()
pc_obj.update_last_purchase_rate(self, 0)
self.make_gl_entries_on_cancel()
@@ -334,22 +347,21 @@ class PurchaseReceipt(BuyingController):
}))
# divisional loss adjustment
if not self.get("taxes"):
sle_valuation_amount = flt(flt(d.valuation_rate, val_rate_db_precision) * flt(d.qty) * flt(d.conversion_factor),
self.precision("base_net_amount", d))
sle_valuation_amount = flt(flt(d.valuation_rate, val_rate_db_precision) * flt(d.qty) * flt(d.conversion_factor),
self.precision("base_net_amount", d))
distributed_amount = flt(flt(d.base_net_amount, self.precision("base_net_amount", d))) + \
flt(d.landed_cost_voucher_amount) + flt(d.rm_supp_cost)
distributed_amount = flt(flt(d.base_net_amount, self.precision("base_net_amount", d))) + \
flt(d.landed_cost_voucher_amount) + flt(d.rm_supp_cost) + flt(d.item_tax_amount)
divisional_loss = flt(distributed_amount - sle_valuation_amount, self.precision("base_net_amount", d))
if divisional_loss:
gl_entries.append(self.get_gl_dict({
"account": stock_rbnb,
"against": warehouse_account[d.warehouse],
"cost_center": d.cost_center,
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
"debit": divisional_loss
}))
divisional_loss = flt(distributed_amount - sle_valuation_amount, self.precision("base_net_amount", d))
if divisional_loss:
gl_entries.append(self.get_gl_dict({
"account": stock_rbnb,
"against": warehouse_account[d.warehouse],
"cost_center": d.cost_center,
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
"debit": divisional_loss
}))
elif d.warehouse not in warehouse_with_no_account or \
d.rejected_warehouse not in warehouse_with_no_account:
@@ -467,4 +479,4 @@ def get_invoiced_qty_map(purchase_receipt):
@frappe.whitelist()
def make_purchase_return(source_name, target_doc=None):
from erpnext.controllers.sales_and_purchase_return import make_return_doc
return make_return_doc("Purchase Receipt", source_name, target_doc)
return make_return_doc("Purchase Receipt", source_name, target_doc)

View File

@@ -3,7 +3,7 @@ frappe.listview_settings['Purchase Receipt'] = {
"transporter_name", "is_return"],
get_indicator: function(doc) {
if(cint(doc.is_return)==1) {
return [__("Return"), "darkgrey", "is_return,=,1"];
return [__("Return"), "darkgrey", "is_return,=,Yes"];
}
}
};

View File

@@ -33,7 +33,7 @@ class SerialNo(StockController):
self.validate_warehouse()
self.validate_item()
self.on_stock_ledger_entry()
def set_maintenance_status(self):
if not self.warranty_expiry_date and not self.amc_expiry_date:
self.maintenance_status = None
@@ -209,7 +209,7 @@ def validate_serial_no(sle, item_det):
frappe.throw(_("Serial No {0} quantity {1} cannot be a fraction").format(sle.item_code, sle.actual_qty))
if len(serial_nos) and len(serial_nos) != abs(cint(sle.actual_qty)):
frappe.throw(_("{0} Serial Numbers required for Item {0}. Only {0} provided.").format(sle.actual_qty, sle.item_code, len(serial_nos)),
frappe.throw(_("{0} Serial Numbers required for Item {1}. You have provided {2}.").format(sle.actual_qty, sle.item_code, len(serial_nos)),
SerialNoQtyError)
if len(serial_nos) != len(set(serial_nos)):

View File

@@ -80,7 +80,8 @@ class StockEntry(StockController):
for item in self.get("items"):
if not flt(item.qty):
frappe.throw(_("Row {0}: Qty is mandatory").format(item.idx))
if not flt(item.conversion_factor):
frappe.throw(_("Row {0}: UOM Conversion Factor is mandatory").format(item.idx))
item.transfer_qty = flt(item.qty * item.conversion_factor, self.precision("transfer_qty", item))
def validate_item(self):

View File

@@ -88,9 +88,12 @@ def update_stock_ledger_entry(item_code, new_stock_uom, conversion_factor):
if flt(conversion_factor) != flt(1):
frappe.db.sql("""update `tabStock Ledger Entry`
set stock_uom = %s, actual_qty = ifnull(actual_qty,0) * %s
set
stock_uom = %s,
actual_qty = ifnull(actual_qty,0) * %s,
qty_after_transaction = ifnull(qty_after_transaction, 0) * %s
where item_code = %s""",
(new_stock_uom, conversion_factor, item_code))
(new_stock_uom, conversion_factor, conversion_factor, item_code))
else:
frappe.db.sql("""update `tabStock Ledger Entry` set stock_uom=%s
where item_code=%s""", (new_stock_uom, item_code))

View File

@@ -140,7 +140,7 @@ class Warehouse(Document):
self.recalculate_bin_qty(newdn)
def recalculate_bin_qty(self, newdn):
from erpnext.utilities.repost_stock import repost_stock
from erpnext.stock.stock_balance import repost_stock
frappe.db.auto_commit_on_many_writes = 1
existing_allow_negative_stock = frappe.db.get_value("Stock Settings", None, "allow_negative_stock")
frappe.db.set_value("Stock Settings", None, "allow_negative_stock", 1)

View File

@@ -257,6 +257,10 @@ def validate_price_list(args):
def validate_conversion_rate(args, meta):
from erpnext.controllers.accounts_controller import validate_conversion_rate
if (not args.conversion_rate
and args.currency==frappe.db.get_value("Company", args.company, "default_currency")):
args.conversion_rate = 1.0
# validate currency conversion rate
validate_conversion_rate(args.currency, args.conversion_rate,
meta.get_label("conversion_rate"), args.company)

View File

@@ -21,3 +21,5 @@ def send_message(subject="Website Query", message="", sender="", status="Open"):
"sent_or_received": "Received"
})
comm.insert(ignore_permissions=True)
return "okay"

View File

@@ -1,6 +1,6 @@
from setuptools import setup, find_packages
version = "5.7.1"
version = "5.8.1"
with open("requirements.txt", "r") as f:
install_requires = f.readlines()