The builtin payment terms on a customer don’t work us so i am hiding these and creating my own payment terms custom field on the Customer doctype.
I then need to link this field and show the permitted values for these payment terms on a Quote. ie if a customer is set to Net 30 days as the selected default term, i want this to appear by default on a quotation for this customer, but so this can be changed to a different payment term, if necessary, for this particular quote.
I’ve tried using a custom script to bridge between the payment terms field in Quotation and the same field in Customer, but when I try to use a ‘link’ type field on the Quotation doctype I can only link to another doctype and not a custom field which is what I have.
What is the easiest way to achieve what I’m trying to do? I have tried working this through and believe it should be quite easy, but can’t quite get it to work in practice …
Are you thinking something like Complex Payment Terms
cur_frm.add_fetch(“customer”, “CUSTOM_FIELD_CUSTOMER”, “CUSTOM_FIELD_QUOTATION”);
Add above in custom script for DocType: Quotation from Setup >>> Customize >>> Custom Script >>> New
But that link field in Quotation is to be ‘Read Only’.
Thanks for this. But does this work for a Select field which is what I need to use in Customer?
Yes, it does work on Select Field but it will display something like below; you may try in fact:
so it would be
If your custom field name is ‘select’ in both the forms then code would be:
cur_frm.add_fetch("customer", "select", "select");
cur_frm.add_fetch("Link_Field", "Source_Field", "Target_Field");
Example: Select Field Added in Item as below:
It is displayed in another linked form field as below: (after using above mentioned code in Custom Script)
I can state read only on the field name and on the actual customise form screen. Where should the ‘readonly’ be stated?
There’s a Checkbox in field details where we customize any DocType and Add a Custom Field:
I still can’t quite get this to work. I can get the field to appear in the quote, but its not linked to the customer field, it works separately to the field ion the customer for.
I’m wondering if I have a problem with the Custok script not working to link the feilds as it should
Ok. Go to: Setup >>> Customization >>> Custom Form
- Select Customer >>> Add a Custom Field as you need.
- Select Quotation >>> Add a Custom Field with Type: Link and in Options write Customer and also mark this field as Read Only.
- Goto Custom Script and write that code under Quotation.
Hope this would help.
thanks for your help.
I think the bit I have wrong is step 2, where I have used Customer.payment_terms in the Options/Field where payment_terms in the fieldname in Customer
I get this error ‘Duplicate name Custom Field Quotation-payment_terms’ when trying to add the custom field in 2. Does this mean I should only add the custom script AFTER stage 2?
It means, payment_terms already exist in Quotation; you may rename it to paymentterm or something else.
I can now get the fields in place without errors, but when I go to my Quote, the payment term field is missing instead of just ‘read only’. If I un tick read only, teh field is show, but only allows me to select a customer.
I have seen the payment TErms field show up as a read only field but clickable to the customer page. But this only shows up sometimes. I’m not sure why sometimes it appears and sometimes it doesnt. But I am getting closer