snapshot of https://github.com/frappe/crm.git (develop, 2026-09-18; blobs > 131072B omitted)
Some checks failed
Frontend / Unit Tests & Coverage (push) Has been skipped
Server / Tests (frappe ${{ matrix.frappe-branch }}) (push) Has been skipped
Server / Resolve frappe matrix (push) Failing after 1s
Frontend / Lint (push) Failing after 1s
Frontend / Production Build (push) Failing after 1s
Server / Coverage Wrap Up (push) Has been skipped
Frontend / Coverage Wrap Up (push) Has been skipped
Regenerate POT file (translatable strings) / Regenerate POT file (develop) (push) Failing after 1s
Regenerate POT file (translatable strings) / Regenerate POT file (main-hotfix) (push) Failing after 1s
Some checks failed
Frontend / Unit Tests & Coverage (push) Has been skipped
Server / Tests (frappe ${{ matrix.frappe-branch }}) (push) Has been skipped
Server / Resolve frappe matrix (push) Failing after 1s
Frontend / Lint (push) Failing after 1s
Frontend / Production Build (push) Failing after 1s
Server / Coverage Wrap Up (push) Has been skipped
Frontend / Coverage Wrap Up (push) Has been skipped
Regenerate POT file (translatable strings) / Regenerate POT file (develop) (push) Failing after 1s
Regenerate POT file (translatable strings) / Regenerate POT file (main-hotfix) (push) Failing after 1s
This commit is contained in:
40
crm/public/js/erpnext_quotation_prefill.js
Normal file
40
crm/public/js/erpnext_quotation_prefill.js
Normal file
@@ -0,0 +1,40 @@
|
||||
frappe.ui.form.on('Quotation', {
|
||||
refresh(frm) {
|
||||
const field = frm.get_field('crm_deal')
|
||||
if (!field) return
|
||||
// Render as a link only works for read only display an editable data
|
||||
field.df.read_only = 1
|
||||
field.df.formatter = (value) =>
|
||||
value
|
||||
? `<a href="${window.location.origin}/crm/deals/${encodeURIComponent(value)}" target="_blank" rel="noopener">${frappe.utils.escape_html(value)}</a>`
|
||||
: value
|
||||
field.refresh()
|
||||
},
|
||||
onload(frm) {
|
||||
const crm_deal = frm.doc.crm_deal || frappe.route_options?.crm_deal
|
||||
if (!crm_deal) return
|
||||
if ((frm.doc.items || []).some((i) => i.item_code)) return
|
||||
|
||||
frappe.call({
|
||||
method: 'crm.fcrm.doctype.erpnext_crm_settings.erpnext_crm_settings.prefill_quotation_items',
|
||||
args: { crm_deal },
|
||||
callback: async (r) => {
|
||||
if (!r.message || !r.message.length) return
|
||||
if (!frm.doc.price_list_currency && frm.doc.currency) {
|
||||
await frm.set_value('price_list_currency', frm.doc.currency)
|
||||
}
|
||||
frm.clear_table('items')
|
||||
for (const item of r.message) {
|
||||
const row = frm.add_child('items')
|
||||
await frappe.model.set_value(row.doctype, row.name, 'item_code', item.item_code)
|
||||
await frappe.model.set_value(row.doctype, row.name, 'qty', item.qty)
|
||||
// price_list_rate must be set before discount_percentage: ERPNext
|
||||
// resets the discount to 0 when price_list_rate is falsy.
|
||||
await frappe.model.set_value(row.doctype, row.name, 'price_list_rate', item.price_list_rate)
|
||||
await frappe.model.set_value(row.doctype, row.name, 'discount_percentage', item.discount_percentage)
|
||||
}
|
||||
frm.refresh_field('items')
|
||||
},
|
||||
})
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user