ERP11
May 9, 2022, 4:36am
1
1)when I am adding new option for order_type in customization form of sales order then I am getting error –You can't set 'Options' for field Order Type
2)when I am trying to cancel sales order ya sales invoice ,any of one…then i am getting error .
1 Like
NCP
May 9, 2022, 5:46am
2
Hi @ERP11 ,
I can’t add an option in Order Type because some methods are called in py and also some if-else conditions apply.
check it, please.
In js:
this.frm.add_custom_button(__('Hold'), () => this.hold_sales_order(), __("Status"))
// close
this.frm.add_custom_button(__('Close'), () => this.close_sales_order(), __("Status"))
}
}
if (flt(doc.per_picked, 6) < 100 && flt(doc.per_delivered, 6) < 100) {
this.frm.add_custom_button(__('Pick List'), () => this.create_pick_list(), __('Create'));
}
const order_is_a_sale = ["Sales", "Shopping Cart"].indexOf(doc.order_type) !== -1;
const order_is_maintenance = ["Maintenance"].indexOf(doc.order_type) !== -1;
// order type has been customised then show all the action buttons
const order_is_a_custom_sale = ["Sales", "Shopping Cart", "Maintenance"].indexOf(doc.order_type) === -1;
// delivery note
if(flt(doc.per_delivered, 6) < 100 && (order_is_a_sale || order_is_a_custom_sale) && allow_delivery) {
this.frm.add_custom_button(__('Delivery Note'), () => this.make_delivery_note_based_on_delivery_date(), __('Create'));
this.frm.add_custom_button(__('Work Order'), () => this.make_work_order(), __('Create'));
}
In py:
for d in self.get("items"):
if d.prevdoc_docname:
res = frappe.db.sql(
"select name from `tabQuotation` where name=%s and order_type = %s",
(d.prevdoc_docname, self.order_type),
)
if not res:
frappe.msgprint(_("Quotation {0} not of type {1}").format(d.prevdoc_docname, self.order_type))
def validate_delivery_date(self):
if self.order_type == "Sales" and not self.skip_delivery_note:
delivery_date_list = [d.delivery_date for d in self.get("items") if d.delivery_date]
max_delivery_date = max(delivery_date_list) if delivery_date_list else None
if (max_delivery_date and not self.delivery_date) or (
max_delivery_date and getdate(self.delivery_date) != getdate(max_delivery_date)
):
self.delivery_date = max_delivery_date
if self.delivery_date:
for d in self.get("items"):
if not d.delivery_date:
d.delivery_date = self.delivery_date
if source.company_address:
target.update({"company_address": source.company_address})
else:
# set company address
target.update(get_company_address(target.company))
if target.company_address:
target.update(get_fetch_values("Sales Invoice", "company_address", target.company_address))
# set the redeem loyalty points if provided via shopping cart
if source.loyalty_points and source.order_type == "Shopping Cart":
target.redeem_loyalty_points = 1
def update_item(source, target, source_parent):
target.amount = flt(source.amount) - flt(source.billed_amt)
target.base_amount = target.amount * flt(source_parent.conversion_rate)
target.qty = (
target.amount / flt(source.rate)
if (source.rate and source.billed_amt)
else source.qty - source.returned_qty
)
[Edit]
Otherwise added a new custom field and set an option your according.
Thanks.
ERP11
May 9, 2022, 6:15am
3
@NCP Okay thanks…i will check.
I just tried this and having the same issue. Any resolution on this?