[Fixes] Drop Shipping

This commit is contained in:
Saurabh
2015-10-19 14:17:52 +05:30
parent 556536615e
commit c6dbe70256
12 changed files with 337 additions and 95 deletions

View File

@@ -37,6 +37,7 @@ status_map = {
["Completed", "eval:self.order_type == 'Maintenance' and self.per_billed == 100 and self.docstatus == 1"],
["Stopped", "eval:self.status=='Stopped'"],
["Cancelled", "eval:self.docstatus==2"],
["Closed", "eval:self.status=='Closed'"],
],
"Purchase Order": [
["Draft", None],
@@ -210,6 +211,16 @@ class StatusUpdater(Document):
def _update_percent_field(self, args):
"""Update percent field in parent transaction"""
unique_transactions = set([d.get(args['percent_join_field']) for d in self.get_all_children(args['source_dt'])])
args["drop_ship_cond"] = ''
if getattr(self, "drop_ship", None):
if self.drop_ship == 1:
args["drop_ship_cond"] = " and is_drop_ship=1 "
else:
if self.doctype=="Delivery Note":
args["drop_ship_cond"] = " and is_drop_ship!=1 "
for name in unique_transactions:
if not name:
@@ -223,7 +234,7 @@ class StatusUpdater(Document):
set %(target_parent_field)s = round((select sum(if(%(target_ref_field)s >
ifnull(%(target_field)s, 0), %(target_field)s,
%(target_ref_field)s))/sum(%(target_ref_field)s)*100
from `tab%(target_dt)s` where parent="%(name)s"), 2) %(set_modified)s
from `tab%(target_dt)s` where parent="%(name)s" %(drop_ship_cond)s), 2) %(set_modified)s
where name='%(name)s'""" % args)
# update field