fix: shipping_address for non-drop shipping item

This commit is contained in:
s-aga-r 2022-12-26 11:39:58 +05:30
parent 9858d9d968
commit 67a7ccf3ce

View File

@ -1024,6 +1024,15 @@ def make_purchase_order(source_name, selected_items=None, target_doc=None):
]
items_to_map = list(set(items_to_map))
def is_drop_ship_order(target):
drop_ship = True
for item in target.items:
if not item.delivered_by_supplier:
drop_ship = False
break
return drop_ship
def set_missing_values(source, target):
target.supplier = ""
target.apply_discount_on = ""
@ -1031,6 +1040,14 @@ def make_purchase_order(source_name, selected_items=None, target_doc=None):
target.discount_amount = 0.0
target.inter_company_order_reference = ""
target.shipping_rule = ""
if is_drop_ship_order(target):
target.customer = source.customer
target.customer_name = source.customer_name
target.shipping_address = source.shipping_address_name
else:
target.customer = target.customer_name = target.shipping_address = None
target.run_method("set_missing_values")
target.run_method("calculate_taxes_and_totals")
@ -1057,11 +1074,9 @@ def make_purchase_order(source_name, selected_items=None, target_doc=None):
"contact_email",
"contact_person",
"taxes_and_charges",
"shipping_address",
"terms",
],
"field_map": [
["shipping_address_name", "shipping_address"],
],
"validation": {"docstatus": ["=", 1]},
},
"Sales Order Item": {