Migration from CGI framework to frappe

I also tried frappe.delete_doc('Custom Field', 'cost_center') but still didn't delete these custom fields.

MP



Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    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+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/e4130702-c02e-4930-a621-bbbe6b6abb62%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.

After you run the delete doc functions, run frappe.db.commit() to commit the changes.

On 16 Jul 2014 19:13, "MP" <ma...@gmail.com> wrote:
Thanks Anand. But it didn't work either. See below:

ro...@doris3to4:/var/www/frappe-bench/sites# ../env/bin/frappe --ipython erp-prod
Python 2.7.3 (default, Aug 1 2012, 05:14:39)
Type "copyright", "credits" or "license" for more information.

IPython 2.1.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.

In [1]: frappe.delete_doc('Custom Field', 'Purchase Order Item-cost_center')

In [2]: frappe.delete_doc('Custom Field', 'Purchase Receipt Item-cost_center')

In [3]: quit
ro...@doris3to4:/var/www/frappe-bench/sites# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 63
Server version: 5.5.38-MariaDB-1~precise-log mariadb.org binary distribution

Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> use sirius_erp_prod;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [sirius_erp_prod]> select name, fieldname from `tabCustom Field` where name like '%cost%';
+-----------------------------------+-------------+
| name | fieldname |
+-----------------------------------+-------------+
| Purchase Order Item-cost_center | cost_center |
| Purchase Receipt Item-cost_center | cost_center |
+-----------------------------------+-------------+
2 rows in set (0.00 sec)

MariaDB [sirius_erp_prod]> quit
Bye
ro...@doris3to4:/var/www/frappe-bench/sites# ../env/bin/frappe --latest erp-prod
Executing frappe.patches.v4_0.update_custom_field_insert_after in erp-prod (sirius_erp_prod)
Traceback (most recent call last):
File "../env/bin/frappe", line 9, in <module>
load_entry_point('frappe==4.1.0', 'console_scripts', 'frappe')()
File "/var/www/frappe-bench/apps/frappe/frappe/cli.py", line 53, in main
return run(fn, parsed_args)
File "/var/www/frappe-bench/apps/frappe/frappe/cli.py", line 83, in run
out = globals().get(fn)(**args)
File "/var/www/frappe-bench/apps/frappe/frappe/cli.py", line 67, in new_fn
return fn(*args, **new_kwargs)
File "/var/www/frappe-bench/apps/frappe/frappe/cli.py", line 417, in latest
frappe.modules.patch_handler.run_all()
File "/var/www/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 25, in run_all
if not run_single(patchmodule = patch):
File "/var/www/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 50, in run_single
return execute_patch(patchmodule, method, methodargs)
File "/var/www/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 66, in execute_patch
frappe.get_attr(patchmodule + ".execute")()
File "/var/www/frappe-bench/apps/frappe/frappe/patches/v4_0/update_custom_field_insert_after.py", line 18, in execute
cf.save()
File "/var/www/frappe-bench/apps/frappe/frappe/model/document.py", line 194, in save
self.run_post_save_methods()
File "/var/www/frappe-bench/apps/frappe/frappe/model/document.py", line 414, in run_post_save_methods
self.run_method("on_update")
File "/var/www/frappe-bench/apps/frappe/frappe/model/document.py", line 387, in run_method
return Document.hook(fn)(self, *args, **kwargs)
File "/var/www/frappe-bench/apps/frappe/frappe/model/document.py", line 463, in composer
return composed(self, method, *args, **kwargs)
File "/var/www/frappe-bench/apps/frappe/frappe/model/document.py", line 446, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File "/var/www/frappe-bench/apps/frappe/frappe/model/document.py", line 381, in <lambda>
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File "/var/www/frappe-bench/apps/frappe/frappe/core/doctype/custom_field/custom_field.py", line 38, in on_update
validate_fields_for_doctype(self.dt)
File "/var/www/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py", line 186, in validate_fields_for_doctype
validate_fields(frappe.get_meta(doctype).get("fields"))
File "/var/www/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py", line 244, in validate_fields
check_unique_fieldname(d.fieldname)
File "/var/www/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py", line 199, in check_unique_fieldname
frappe.throw(_("Fieldname {0} appears multiple times in rows {1}").format(fieldname, ", ".join(duplicates)))
File "/var/www/frappe-bench/apps/frappe/frappe/__init__.py", line 206, in throw
msgprint(msg, raise_exception=exc)
File "/var/www/frappe-bench/apps/frappe/frappe/__init__.py", line 203, in msgprint
_raise_exception()
File "/var/www/frappe-bench/apps/frappe/frappe/__init__.py", line 187, in _raise_exception
raise raise_exception, msg
frappe.exceptions.ValidationError: Fieldname cost_center appears multiple times in rows 17, 41
ro...@doris3to4:/var/www/frappe-bench/sites#



