From 1bfec3a6c8a2da17423a382abfda32e41b62ebba Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 28 Feb 2013 19:17:46 +0530 Subject: [PATCH] buying - update valuation rate when item row has item_code and quantity, else set valuation rate as 0 --- buying/utils.py | 2 +- controllers/buying_controller.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/buying/utils.py b/buying/utils.py index 9d125de24a..0431e642cb 100644 --- a/buying/utils.py +++ b/buying/utils.py @@ -53,7 +53,7 @@ def get_item_details(args): "qty": 0, "stock_uom": item.stock_uom, "uom": item.stock_uom, - "conversion_factor": 1, + "conversion_factor": 1.0, "warehouse": args.warehouse or item.default_warehouse, "item_tax_rate": json.dumps(dict(([d.tax_type, d.tax_rate] for d in item_wrapper.doclist.get({"parentfield": "item_tax"})))), diff --git a/controllers/buying_controller.py b/controllers/buying_controller.py index c49bf2a929..e5b8b07108 100644 --- a/controllers/buying_controller.py +++ b/controllers/buying_controller.py @@ -331,7 +331,9 @@ class BuyingController(AccountsController): # update valuation rate def update_valuation_rate(self, parentfield): for d in self.doclist.get({"parentfield": parentfield}): - if d.qty: + if d.item_code and d.qty: + # if no item code, which is sometimes the case in purchase invoice, + # then it is not possible to track valuation against it d.valuation_rate = (flt(d.purchase_rate or d.rate) + (flt(d.item_tax_amount) + flt(d.rm_supp_cost)) / flt(d.qty) ) / flt(d.conversion_factor)