addchild will never save added doc

This commit is contained in:
Anand Doshi
2012-12-24 17:02:38 +05:30
parent acc36be87f
commit f5d90abe92
27 changed files with 386 additions and 376 deletions

View File

@@ -350,7 +350,7 @@ class DocType:
reaches re-order level when %s %s was created""" % (doc_type,doc_name)
indent.save(1)
indent_obj = get_obj('Purchase Request',indent.name,with_children=1)
indent_details_child = addchild(indent_obj.doc,'indent_details','Purchase Request Item',0)
indent_details_child = addchild(indent_obj.doc,'indent_details','Purchase Request Item')
indent_details_child.item_code = self.doc.item_code
indent_details_child.uom = self.doc.stock_uom
indent_details_child.warehouse = self.doc.warehouse

View File

@@ -70,7 +70,8 @@ class DocType:
raise Exception
if not cstr(self.doc.stock_uom) in check_list :
child = addchild( self.doc, 'uom_conversion_details', 'UOM Conversion Detail', 1, self.doclist)
child = addchild( self.doc, 'uom_conversion_details',
'UOM Conversion Detail', self.doclist)
child.uom = self.doc.stock_uom
child.conversion_factor = 1
child.save()

View File

@@ -51,7 +51,8 @@ class DocType:
msgprint("Please enter date of shorter duration as there are too many purchase receipt, hence it cannot be loaded.", raise_exception=1)
for i in pr:
ch = addchild(self.doc, 'lc_pr_details', 'Landed Cost Purchase Receipt', 1, self.doclist)
ch = addchild(self.doc, 'lc_pr_details', 'Landed Cost Purchase Receipt',
self.doclist)
ch.purchase_receipt = i and i['name'] or ''
ch.save()
@@ -62,7 +63,8 @@ class DocType:
idx = 0
landed_cost = sql("select account_head, description from `tabLanded Cost Master Detail` where parent=%s", (self.doc.landed_cost), as_dict = 1)
for cost in landed_cost:
lct = addchild(self.doc, 'landed_cost_details', 'Landed Cost Item', 1, self.doclist)
lct = addchild(self.doc, 'landed_cost_details', 'Landed Cost Item',
self.doclist)
lct.account_head = cost['account_head']
lct.description = cost['description']
@@ -100,7 +102,7 @@ class DocType:
pr_oc_row = sql("select name from `tabPurchase Taxes and Charges` where parent = %s and category = 'Valuation' and add_deduct_tax = 'Add' and charge_type = 'Actual' and account_head = %s",(pr, lc.account_head))
if not pr_oc_row: # add if not exists
ch = addchild(pr_obj.doc, 'purchase_tax_details', 'Purchase Taxes and Charges', 1)
ch = addchild(pr_obj.doc, 'purchase_tax_details', 'Purchase Taxes and Charges')
ch.category = 'Valuation'
ch.add_deduct_tax = 'Add'
ch.charge_type = 'Actual'

View File

@@ -390,7 +390,7 @@ class DocType(TransactionBase):
if i and not sql("select name from `tabPurchase Receipt Item Supplied` where reference_name = '%s' and bom_detail_no = '%s' and parent = '%s' " %(d.name, i[6], self.doc.name)):
rm_child = addchild(self.doc, 'pr_raw_material_details', 'Purchase Receipt Item Supplied', 1, self.doclist)
rm_child = addchild(self.doc, 'pr_raw_material_details', 'Purchase Receipt Item Supplied', self.doclist)
rm_child.reference_name = d.name
rm_child.bom_detail_no = i and i[6] or ''

View File

@@ -8,11 +8,11 @@
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import webnotes
@@ -26,45 +26,46 @@ sql = webnotes.conn.sql
class DocType :
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
# Pull Item Details
# ---------------------------
def pull_item_details(self):
if self.doc.return_type == 'Sales Return':
if self.doc.delivery_note_no:
det = sql("select t1.name, t1.item_code, t1.description, t1.qty, t1.uom, t2.export_rate * t3.conversion_rate, t3.customer, t3.customer_name, t3.customer_address, t2.serial_no, t2.batch_no from `tabDelivery Note Packing Item` t1, `tabDelivery Note Item` t2, `tabDelivery Note` t3 where t1.parent = t3.name and t2.parent = t3.name and t1.parent_detail_docname = t2.name and t3.name = '%s' and t3.docstatus = 1" % self.doc.delivery_note_no)
elif self.doc.sales_invoice_no:
det = sql("select t1.name, t1.item_code, t1.description, t1.qty, t1.stock_uom, t1.export_rate * t2.conversion_rate, t2.customer, t2.customer_name, t2.customer_address, t1.serial_no from `tabSales Invoice Item` t1, `tabSales Invoice` t2 where t1.parent = t2.name and t2.name = '%s' and t2.docstatus = 1" % self.doc.sales_invoice_no)
elif self.doc.return_type == 'Purchase Return' and self.doc.purchase_receipt_no:
det = sql("select t1.name, t1.item_code, t1.description, t1.received_qty, t1.uom, t1.purchase_rate, t2.supplier, t2.supplier_name, t2.supplier_address, t1.serial_no, t1.batch_no from `tabPurchase Receipt Item` t1, `tabPurchase Receipt` t2 where t1.parent = t2.name and t2.name = '%s' and t2.docstatus = 1" % self.doc.purchase_receipt_no)
# Pull Item Details
# ---------------------------
def pull_item_details(self):
if self.doc.return_type == 'Sales Return':
if self.doc.delivery_note_no:
det = sql("select t1.name, t1.item_code, t1.description, t1.qty, t1.uom, t2.export_rate * t3.conversion_rate, t3.customer, t3.customer_name, t3.customer_address, t2.serial_no, t2.batch_no from `tabDelivery Note Packing Item` t1, `tabDelivery Note Item` t2, `tabDelivery Note` t3 where t1.parent = t3.name and t2.parent = t3.name and t1.parent_detail_docname = t2.name and t3.name = '%s' and t3.docstatus = 1" % self.doc.delivery_note_no)
elif self.doc.sales_invoice_no:
det = sql("select t1.name, t1.item_code, t1.description, t1.qty, t1.stock_uom, t1.export_rate * t2.conversion_rate, t2.customer, t2.customer_name, t2.customer_address, t1.serial_no from `tabSales Invoice Item` t1, `tabSales Invoice` t2 where t1.parent = t2.name and t2.name = '%s' and t2.docstatus = 1" % self.doc.sales_invoice_no)
elif self.doc.return_type == 'Purchase Return' and self.doc.purchase_receipt_no:
det = sql("select t1.name, t1.item_code, t1.description, t1.received_qty, t1.uom, t1.purchase_rate, t2.supplier, t2.supplier_name, t2.supplier_address, t1.serial_no, t1.batch_no from `tabPurchase Receipt Item` t1, `tabPurchase Receipt` t2 where t1.parent = t2.name and t2.name = '%s' and t2.docstatus = 1" % self.doc.purchase_receipt_no)
self.doc.cust_supp = det and det[0][6] or ''
self.doc.cust_supp_name = det and det[0][7] or ''
self.doc.cust_supp_address = det and det[0][8] or ''
self.create_item_table(det)
self.doc.save()
# Create Item Table
# -----------------------------
def create_item_table(self, det):
self.doclist = self.doc.clear_table(self.doclist, 'return_details', 1)
for i in det:
ch = addchild(self.doc, 'return_details', 'Sales and Purchase Return Item', 1, self.doclist)
ch.detail_name = i and i[0] or ''
ch.item_code = i and i[1] or ''
ch.description = i and i[2] or ''
ch.qty = i and flt(i[3]) or 0
ch.uom = i and i[4] or ''
ch.rate = i and flt(i[5]) or 0
ch.serial_no = i and i[9] or ''
ch.batch_no = (len(i) == 11) and i[10] or ''
ch.save()
self.doc.cust_supp = det and det[0][6] or ''
self.doc.cust_supp_name = det and det[0][7] or ''
self.doc.cust_supp_address = det and det[0][8] or ''
self.create_item_table(det)
self.doc.save()
# Create Item Table
# -----------------------------
def create_item_table(self, det):
self.doclist = self.doc.clear_table(self.doclist, 'return_details', 1)
for i in det:
ch = addchild(self.doc, 'return_details', 'Sales and Purchase Return Item',
self.doclist)
ch.detail_name = i and i[0] or ''
ch.item_code = i and i[1] or ''
ch.description = i and i[2] or ''
ch.qty = i and flt(i[3]) or 0
ch.uom = i and i[4] or ''
ch.rate = i and flt(i[5]) or 0
ch.serial_no = i and i[9] or ''
ch.batch_no = (len(i) == 11) and i[10] or ''
ch.save()
# Clear return table
# --------------------------------
def clear_return_table(self):
self.doclist = self.doc.clear_table(self.doclist, 'return_details', 1)
self.doc.save()
# Clear return table
# --------------------------------
def clear_return_table(self):
self.doclist = self.doc.clear_table(self.doclist, 'return_details', 1)
self.doc.save()

View File

@@ -467,7 +467,8 @@ class DocType(TransactionBase):
def add_to_stock_entry_detail(self, source_wh, target_wh, item_dict, bom_no=None):
for d in item_dict:
se_child = addchild(self.doc, 'mtn_details', 'Stock Entry Detail', 0, self.doclist)
se_child = addchild(self.doc, 'mtn_details', 'Stock Entry Detail',
self.doclist)
se_child.s_warehouse = source_wh
se_child.t_warehouse = target_wh
se_child.item_code = cstr(d)