Note:



If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.



    End of Note



    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+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/ef9038c1-102e-4aa0-9b36-5638b576313e%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Thanks Pratik, Anand and Rushabh.

It worked. I checked the database and these two entries are not there any more. I will continue with ../env/bin/frappe --latest erp-prod.

I am currently performing this test migration on a test server before the actual migration of the production instance. For the production instance, before migration,  is it okay to delete this custom field "cost_center" through web interface and then run the migration script? Also can we use the new version of Bench to migrate from version 3 to 4? If so, will the steps be same of different? Thanks in advance.

Kind regards,
Mayur Patel



Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    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+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/694530e1-aa7c-4b3b-9796-135fa7eb3b2f%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.
Hi Team,

I have managed to migrate a copy of production version to version 4. Thanks for your help. I have noticed below:

- I have come across some bugs, I will report them later.
- We had some custom server side scripts in our old version but in new version I can't find them. Where can I find them?
- We had modified some of the .py and .js file in our old version. We had added some methods in .py file and also in .js file. Before migration, I removed them manually. We would like to re-apply those customisations in the new version. I was told that in version 4 we can keep our customisation separate from the main erpnext code. I remember something about plugin in wsgi version before frappe bench. How do we achive the same in version 4? Thanks in advance.

Kind regards,
Mayur



Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    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+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/654b4c07-8d3e-4f82-8b87-09848dcab25e%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.

On 16-Jul-2014, at 9:57 pm, MP <ma...@gmail.com> wrote:

Hi Team,

I have managed to migrate a copy of production version to version 4. Thanks for your help. I have noticed below:

- I have come across some bugs, I will report them later.
- We had some custom server side scripts in our old version but in new version I can't find them. Where can I find them?

Put them in a new app: See examples:


Since you are a subscriber - we will help you do set this up. @Anand you want to take this forward.

- We had modified some of the .py and .js file in our old version. We had added some methods in .py file and also in .js file. Before migration, I removed them manually. We would like to re-apply those customisations in the new version. I was told that in version 4 we can keep our customisation separate from the main erpnext code. I remember something about plugin in wsgi version before frappe bench. How do we achive the same in version 4? Thanks in advance.

Same as above. Will be great if you can put your customizations, each in a separate file and zip and mail to us.


Kind regards,
Mayur



Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    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+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/654b4c07-8d3e-4f82-8b87-09848dcab25e%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.



Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    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+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/919AB413-CBE1-4714-80DC-D7AAB1B712F2%40gmail.com.

    For more options, visit https://groups.google.com/d/optout.

Thanks Rushabh.

I will email our customisations as requested…

Kind regards,
Mayur Patel



Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    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+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/6b46544f-9c76-4be1-afb4-f8ec22beb224%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.

Hi Rushabh,

I have just emailed my customisations as requested.

Kind regards,
Mayur Patel



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    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+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/609a8979-b8d9-4aff-a953-8da7f456a32e%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.
Hi There,

I need your help for the following two issues:


1) In version 3, We have written a custom script (client side) to restrict the selection of cost center to the selected company by limiting the search result of the cost center to the selected company. See below script. This helps the user as the resulting search result list is smaller and easy to pick the value from.  This custom script uses a server side function called "accounts.utils.get_cost_center_list". In new version, this function doesn’t exists in utils.py under accounts directory on the server. I tried looking for this function in the entire source code but I can’t seem to find it. Could you please help to rewrite the below script to make it work in the new version? Thanks.  Don’t you think this restriction should be included in ERPNext by default. Why would you want a user to select cost center that is not part of the selected company?


// To restrict selection of cost center for the selected company
cur_frm.fields_dict["po_details"].grid.get_field("cost_center").get_query = function(doc) {
    return {
        query: "accounts.utils.get_cost_center_list",
        filters: { company_name: doc.company}
    }
}



