I am collecting materials in a custom app (eggs). These are usually counted in unit quantity (integer) and then stored in inventory as “dozen”. I can’t seem to get the conversion table running correctly. Shouldn’t the conversion happen automatically? I’m not opposed to writing code to make this work correctly but I don’t want to duplicate efforts when there seems to be a built-in utility.
def pass_to_stock(self):
# this appears to be working except for the conversion table
# perhaps best approach is to make a modulus and send loose eggs to another Item?
pass_to_stock=frappe.new_doc('Stock Entry')
pass_to_stock.purpose = "Material Receipt"
pass_to_stock.append("items", {
"item_code": self.at_enter_as_item,
"qty": self.batched_egg_yield,
"uom": "Nos",
"stock_uom": self.at_enter_as_uom,
"conversion_factor": "1",
"transfer_qty": self.batched_egg_yield
})
pass_to_stock.company = frappe.db.get_value("Global Defaults", None, "default_company")
pass_to_stock.to_warehouse = "Finished Goods - " + str((frappe.db.get_value("Company", pass_to_stock.company, "abbr")))
pass_to_stock.date = self.collection_date
# pass_to_stock.time = self.time_collected
pass_to_stock.save()