Merge branch 'master' of github.com:webnotes/erpnext
diff --git a/accounts/doctype/pos_setting/pos_setting.txt b/accounts/doctype/pos_setting/pos_setting.txt
index 80cb1ec..788af9e 100755
--- a/accounts/doctype/pos_setting/pos_setting.txt
+++ b/accounts/doctype/pos_setting/pos_setting.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-04-30 12:58:25",
+ "creation": "2013-05-09 13:16:11",
"docstatus": 0,
- "modified": "2013-05-03 14:36:24",
+ "modified": "2013-05-23 12:52:09",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -213,6 +213,14 @@
"options": "link:Print Heading"
},
{
+ "cancel": 1,
+ "create": 1,
+ "doctype": "DocPerm",
+ "role": "System Manager",
+ "write": 1
+ },
+ {
+ "cancel": 1,
"create": 1,
"doctype": "DocPerm",
"role": "Accounts Manager",
diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py
index d18b967..4c71cb3 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/accounts/doctype/sales_invoice/sales_invoice.py
@@ -74,9 +74,11 @@
self.set_aging_date()
self.set_against_income_account()
self.validate_c_form()
+ self.validate_rate_with_refdoc()
self.validate_time_logs_are_submitted()
self.validate_recurring_invoice()
+
def on_submit(self):
if cint(self.doc.is_pos) == 1:
if cint(self.doc.update_stock) == 1:
@@ -213,8 +215,9 @@
if self.doc.customer:
acc_head = webnotes.conn.sql("""select name from `tabAccount`
where (name = %s or (master_name = %s and master_type = 'customer'))
- and docstatus != 2""",
- (cstr(self.doc.customer) + " - " + self.get_company_abbr(), self.doc.customer))
+ and docstatus != 2 and company = %s""",
+ (cstr(self.doc.customer) + " - " + self.get_company_abbr(),
+ self.doc.customer, self.doc.company))
if acc_head and acc_head[0][0]:
return acc_head[0][0]
@@ -551,6 +554,19 @@
webnotes.conn.set(self.doc, 'c_form_no', '')
+ def validate_rate_with_refdoc(self):
+ """Validate values with reference document with previous document"""
+ for d in self.doclist.get({"parentfield": "entries"}):
+ if d.so_detail:
+ self.check_value("Sales Order", d.so_detail, d.export_rate, d.item_code)
+ if d.dn_detail:
+ self.check_value("Delivery Note", d.dn_detail, d.export_rate, d.item_code)
+
+ def check_value(self, ref_dt, ref_dn, val, item_code):
+ ref_val = webnotes.conn.get_value(ref_dt + "Item", ref_dn, "export_rate")
+ if flt(ref_val) != val:
+ msgprint(_("Rate is not matching with ") + ref_dt + ": " + ref_dn +
+ _(" for item: ") + item_code, raise_exception=True)
def update_current_stock(self):
for d in getlist(self.doclist, 'entries'):