From 72a178a37e5ca8ad9ede5c72128a9a0fb58d5289 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 18 Jun 2014 12:14:17 +0530 Subject: [PATCH 1/7] Fixed Currency Exchange error --- erpnext/setup/doctype/currency/currency.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/erpnext/setup/doctype/currency/currency.py b/erpnext/setup/doctype/currency/currency.py index 5be618b80e..abfbe1930c 100644 --- a/erpnext/setup/doctype/currency/currency.py +++ b/erpnext/setup/doctype/currency/currency.py @@ -17,8 +17,5 @@ def validate_conversion_rate(currency, conversion_rate, conversion_rate_label, c company_currency = frappe.db.get_value("Company", company, "default_currency") if not conversion_rate: - throw(_('%(conversion_rate_label)s is mandatory. Maybe Currency Exchange record is not created for %(from_currency)s to %(to_currency)s') % { - "conversion_rate_label": conversion_rate_label, - "from_currency": currency, - "to_currency": company_currency - }) + throw(_("{0} is mandatory. Maybe Currency Exchange record is not created for {1} to {2}.").format( + conversion_rate_label, currency, company_currency)) From 2f800521cb9db1aa3d96e240d1a0f22b7a529994 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 18 Jun 2014 12:48:46 +0530 Subject: [PATCH 2/7] Don't set default for warehouse when creating serial no --- erpnext/stock/doctype/serial_no/serial_no.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/serial_no/serial_no.py b/erpnext/stock/doctype/serial_no/serial_no.py index ff4d519cf9..fe4af21d78 100644 --- a/erpnext/stock/doctype/serial_no/serial_no.py +++ b/erpnext/stock/doctype/serial_no/serial_no.py @@ -278,13 +278,16 @@ def get_serial_nos(serial_no): def make_serial_no(serial_no, sle): sr = frappe.new_doc("Serial No") + sr.warehouse = None + sr.dont_update_if_missing.append("warehouse") sr.ignore_permissions = True + sr.serial_no = serial_no sr.item_code = sle.item_code - sr.warehouse = None sr.company = sle.company sr.via_stock_ledger = True sr.insert() + sr.warehouse = sle.warehouse sr.status = "Available" sr.save() From 297939325a49f51140971f99c5f240162b656f36 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 18 Jun 2014 13:10:10 +0530 Subject: [PATCH 3/7] Stock Entry: get fg item incoming rate if bom is mentioned --- .../stock/doctype/stock_entry/stock_entry.py | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index 3df78c8def..1dc624f21e 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -217,8 +217,8 @@ class StockEntry(StockController): Available Qty: {4}, Transfer Qty: {5}""").format(d.idx, d.s_warehouse, self.posting_date, self.posting_time, d.actual_qty, d.transfer_qty)) - # get incoming rate if not d.bom_no: + # set incoming rate if not flt(d.incoming_rate) or d.s_warehouse or self.purpose == "Sales Return": incoming_rate = self.get_incoming_rate(args) if flt(incoming_rate) > 0: @@ -227,15 +227,16 @@ class StockEntry(StockController): d.amount = flt(d.transfer_qty) * flt(d.incoming_rate) raw_material_cost += flt(d.amount) - # set incoming rate for fg item - if self.production_order and self.purpose == "Manufacture/Repack": - for d in self.get("mtn_details"): - if d.bom_no: - if not flt(d.incoming_rate): - bom = frappe.db.get_value("BOM", d.bom_no, ["operating_cost", "quantity"], as_dict=1) - operation_cost_per_unit = flt(bom.operating_cost) / flt(bom.quantity) - d.incoming_rate = operation_cost_per_unit + (raw_material_cost / flt(d.transfer_qty)) - d.amount = flt(d.transfer_qty) * flt(d.incoming_rate) + # bom no exists and purpose is Manufacture/Repack + elif self.purpose == "Manufacture/Repack": + + # set incoming rate for fg item + if not flt(d.incoming_rate): + bom = frappe.db.get_value("BOM", d.bom_no, ["operating_cost", "quantity"], as_dict=1) + operation_cost_per_unit = flt(bom.operating_cost) / flt(bom.quantity) + d.incoming_rate = operation_cost_per_unit + (raw_material_cost / flt(d.transfer_qty)) + + d.amount = flt(d.transfer_qty) * flt(d.incoming_rate) def get_incoming_rate(self, args): incoming_rate = 0 From c5dbf0f8ad5a926cffa75206899b531379573e46 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 18 Jun 2014 13:35:37 +0530 Subject: [PATCH 4/7] Travis: Install frappe of targetted branch For example: If pull request is for wip-4.1 branch of erpnext, install frappe with branch as wip-4.1 --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 59acb5c0e4..dba0dab6ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,9 +14,13 @@ install: - sudo apt-get update - sudo apt-get purge -y mysql-common - sudo apt-get install mariadb-server mariadb-common libmariadbclient-dev - - CFLAGS=-O0 pip install git+https://github.com/frappe/frappe.git@develop && + - CFLAGS=-O0 pip install git+https://github.com/frappe/frappe.git@$TRAVIS_BRANCH && - pip install --editable . +before_script: + - mysql -e 'create database test_frappe' + - echo "USE mysql;\nCREATE USER 'test_frappe'@'localhost' IDENTIFIED BY 'test_frappe';\nFLUSH PRIVILEGES;\n" | mysql -u root + script: - cd ./test_sites/ - frappe --use test_site @@ -25,7 +29,3 @@ script: - frappe -b - frappe --serve_test & - frappe --verbose --run_tests --app erpnext - -before_script: - - mysql -e 'create database test_frappe' - - echo "USE mysql;\nCREATE USER 'test_frappe'@'localhost' IDENTIFIED BY 'test_frappe';\nFLUSH PRIVILEGES;\n" | mysql -u root From 987a28fc6aeb24eebe94f321d94aaf7cfc303cf5 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 18 Jun 2014 14:05:08 +0530 Subject: [PATCH 5/7] Revert "Stock Entry: get fg item incoming rate if bom is mentioned" This reverts commit 297939325a49f51140971f99c5f240162b656f36. --- .../stock/doctype/stock_entry/stock_entry.py | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index 1dc624f21e..3df78c8def 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -217,8 +217,8 @@ class StockEntry(StockController): Available Qty: {4}, Transfer Qty: {5}""").format(d.idx, d.s_warehouse, self.posting_date, self.posting_time, d.actual_qty, d.transfer_qty)) + # get incoming rate if not d.bom_no: - # set incoming rate if not flt(d.incoming_rate) or d.s_warehouse or self.purpose == "Sales Return": incoming_rate = self.get_incoming_rate(args) if flt(incoming_rate) > 0: @@ -227,16 +227,15 @@ class StockEntry(StockController): d.amount = flt(d.transfer_qty) * flt(d.incoming_rate) raw_material_cost += flt(d.amount) - # bom no exists and purpose is Manufacture/Repack - elif self.purpose == "Manufacture/Repack": - - # set incoming rate for fg item - if not flt(d.incoming_rate): - bom = frappe.db.get_value("BOM", d.bom_no, ["operating_cost", "quantity"], as_dict=1) - operation_cost_per_unit = flt(bom.operating_cost) / flt(bom.quantity) - d.incoming_rate = operation_cost_per_unit + (raw_material_cost / flt(d.transfer_qty)) - - d.amount = flt(d.transfer_qty) * flt(d.incoming_rate) + # set incoming rate for fg item + if self.production_order and self.purpose == "Manufacture/Repack": + for d in self.get("mtn_details"): + if d.bom_no: + if not flt(d.incoming_rate): + bom = frappe.db.get_value("BOM", d.bom_no, ["operating_cost", "quantity"], as_dict=1) + operation_cost_per_unit = flt(bom.operating_cost) / flt(bom.quantity) + d.incoming_rate = operation_cost_per_unit + (raw_material_cost / flt(d.transfer_qty)) + d.amount = flt(d.transfer_qty) * flt(d.incoming_rate) def get_incoming_rate(self, args): incoming_rate = 0 From de12a0941fd36362d6cd5ae5bda82a9c6e1d71e4 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 18 Jun 2014 14:05:29 +0530 Subject: [PATCH 6/7] Stock Entry: get fg item incoming rate if bom is mentioned --- erpnext/stock/doctype/stock_entry/stock_entry.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index 3df78c8def..38c7521e36 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -228,7 +228,7 @@ class StockEntry(StockController): raw_material_cost += flt(d.amount) # set incoming rate for fg item - if self.production_order and self.purpose == "Manufacture/Repack": + if self.purpose == "Manufacture/Repack": for d in self.get("mtn_details"): if d.bom_no: if not flt(d.incoming_rate): From d768afb80b6544db64625b95034ba10eda8add96 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 18 Jun 2014 15:23:25 +0530 Subject: [PATCH 7/7] Fixed Sales Order -> Delivery Note mapping of address fields --- erpnext/selling/doctype/sales_order/sales_order.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index 1b66c65dac..24da5773a3 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -279,13 +279,9 @@ def make_delivery_note(source_name, target_doc=None): target.amount = (flt(source.qty) - flt(source.delivered_qty)) * flt(source.rate) target.qty = flt(source.qty) - flt(source.delivered_qty) - doclist = get_mapped_doc("Sales Order", source_name, { + target_doc = get_mapped_doc("Sales Order", source_name, { "Sales Order": { "doctype": "Delivery Note", - "field_map": { - "shipping_address": "address_display", - "shipping_address_name": "customer_address", - }, "validation": { "docstatus": ["=", 1] } @@ -310,7 +306,7 @@ def make_delivery_note(source_name, target_doc=None): } }, target_doc, set_missing_values) - return doclist + return target_doc @frappe.whitelist() def make_sales_invoice(source_name, target_doc=None):