2) In version 3. the field name for "Expense Code" in "Purchase Invoice Item" doctype is‘expense_head’. Since we wanted to capture "Expense Code" at creation of purchaes order, we create a custom field called "expense_head" for "Purchase Order Item" doctype. This way when we create "Purchase Invoice" from  "Purchase Order" page, the expense_head fields of "Purchase Invoice Item" gets populated automatically. We did same for "Purchae Receipt Item" doctype.

But in the new version it seems that this fields has been renamed to ‘expense_account’ from "expense_head". Because of this the Expense code from Purchase Order Item/Purchase Receipt Item is not being automatically mapped on Purchase Invoice (for each line item) Page. How do we resolve it? Do I need to add new custom field called expense_head for Purchase receipt item/purchase order item and  manually copy over the data at database level for existing purchase orders/receipts? This also means rewriting the custom reports that depends on this field. Is there any other way to handle this?

Thanks.

Kind regards,
Mayur Patel



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    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+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/d8ff7f40-8bd9-4403-912d-05fbb9c527fa%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.
Hi Mayur,

Answers inline:

Thanks,
Anand Doshi.


On Wed, Jul 23, 2014 at 7:20 PM, MP <ma...@gmail.com> wrote:
Hi There,

I need your help for the following two issues:


1) In version 3, We have written a custom script (client side) to restrict the selection of cost center to the selected company by limiting the search result of the cost center to the selected company. See below script. This helps the user as the resulting search result list is smaller and easy to pick the value from. This custom script uses a server side function called "accounts.utils.get_cost_center_list". In new version, this function doesn’t exists in utils.py under accounts directory on the server. I tried looking for this function in the entire source code but I can’t seem to find it. Could you please help to rewrite the below script to make it work in the new version? Thanks. Don’t you think this restriction should be included in ERPNext by default. Why would you want a user to select cost center that is not part of the selected company?



// To restrict selection of cost center for the selected company
cur_frm.fields_dict["po_details"].grid.get_field("cost_center").get_query = function(doc) {
return {
query: "accounts.utils.get_cost_center_list",

    filters: { company_name: doc.company} <br>    } <br>} <br><br></div></blockquote><div><br>Cost Center seems to be a custom field in your account. You can try:<br>cur_frm.set_query(&quot;cost_center&quot;, &quot;po_details&quot;, function() {<br>
return {
filters: { company: cur_frm.doc.company }
}
}



2) In version 3. the field name for "Expense Code" in "Purchase Invoice Item" doctype is‘expense_head’. Since we wanted to capture "Expense Code" at creation of purchaes order, we create a custom field called "expense_head" for "Purchase Order Item" doctype. This way when we create "Purchase Invoice" from "Purchase Order" page, the expense_head fields of "Purchase Invoice Item" gets populated automatically. We did same for "Purchae Receipt Item" doctype.


But in the new version it seems that this fields has been renamed to ‘expense_account’ from "expense_head". Because of this the Expense code from Purchase Order Item/Purchase Receipt Item is not being automatically mapped on Purchase Invoice (for each line item) Page. How do we resolve it? Do I need to add new custom field called expense_head for Purchase receipt item/purchase order item and manually copy over the data at database level for existing purchase orders/receipts? This also means rewriting the custom reports that depends on this field. Is there any other way to handle this?



Since you will also be creating a Custom Frappe App for your customisations, this mapping part can be added on the server side itself via a hook. (Though we are yet to add such a hook. I will do this while fixing the server side custom code). However it will be best to rename those fields via a custom patch, since many fieldnames have changed and you will have to fix your reports anyway.

Thanks.

Kind regards,
Mayur Patel



Note:



If you are posting an issue,


  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.

  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.

  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email

  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.



    End of Note



    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+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/d8ff7f40-8bd9-4403-912d-05fbb9c527fa%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    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+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/CAAQzbF3JPQ%2BQ9V53B8uZN4LyjwwQcRHJ5XmR%2BYT5px7sJKWfQQ%40mail.gmail.com.

    For more options, visit https://groups.google.com/d/optout.
Thanks Anand for your response.

See my reply inline:



