Default pricelist for multiple companies

Hi there!

Trying to set default price list based on company. Here’s what I did

  1. Created default selling price list custom field on Company

  2. Unset Default Price List in Selling > Setup > Selling Setup

  3. Added fetch on sales order form

    cur_frm.add_fetch(“company”, “default_selling_price_list”, “selling_price_list”)

It works, but I get “Unable to find exchange rate” error, I believe because default price list is empty and the server side script fails? What’s the best way to get rid of this error message?

NOTE: the two companies are setup with different currencies

This seems to be related to your currency exchange conversion, do you have a valid Currency Exchange recrod for the currencies?

The strange thing is, there is no exchange rate needed because both the company and the price list are in the same currency. The XHR request is made with a blank from_currency (because there is no default price list before the custom script sets it) and hence the response generates the error message.

I found out something strange:





So I’m guessing the default value is loaded as HKD first:

Yeah, that seems to be the case.

@nabinhait can you check this?


The problem was that my previous custom script was using add_fetch which gets executed after form “unload” event so unsetting the global default pricelist was generating the error. I changed the add_fetch to:

frappe.ui.form.on("Sales Order", "onload", function (frm, cdt, cdn) {{
    'method': 'frappe.client.get_value',
    'args': {
       'doctype': 'Company',
       'fieldname': 'default_selling_price_list',
  'async': false,
  'callback': function(res){

thanks to @max_morais_dmm for the fix!

1 Like