We have define a custom field call Expense Code (Link to Account) for Purchase Order Item doc type. We noticed that on Purchase Order page when we add a new row under Item, as soon as we select a product, the custom field Expense Code is auto filled with “Cost of Goods Sold - YP” on that page. Please note YP is the default company in our instance. I checked all the item and we haven’t set any default value for Expense Account field. Please help to rectify this issue. Thanks.
@rmehta
I found the reason for above behaviour. It started whenI renamed one of the custom field from expense_head to expense_account for ‘Purchase Order Item’ and ‘Purchase Receipt Item’ as per your advise. See the post: Migration from CGI framework to frappe - #31 by mayur_hotmail
I used below queries to change expense_head to expense_account for Purchase Order Item. is below correct? Am I missing any other table?
update tabCustom Field set fieldname=‘expense_account’ where fieldname=‘expense_head’;
alter table tabPurchase Order Item change expense_head expense_account varchar(180);
alter table tabPurchase Receipt Item change expense_head expense_account varchar(180);
As soon as I reverted field back to expense _head, the “Cost of Good Sold” issue got resolved. But I need a way to rename the custom field from expense_head to expense_account so that Purchase Receipt and Purchase Invoice page can automatically use this values from Purchase Order Item.
@rmehta
Further to above, if I add a new custom field called expense_account for ‘Purchase Order Item’ then also it seems to set it “Cost of Good Sold”. I do have custom script as below. Is there anything wrong with below script?
Another interesting thing is. I added a 3rd field call expense_number (Link to Account -same as for above field). I also got same script for this field. it works fine but not with expense_account. So the issue is with the field name being called expense_account and above script. Unfortunately, I need it to work with expense_account as that is what is called on Purchase Invoice Item page. Please try to setup a custom field in your local environment and use above script and see if you can replicate it. It shouldn’t take more than 1 minute.
There is a setting for Company under Accounts module called “Default Cost of Goods Sold Account” and by default it is set to “Cost of Goods Sold”. Because of this, the value for expense_account is automatically getting set to “Cost of Goods Sold” on Purchase Order Item page when an item is selected. It is only true if the custom field is called expense_account. I am not sure how am I going to tell system not to set it to this default value without changing Company’s setting. One thing I don’t understand what does Purchase Order has to do with Goods Sold. This should be only applicable to Sales Order and not Purchase Order??
On selection of item code, the system fetches Expense Account from Item / Item Group / Company and it sets in Item table if field name is “expense_account”. There is nothing wrong in it.
Can you please elaborate why you don’t want default expense account in PO? As it will be copied to Purchase Invoice, and in Purchase Invoice it fetches default expense account. Hence why you do not want to apply default value in PO?
It is “Cost of Goods Sold”, which is your cost of purchase and it is related to Purchase cycle only.
Thanks Nabin for your reply. We want user to enter expense account and we
have set it as mandatory field. By default we want it to be blank and want
user to select a correct one. But if it is set by default then user may not
enter the correct one. If there was an easier way to set it to blank then
it will be very helpful if not then we will have to live with it :).
None of our items has any expense code set by default.
@mayur_hotmail Have you looked at Cost Centres? It strikes me that what you are trying to achieve is cost classification and analysis and that is best done through cost centres.
@mayur_hotmail You do not get default value of expense account in other forms as well like Purchase Invoice, Stock Entry / Reconciliation. You need to enter manually in all the places.