On Friday, 25 July 2014 07:41:26 UTC+1, Anand Doshi wrote:
Hi Mayur,

Answers inline:

Thanks,
Anand Doshi.


On Wed, Jul 23, 2014 at 7:20 PM, MP <ma...@gmail.com> wrote:
Hi There,

I need your help for the following two issues:


1) In version 3, We have written a custom script (client side) to restrict the selection of cost center to the selected company by limiting the search result of the cost center to the selected company. See below script. This helps the user as the resulting search result list is smaller and easy to pick the value from.  This custom script uses a server side function called "accounts.utils.get_cost_center_list". In new version, this function doesn’t exists in utils.py under accounts directory on the server. I tried looking for this function in the entire source code but I can’t seem to find it. Could you please help to rewrite the below script to make it work in the new version? Thanks.  Don’t you think this restriction should be included in ERPNext by default. Why would you want a user to select cost center that is not part of the selected company?



// To restrict selection of cost center for the selected company
cur_frm.fields_dict[“po_details”].grid.get_field(“cost_center”).get_query = function(doc) {
    return {
        query: “accounts.utils.get_cost_center_list”,

        filters: { company_name: doc.company}
    }
}


Cost Center seems to be a custom field in your account. You can try:
cur_frm.set_query(“cost_center”, “po_details”, function() {

    return {
        filters: { company: cur_frm.doc.company }
    }
}
 

Sorry, I realised later on that this is a custom field. Thanks for the script. I have tested it. It is working fine. It was missing a ')'. I am also assuming that I can use the same script for restricting Expense Code to the selected company by changing the field name in the script.
 


2) In version 3. the field name for "Expense Code" in "Purchase Invoice Item" doctype is‘expense_head’. Since we wanted to capture "Expense Code" at creation of purchaes order, we create a custom field called "expense_head" for "Purchase Order Item" doctype. This way when we create "Purchase Invoice" from  "Purchase Order" page, the expense_head fields of "Purchase Invoice Item" gets populated automatically. We did same for "Purchae Receipt Item" doctype.


But in the new version it seems that this fields has been renamed to ‘expense_account’ from “expense_head”. Because of this the Expense code from Purchase Order Item/Purchase Receipt Item is not being automatically mapped on Purchase Invoice (for each line item) Page. How do we resolve it? Do I need to add new custom field called expense_head for Purchase receipt item/purchase order item and  manually copy over the data at database level for existing purchase orders/receipts? This also means rewriting the custom reports that depends on this field. Is there any other way to handle this?



Since you will also be creating a Custom Frappe App for your customisations, this mapping part can be added on the server side itself via a hook. (Though we are yet to add such a hook. I will do this while fixing the server side custom code). However it will be best to rename those fields via a custom patch, since many fieldnames have changed and you will have to fix your reports anyway.

 

I believe you are helping us with turning our customisations into custom Frappe App. Please clarify if my understanding is not correct here. Also how do we write a custom patch to rename these fields? Sorry we haven't written any custom patch in the past.  Can I just do this at database level and manually update the report code? Or is there a better way to do it via custom patch?

 
Thanks.

Kind regards,
Mayur Patel





Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    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+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/e2684e00-47cc-4a8e-a1c6-041d22a3c618%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.

@anand
Revisiting this issue again since we are now serious about the migration.

In version 3. the field name for “Expense Code” in “Purchase Invoice Item” doctype is‘expense_head’. Since we wanted to capture “Expense Code” at creation of purchase order, we create a custom field called “expense_head” for “Purchase Order Item” doctype. This way when we create “Purchase Invoice” from “Purchase Order” page, the expense_head fields of “Purchase Invoice Item” gets populated automatically. We did same for “Purchase Receipt Item” doctype. But in the new version it seems that this fields has been renamed to ‘expense_account’ from “expense_head”. Because of this the Expense code from Purchase Order Item/Purchase Receipt Item is not being automatically mapped on Purchase Invoice (for each line item) Page.

How do we resolve it? Do I need to add new custom field called expense_head for Purchase receipt item/purchase order item and manually copy over the data at database level for existing purchase orders/receipts? This also means rewriting the custom reports that depends on this field. Is there any other way to handle this?

Kind regards,
MP

You can write an “alter table” query to rename the custom fields.

Yes you will have to re-write the custom scripts / reports (replace the fieldnames)