address_title

75 views
Skip to first unread message

Sören H. Biere

unread,
May 28, 2013, 5:41:44 AM5/28/13
to erpnext-dev...@googlegroups.com
Hi,
 
like Addy posted in user-forum in january me too would like to use address_title.
Simply adding it to address_display in transaction_base.py wouldn't be nice because
it stops nice injection of contact's name.
 
Am I missing any way to get this fields content in my document?
 
Or do i have to add  new method to transaction_base.py, to documents'js and fetch to a new field?
 
Wouldn't this be a nice addition for future release, should i give pull-request once tested?
 
Best regards,
Sören

Anand Doshi

unread,
May 28, 2013, 5:50:37 AM5/28/13
to erpnext-dev...@googlegroups.com
Hi Sören,

In your custom script (client), you can use:

wn.model.with_doc("Address", address_name, function() {
var address = wn.model.get_doc("Address", address_name);
// now access address[fieldname]
});

Thanks,
Anand.

--
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.
To post to this group, send email to erpnext-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/b0472065-021a-4946-b504-24e2f97de4b3%40googlegroups.com?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Sören H. Biere

unread,
May 29, 2013, 3:12:36 AM5/29/13
to erpnext-dev...@googlegroups.com
Great, thank you very much!

On Tuesday, May 28, 2013 11:50:37 AM UTC+2, Anand Doshi wrote:
Hi Sören,

In your custom script (client), you can use:

wn.model.with_doc("Address", address_name, function() {
var address = wn.model.get_doc("Address", address_name);
// now access address[fieldname]
});

Thanks,
Anand.

On 28-May-2013, at 3:11 PM, Sören H. Biere <Kon...@SHB-Technologie.de> wrote:

Hi,
 
like Addy posted in user-forum in january me too would like to use address_title.
Simply adding it to address_display in transaction_base.py wouldn't be nice because
it stops nice injection of contact's name.
 
Am I missing any way to get this fields content in my document?
 
Or do i have to add  new method to transaction_base.py, to documents'js and fetch to a new field?
 
Wouldn't this be a nice addition for future release, should i give pull-request once tested?
 
Best regards,
Sören

--
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+unsub...@googlegroups.com.

Sören H. Biere

unread,
May 30, 2013, 9:35:33 AM5/30/13
to erpnext-dev...@googlegroups.com
Hi,
I would like to fill my field 'anschrift' with the address_title and used the refresh-function with the lines you gave me.
It works it fills the Anschrift-field only on save or next refresh. Great would be if it fills me 'anschrift' when i choose the new customer.
Like it ist with cur_frm.add_fetch. Could you give me a hint where i might have to look at.
In the moment i choose the customer and it refreshs customer_address still seems to be empty.
 
Thank you very much!
Sören
 
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
 
    if(doc.customer_address) {
            wn.model.with_doc("Address", doc.customer_address, function() {
                    var address = wn.model.get_doc("Address", doc.customer_address);
                    doc.anschrift = address["address_title"];
                }
            );
    }
 
}
On Tuesday, May 28, 2013 11:50:37 AM UTC+2, Anand Doshi wrote:
Hi Sören,

In your custom script (client), you can use:

wn.model.with_doc("Address", address_name, function() {
var address = wn.model.get_doc("Address", address_name);
// now access address[fieldname]
});

Thanks,
Anand.

On 28-May-2013, at 3:11 PM, Sören H. Biere <Kon...@SHB-Technologie.de> wrote:

Hi,
 
like Addy posted in user-forum in january me too would like to use address_title.
Simply adding it to address_display in transaction_base.py wouldn't be nice because
it stops nice injection of contact's name.
 
Am I missing any way to get this fields content in my document?
 
Or do i have to add  new method to transaction_base.py, to documents'js and fetch to a new field?
 
Wouldn't this be a nice addition for future release, should i give pull-request once tested?
 
Best regards,
Sören

--
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+unsub...@googlegroups.com.

Sören H. Biere

unread,
May 30, 2013, 9:39:10 AM5/30/13
to erpnext-dev...@googlegroups.com
perhaps i should use the function loading the default_address to ensure customer_address is filled - but my tests didn't work out as well.
 
Greets from Germany,
Sören

Anand Doshi

unread,
May 30, 2013, 9:58:17 AM5/30/13
to erpnext-dev...@googlegroups.com
Hi Sören,

Please don't override the default refresh function. You should use cur_frm.cscript.custom_(existing_function_name) instead.

You can use:
cur_frm.cscript.custom_validate = function(doc) {
if(doc.customer_address) {
            wn.model.with_doc("Address", doc.customer_address, function() {
                    var address = wn.model.get_doc("Address", doc.customer_address);
                    doc.anschrift = address["address_title"];
                }
            );
    }
}

so that it gets stored on save. (or custom_on_submit for before submit)

I can't think of a straightforward way of setting your values on customer trigger without changing the server side function. The customer_address value is fetched on change of customer and only when this value is available can you get the Address document and set anschrift.

Thanks,
Anand.


To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.

To post to this group, send email to erpnext-dev...@googlegroups.com.

Rushabh Mehta

unread,
May 31, 2013, 1:17:16 AM5/31/13
to erpnext-dev...@googlegroups.com
Soren,

You can also use the add_fetch function to fetch properties of the selected link. On top of your script write:

cur_frm.add_fetch("customer_address", "anschrift", "address_title")

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

Reply all
Reply to author
Forward
0 new messages