[fix] [mapper] add rows only table is blank, allow multiple time pull and validation if same item pulled twice
This commit is contained in:
parent
1c88490ff9
commit
a9ec49e0bf
@ -114,16 +114,6 @@ class DocType(BuyingController):
|
||||
ret={'add_tax_rate' :rate and flt(rate[0][0]) or 0 }
|
||||
return ret
|
||||
|
||||
def validate_duplicate_docname(self,doctype):
|
||||
for d in getlist(self.doclist, 'entries'):
|
||||
if doctype == 'purchase_receipt' and cstr(self.doc.purchase_receipt_main) == cstr(d.purchase_receipt):
|
||||
msgprint(cstr(self.doc.purchase_receipt_main) + " purchase receipt details have already been pulled.")
|
||||
raise Exception , " Validation Error. "
|
||||
|
||||
if doctype == 'purchase_order' and cstr(self.doc.purchase_order_main) == cstr(d.purchase_order) and not d.purchase_receipt:
|
||||
msgprint(cstr(self.doc.purchase_order_main) + " purchase order details have already been pulled.")
|
||||
raise Exception , " Validation Error. "
|
||||
|
||||
def check_active_purchase_items(self):
|
||||
for d in getlist(self.doclist, 'entries'):
|
||||
if d.item_code: # extra condn coz item_code is not mandatory in PV
|
||||
|
@ -276,25 +276,6 @@ class DocType(SellingController):
|
||||
|
||||
if self.doc.debit_to:
|
||||
self.doc.customer = webnotes.conn.get_value('Account',self.doc.debit_to,'master_name')
|
||||
|
||||
def update_accounts(self):
|
||||
if not self.doc.debit_to:
|
||||
self.doc.debit_to = self.get_debit_to().get("debit_to")
|
||||
|
||||
self.get_income_expense_account('entries')
|
||||
|
||||
def get_income_expense_account(self,doctype):
|
||||
auto_inventory_accounting = cint(webnotes.defaults.get_global_default("auto_inventory_accounting"))
|
||||
default_cost_center = webnotes.conn.get_value("Company", self.doc.company, "cost_center")
|
||||
for d in getlist(self.doclist, doctype):
|
||||
if d.item_code:
|
||||
item = webnotes.conn.get_value("Item", d.item_code, ["default_income_account",
|
||||
"default_sales_cost_center", "purchase_account"], as_dict=True)
|
||||
d.income_account = item['default_income_account'] or ""
|
||||
d.cost_center = item['default_sales_cost_center'] or default_cost_center
|
||||
|
||||
if auto_inventory_accounting and cint(self.doc.update_stock):
|
||||
d.expense_account = item['purchase_account'] or ""
|
||||
|
||||
def get_barcode_details(self, barcode):
|
||||
return get_obj('Sales Common').get_barcode_details(barcode)
|
||||
|
@ -231,6 +231,7 @@ def make_purchase_receipt(source_name, target_doclist=None):
|
||||
},
|
||||
"Purchase Taxes and Charges": {
|
||||
"doctype": "Purchase Taxes and Charges",
|
||||
"add_if_empty": True
|
||||
}
|
||||
}, target_doclist, set_missing_values)
|
||||
|
||||
@ -271,6 +272,7 @@ def make_purchase_invoice(source_name, target_doclist=None):
|
||||
},
|
||||
"Purchase Taxes and Charges": {
|
||||
"doctype": "Purchase Taxes and Charges",
|
||||
"add_if_empty": True
|
||||
}
|
||||
}, target_doclist, set_missing_values)
|
||||
|
||||
|
@ -102,6 +102,7 @@ def make_purchase_order(source_name, target_doclist=None):
|
||||
},
|
||||
"Purchase Taxes and Charges": {
|
||||
"doctype": "Purchase Taxes and Charges",
|
||||
"add_if_empty": True
|
||||
},
|
||||
}, target_doclist, set_missing_values)
|
||||
|
||||
|
@ -29,6 +29,9 @@ class SellingController(StockController):
|
||||
self.set_missing_values()
|
||||
|
||||
self.set_taxes("other_charges", "charge")
|
||||
|
||||
if self.meta.get_field("debit_to") and not self.doc.debit_to:
|
||||
self.doc.debit_to = self.get_debit_to().get("debit_to")
|
||||
|
||||
def set_missing_values(self, for_validate=False):
|
||||
super(SellingController, self).set_missing_values(for_validate)
|
||||
|
@ -117,7 +117,8 @@ def make_salary_slip(source_name, target_doclist=None):
|
||||
["depend_on_lwp", "d_depends_on_lwp"],
|
||||
["d_modified_amt", "d_amount"],
|
||||
["d_modified_amt", "d_modified_amount"]
|
||||
]
|
||||
],
|
||||
"add_if_empty": True
|
||||
},
|
||||
"Salary Structure Earning": {
|
||||
"doctype": "Salary Slip Earning",
|
||||
@ -125,7 +126,8 @@ def make_salary_slip(source_name, target_doclist=None):
|
||||
["depend_on_lwp", "e_depends_on_lwp"],
|
||||
["modified_value", "e_modified_amount"],
|
||||
["modified_value", "e_amount"]
|
||||
]
|
||||
],
|
||||
"add_if_empty": True
|
||||
}
|
||||
}, target_doclist, postprocess)
|
||||
|
||||
|
@ -52,12 +52,6 @@ class DocType(TransactionBase):
|
||||
sales_com_obj = get_obj(dt = 'Sales Common')
|
||||
sales_com_obj.check_active_sales_items(self)
|
||||
sales_com_obj.get_prevdoc_date(self)
|
||||
|
||||
def validate_prev_docname(self):
|
||||
for d in getlist(self.doclist, 'installed_item_details'):
|
||||
if self.doc.delivery_note_no == d.prevdoc_docname:
|
||||
msgprint(cstr(self.doc.delivery_note_no) +
|
||||
" delivery note details have already been pulled", raise_exception=1)
|
||||
|
||||
def validate_fiscal_year(self):
|
||||
from accounts.utils import validate_fiscal_year
|
||||
|
@ -192,7 +192,8 @@ def make_quotation(source_name, target_doclist=None):
|
||||
"parent": "prevdoc_docname",
|
||||
"parenttype": "prevdoc_doctype",
|
||||
"uom": "stock_uom"
|
||||
}
|
||||
},
|
||||
"add_if_empty": True
|
||||
}
|
||||
}, target_doclist)
|
||||
|
||||
|
@ -235,7 +235,10 @@ def _make_sales_order(source_name, target_doclist=None, ignore_permissions=False
|
||||
if customer:
|
||||
target[0].customer = customer.doc.name
|
||||
target[0].customer_name = customer.doc.customer_name
|
||||
|
||||
|
||||
si = webnotes.bean(target)
|
||||
si.run_method("onload_post_render")
|
||||
|
||||
doclist = get_mapped_doclist("Quotation", source_name, {
|
||||
"Quotation": {
|
||||
"doctype": "Sales Order",
|
||||
@ -247,13 +250,16 @@ def _make_sales_order(source_name, target_doclist=None, ignore_permissions=False
|
||||
"doctype": "Sales Order Item",
|
||||
"field_map": {
|
||||
"parent": "prevdoc_docname"
|
||||
}
|
||||
},
|
||||
"add_if_empty": True
|
||||
},
|
||||
"Sales Taxes and Charges": {
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"add_if_empty": True
|
||||
},
|
||||
"Sales Team": {
|
||||
"doctype": "Sales Team",
|
||||
"add_if_empty": True
|
||||
}
|
||||
}, target_doclist, set_missing_values, ignore_permissions=ignore_permissions)
|
||||
|
||||
|
@ -340,6 +340,10 @@ def get_currency_and_number_format():
|
||||
from tabCurrency where ifnull(enabled,0)=1""")))
|
||||
}
|
||||
|
||||
def set_missing_values(source, target):
|
||||
bean = webnotes.bean(target)
|
||||
bean.run_method("onload_post_render")
|
||||
|
||||
@webnotes.whitelist()
|
||||
def make_material_request(source_name, target_doclist=None):
|
||||
def postprocess(source, doclist):
|
||||
@ -395,11 +399,13 @@ def make_delivery_note(source_name, target_doclist=None):
|
||||
},
|
||||
"Sales Taxes and Charges": {
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"add_if_empty": True
|
||||
},
|
||||
"Sales Team": {
|
||||
"doctype": "Sales Team",
|
||||
"doctype": "Sales Team",
|
||||
"add_if_empty": True
|
||||
}
|
||||
}, target_doclist)
|
||||
}, target_doclist, set_missing_values)
|
||||
|
||||
return [d.fields for d in doclist]
|
||||
|
||||
@ -409,10 +415,6 @@ def make_sales_invoice(source_name, target_doclist=None):
|
||||
target.export_amount = flt(obj.amount) - flt(obj.billed_amt)
|
||||
target.amount = target.export_amount / flt(source_parent.conversion_rate)
|
||||
target.qty = obj.basic_rate and target.amount / flt(obj.basic_rate) or obj.qty
|
||||
|
||||
def update_accounts(source, target):
|
||||
si = webnotes.bean(target)
|
||||
si.run_method("update_accounts")
|
||||
|
||||
doclist = get_mapped_doclist("Sales Order", source_name, {
|
||||
"Sales Order": {
|
||||
@ -433,11 +435,13 @@ def make_sales_invoice(source_name, target_doclist=None):
|
||||
},
|
||||
"Sales Taxes and Charges": {
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"add_if_empty": True
|
||||
},
|
||||
"Sales Team": {
|
||||
"doctype": "Sales Team",
|
||||
"add_if_empty": True
|
||||
}
|
||||
}, target_doclist, update_accounts)
|
||||
}, target_doclist, set_missing_values)
|
||||
|
||||
return [d.fields for d in doclist]
|
||||
|
||||
@ -462,7 +466,8 @@ def make_maintenance_schedule(source_name, target_doclist=None):
|
||||
"doctype": "Maintenance Schedule Item",
|
||||
"field_map": {
|
||||
"parent": "prevdoc_docname"
|
||||
}
|
||||
},
|
||||
"add_if_empty": True
|
||||
}
|
||||
}, target_doclist)
|
||||
|
||||
@ -491,7 +496,8 @@ def make_maintenance_visit(source_name, target_doclist=None):
|
||||
"field_map": {
|
||||
"parent": "prevdoc_docname",
|
||||
"parenttype": "prevdoc_doctype"
|
||||
}
|
||||
},
|
||||
"add_if_empty": True
|
||||
}
|
||||
}, target_doclist)
|
||||
|
||||
|
@ -136,22 +136,19 @@ class DocType(SellingController):
|
||||
def validate_for_items(self):
|
||||
check_list, chk_dupl_itm = [], []
|
||||
for d in getlist(self.doclist,'delivery_note_details'):
|
||||
ch = sql("select is_stock_item from `tabItem` where name = '%s'"%d.item_code)
|
||||
if d.prevdoc_doctype and d.prevdoc_detail_docname and ch and ch[0][0]=='Yes':
|
||||
self.validate_items_with_prevdoc(d)
|
||||
|
||||
# validates whether item is not entered twice
|
||||
e = [d.item_code, d.description, d.warehouse, d.prevdoc_docname or '', d.batch_no or '']
|
||||
f = [d.item_code, d.description, d.prevdoc_docname or '']
|
||||
|
||||
if ch and ch[0][0] == 'Yes':
|
||||
if webnotes.conn.get_value("Item", d.item_code, "is_stock_item") == 'Yes':
|
||||
if e in check_list:
|
||||
msgprint("Please check whether item %s has been entered twice wrongly." % d.item_code)
|
||||
msgprint("Please check whether item %s has been entered twice wrongly."
|
||||
% d.item_code)
|
||||
else:
|
||||
check_list.append(e)
|
||||
elif ch and ch[0][0] == 'No':
|
||||
else:
|
||||
if f in chk_dupl_itm:
|
||||
msgprint("Please check whether item %s has been entered twice wrongly." % d.item_code)
|
||||
msgprint("Please check whether item %s has been entered twice wrongly."
|
||||
% d.item_code)
|
||||
else:
|
||||
chk_dupl_itm.append(f)
|
||||
|
||||
@ -162,16 +159,6 @@ class DocType(SellingController):
|
||||
msgprint("Please enter Warehouse for item %s as it is stock item"
|
||||
% d['item_code'], raise_exception=1)
|
||||
|
||||
def validate_items_with_prevdoc(self, d):
|
||||
"""check if same item, warehouse present in prevdoc"""
|
||||
prev_item_dt = (d.prevdoc_doctype == 'Sales Order') and 'Sales Order Item' or 'Purchase Receipt Item'
|
||||
data = sql("select item_code from `tab%s` where parent = '%s' and name = '%s'"\
|
||||
% (prev_item_dt, d.prevdoc_docname, d.prevdoc_detail_docname))
|
||||
if not data or data[0][0] != d.item_code:
|
||||
msgprint("Item: %s is not matching with Sales Order: %s. Sales Order might be modified after \
|
||||
fetching data from it. Please delete items and fetch again." \
|
||||
% (d.item_code, d.prevdoc_docname), raise_exception=1)
|
||||
|
||||
|
||||
def update_current_stock(self):
|
||||
for d in getlist(self.doclist, 'delivery_note_details'):
|
||||
@ -375,7 +362,7 @@ def make_sales_invoice(source_name, target_doclist=None):
|
||||
|
||||
def update_accounts(source, target):
|
||||
si = webnotes.bean(target)
|
||||
si.run_method("update_accounts")
|
||||
si.run_method("onload_post_render")
|
||||
|
||||
doclist = get_mapped_doclist("Delivery Note", source_name, {
|
||||
"Delivery Note": {
|
||||
@ -397,12 +384,14 @@ def make_sales_invoice(source_name, target_doclist=None):
|
||||
},
|
||||
"Sales Taxes and Charges": {
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"add_if_empty": True
|
||||
},
|
||||
"Sales Team": {
|
||||
"doctype": "Sales Team",
|
||||
"field_map": {
|
||||
"incentives": "incentives"
|
||||
}
|
||||
},
|
||||
"add_if_empty": True
|
||||
}
|
||||
}, target_doclist, update_accounts)
|
||||
|
||||
|
@ -49,12 +49,6 @@ class DocType(BuyingController):
|
||||
def get_bin_details(self, arg = ''):
|
||||
return get_obj(dt='Purchase Common').get_bin_details(arg)
|
||||
|
||||
# validate if PO has been pulled twice
|
||||
def validate_prev_docname(self):
|
||||
for d in getlist(self.doclist, 'purchase_receipt_details'):
|
||||
if self.doc.purchase_order_no and d.prevdoc_docname and self.doc.purchase_order_no == d.prevdoc_docname:
|
||||
msgprint(cstr(self.doc.purchase_order_no) + " Purchase Order details have already been pulled. ")
|
||||
raise Exception
|
||||
|
||||
# validate accepted and rejected qty
|
||||
def validate_accepted_rejected_qty(self):
|
||||
@ -383,6 +377,7 @@ def make_purchase_invoice(source_name, target_doclist=None):
|
||||
},
|
||||
"Purchase Taxes and Charges": {
|
||||
"doctype": "Purchase Taxes and Charges",
|
||||
"add_if_empty": True
|
||||
}
|
||||
}, target_doclist, set_missing_values)
|
||||
|
||||
|
@ -277,12 +277,18 @@ class TransactionBase(StatusUpdater):
|
||||
for key, val in ref.items():
|
||||
is_child = val.get("is_child_table")
|
||||
ref_doc = {}
|
||||
item_ref_dn = []
|
||||
for d in self.doclist.get({"doctype": source_dt}):
|
||||
ref_dn = d.fields.get(val["ref_dn_field"])
|
||||
if ref_dn:
|
||||
if is_child:
|
||||
self.compare_values({key: [ref_dn]}, val["compare_fields"], d)
|
||||
elif ref_dn:
|
||||
if ref_dn not in item_ref_dn:
|
||||
item_ref_dn.append(ref_dn)
|
||||
else:
|
||||
webnotes.msgprint(_("Row ") + cstr(d.idx + 1) +
|
||||
_(": Duplicate row from same ") + key, raise_exception=1)
|
||||
elif ref_dn:
|
||||
ref_doc.setdefault(key, [])
|
||||
if ref_dn not in ref_doc[key]:
|
||||
ref_doc[key].append(ref_dn)
|
||||
|
Loading…
Reference in New Issue
Block a user