For custom script, by right it should override everything else.
However, I realised some error as following
I tried to pull the correct Cost Center , Letter Head and Naming Series if the users select the Delivery Warehouse.
Everything works fine if there’s no POS Profile Involve.
The POS Profile will OVERRIDE the custom script if there’s default pos profile being set under the POS Profile List.
This only happened when Convert the Sales Order to Sales Invoice, if directly Created Sales Invoice, it’s ok.
I’m wondering where went wrong on this part, To Create Invoice from Sales Order and Create Invoice works differently for the same script.
Anyone have any idea ?
If you’re making the invoice with Include Payment (POS) then system always pulls the data from the respective POS Profile. If you want to change this behaviour you have to make changes in the core code.
self.customer = pos.customer
self.account_for_change_amount = pos.get('account_for_change_amount')
for fieldname in ('territory', 'naming_series', 'currency', 'taxes_and_charges', 'letter_head', 'tc_name',
'selling_price_list', 'company', 'select_print_heading', 'cash_bank_account',
'write_off_account', 'write_off_cost_center', 'apply_discount_on'):
if (not for_validate) or (for_validate and not self.get(fieldname)):
if not for_validate:
self.update_stock = cint(pos.get("update_stock"))
# set pos values in items
for item in self.get("items"):
profile_details = get_pos_profile_item_details(pos, frappe._dict(item.as_dict()), pos)
for fname, val in iteritems(profile_details):
if (not for_validate) or (for_validate and not item.get(fname)):
You need to remove True from the method get_pos_profile_item_details
The weird things is it only happened as following
If direct from Sales Invoice, Include POS, the custom script works perfectly.
If Create from Sales Order to Sales Invoice, it have problems.
For (2) also, if I remove all users from POS Profile, it still pull from POS. But If I add one dummy user, other users will works correctly according to the custom script.
So I’m wondering modify this works. Kindly comment.
can you share your custom script?