Change doctype programmatically

157 views
Skip to first unread message

Luis Fernandes

unread,
Sep 16, 2014, 7:03:29 AM9/16/14
to erpnext-dev...@googlegroups.com
I. 

I need to change doctype company and add one field, but i want to do the changes programmatically in my module. 
The ideia is, if my module is installed then the new field show in company, if not... you guess!!!

I that possible? If it is point me out the outlines that i do the rest.

I know that i must put a hook to company "get" or some thing like that but i don't see how.


Thanks.

Rushabh Mehta

unread,
Sep 16, 2014, 7:33:51 AM9/16/14
to erpnext-dev...@googlegroups.com
On 16-Sep-2014, at 4:33 pm, Luis Fernandes <luisfmf...@gmail.com> wrote:

I. 

I need to change doctype company and add one field, but i want to do the changes programmatically in my module. 
The ideia is, if my module is installed then the new field show in company, if not... you guess!!!

I that possible? If it is point me out the outlines that i do the rest.

Add your field as a "Custom Field" and set it as a fixture (will be installed / updated with the app)


Run frappe --export_fixtures to build them


I know that i must put a hook to company "get" or some thing like that but i don't see how.


Thanks.

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/c9a453a1-aa95-4ac7-afd5-bec658fea0b7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Luis Fernandes

unread,
Sep 16, 2014, 7:38:11 AM9/16/14
to erpnext-dev...@googlegroups.com
Thanks i will try.

Luis Fernandes

unread,
Sep 16, 2014, 10:30:33 AM9/16/14
to erpnext-dev...@googlegroups.com
rushabh. This is not what i want.

What i want is add one field to Company, field with this name: vat_check_vies, type check and label VIES VAT Check. Like we do in custom field. But i want to do it programmatically. 

Your solution is almost there. But in your solution i get all the fields and values. When i install my app it will install the fields and the data and that is what i don't want.

I want to make an app that make possible to insert VAT numbers for different countries. This is an app based in openerp base_vat module and i want to adapted to erpnext. Then i want to distribute to community and when other programmers install this app they get in Company doctype one filed called vat_check_vies with type check and label VIES VAT Check and nothing more. Then when they check this field my module do the real check against EU's VIES service.

Is this possible and how?


Thanks.


Terça-feira, 16 de Setembro de 2014 12:03:29 UTC+1, Luis Fernandes escreveu:

Luis Fernandes

unread,
Sep 16, 2014, 3:50:29 PM9/16/14
to erpnext-dev...@googlegroups.com
I already teste what do you said in every possible way. I'm doing some thing wrong. 

you said -> Add your field as a "Custom Field": it is easy and it's done. The field is named NIF, type check and field name is nif.

you said -> and set it as a fixture... What do you mean by that? I made like the example and i put in the hooks.py of my application:

fixtures = [
"Customer"
]

and it work. It exports a file called customers in fixtures folder with my new file (nif):

Name:","name","customer_name","customer_type","customer_group","territory","company","lead_name","nif","customer_details","default_currency","default_price_list","default_taxes_and_charges","credit_days","credit_limit","website","default_sales_partner","default_commission_rate","~","name","sales_person","sales_designation","allocated_percentage","allocated_amount","incentives","~","name","sent_or_received","subject","content","category","next_communication_date","action","recipients","sender","communication_medium","phone_no","user","communication_date"
"Mandatory:","Yes","Yes","Yes","Yes","Yes","Yes","No","No","No","No","No","No","No","No","No","No","No","","Yes","Yes","No","No","No","No","","Yes","Yes","Yes","No","No","No","No","No","No","No","No","No","No"

and with all my customers data...

When i install my app in my site2.local (i made all that in site1.local) my app install but the field no.

Can you help me to achieve my objective as mention in my second post?

Thanks.


Terça-feira, 16 de Setembro de 2014 12:33:51 UTC+1, rushabh escreveu:
On 16-Sep-2014, at 4:33 pm, Luis Fernandes <luisfmf...@gmail.com> wrote:

I. 

I need to change doctype company and add one field, but i want to do the changes programmatically in my module. 
The ideia is, if my module is installed then the new field show in company, if not... you guess!!!

I that possible? If it is point me out the outlines that i do the rest.

Add your field as a "Custom Field" and set it as a fixture (will be installed / updated with the app)


Run frappe --export_fixtures to build them


I know that i must put a hook to company "get" or some thing like that but i don't see how.


Thanks.

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

Rushabh Mehta

unread,
Sep 17, 2014, 1:39:57 AM9/17/14
to erpnext-dev...@googlegroups.com
On 17-Sep-2014, at 1:20 am, Luis Fernandes <luisfmf...@gmail.com> wrote:

I already teste what do you said in every possible way. I'm doing some thing wrong. 

you said -> Add your field as a "Custom Field": it is easy and it's done. The field is named NIF, type check and field name is nif.

you said -> and set it as a fixture... What do you mean by that? I made like the example and i put in the hooks.py of my application:

fixtures = [
"Customer"
]

Create a fixture for "Custom Field" :)

To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/6f955034-a129-4937-b116-90438301c296%40googlegroups.com.
Message has been deleted

Y Y

unread,
Sep 17, 2014, 3:51:49 AM9/17/14
to erpnext-dev...@googlegroups.com
After you done., can you share your working code, then we can learn the knowleadge... thanks very much.

在 2014年9月17日星期三UTC+8下午3时50分32秒,Luis Fernandes写道:
Know i understand!!! You mean create a fixture for a "Custom Field" you mean Literally!!!!


Thanks, i will try.


Terça-feira, 16 de Setembro de 2014 12:03:29 UTC+1, Luis Fernandes escreveu:
I. 

I need to change doctype company and add one field, but i want to do the changes programmatically in my module. 
The ideia is, if my module is installed then the new field show in company, if not... you guess!!!

I that possible? If it is point me out the outlines that i do the rest.

Luis Fernandes

unread,
Sep 17, 2014, 5:25:23 AM9/17/14
to erpnext-dev...@googlegroups.com
Of course. As soon as i make my module i will tell you.
Reply all
Reply to author
Forward
0 new messages