diff --git a/accounts/doctype/pos_setting/pos_setting.txt b/accounts/doctype/pos_setting/pos_setting.txt index 80cb1ecdc9..788af9ee06 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 d18b967dfa..4c71cb3342 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.py +++ b/accounts/doctype/sales_invoice/sales_invoice.py @@ -74,9 +74,11 @@ class DocType(SellingController): 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 @@ class DocType(SellingController): 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 @@ class DocType(SellingController): 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'): diff --git a/selling/doctype/sales_order/sales_order.py b/selling/doctype/sales_order/sales_order.py index 6a52e5a0fa..c8db1f919f 100644 --- a/selling/doctype/sales_order/sales_order.py +++ b/selling/doctype/sales_order/sales_order.py @@ -217,7 +217,10 @@ class DocType(SellingController): self.validate_proj_cust() self.validate_po() #self.validate_reference_value() - self.validate_for_items() + + if self.doc.docstatus == 1: + self.validate_for_items() + sales_com_obj = get_obj(dt = 'Sales Common') sales_com_obj.check_active_sales_items(self) sales_com_obj.check_conversion_rate(self)