blob: c59253b3a938ab810ccf3c1e6ed3d0b40dc15dba [file] [log] [blame]
Rushabh Mehta3966f1d2012-02-23 12:35:32 +05301# ERPNext - web based ERP (http://erpnext.com)
2# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
3#
4# This program is free software: you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation, either version 3 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
Anand Doshi486f9df2012-07-19 13:40:31 +053017from __future__ import unicode_literals
Nabin Hait31665e52011-09-29 10:41:02 +053018"""
19 All master data in one place, can be created by 1 function call
20
21"""
22
23import webnotes
24from webnotes.model.doc import Document
25
26
27master_groups = {
28 # Company
29 #----------------------------------
30 'company': Document(
31 fielddata={
32 'doctype':'Company',
33 'abbr': 'co',
34 'company_name' : 'comp',
35 'name': 'comp'
36 }
37 ),
38
39 # Customer Group
40 #----------------------------------
41 'customer_group': Document(
42 fielddata={
43 'doctype':'Customer Group',
44 'customer_group_name' : 'cg',
45 'name': 'cg',
46 'is_group': 'No',
47 'parent_customer_group':'',
48 'lft' : 1,
49 'rgt': 2
50 }
51 ),
52
53 # Item Group
54 #----------------------------------
55 'item_group': Document(
56 fielddata = {
57 'doctype': 'Item Group',
58 'item_group_name': 'ig',
59 'lft': 1,
60 'rgt': 2,
61 'parent_item_group' : '',
62 'is_group': 'No',
63 'name': 'ig'
64 }
65 ),
66
67 # Warehouse Type
68 #-----------------------------
69 'warehouse_type' : Document(
70 fielddata = {
71 'doctype' : 'Warehouse Type',
72 'name': 'normal',
73 'warehouse_type' : 'normal'
74 }
75 ),
76
77 # Supplier Type
78 #-----------------------------
79 'supplier_type' : Document(
80 fielddata = {
81 'doctype': 'Supplier Type',
82 'supplier_type': 'stype'
83 }
84 )
85
86}
87
88
89main_masters = {
90 # Customer
91 #----------------------------------
92 'customer': Document(
93 fielddata={
94 'doctype':'Customer',
95 'docstatus':0,
96 'customer_name' : 'cust',
97 'company' : 'comp',
98 'customer_group' : '',
99 'name': 'cust'
100 }
101 ),
102
103
104 # Supplier
105 #----------------------------------
106 'supplier': Document(
107 fielddata = {
108 'doctype': 'Supplier',
109 'supplier_name': 'supp',
110 'name': 'supp',
111 'supplier_type' : 'stype'
112 }
113 ),
114
115 # Customer Account
116 #----------------------------------
117 'customer_acc': Document(
118 fielddata={
119 'doctype':'Account',
120 'docstatus':0,
121 'account_name' : 'cust',
122 'debit_or_credit': 'Debit',
123 'company' : 'comp',
124 'lft': 1,
125 'rgt': 2,
126 'group_or_ledger' : 'Ledger',
127 'is_pl_account': 'No',
128 'name' : 'cust - co'
129 }
130 ),
131
132 # Customer Account
133 #----------------------------------
134 'supplier_acc': Document(
135 fielddata={
136 'doctype':'Account',
137 'docstatus':0,
138 'account_name' : 'supp',
139 'debit_or_credit': 'Credit',
140 'company' : 'comp',
141 'lft': 5,
142 'rgt': 6,
143 'group_or_ledger' : 'Ledger',
144 'is_pl_account': 'No',
145 'name' : 'supp - co'
146 }
147 ),
148
149 # Bank Account
150 #----------------------------------
151 'bank_acc': Document(
152 fielddata={
153 'doctype':'Account',
154 'docstatus':0,
155 'account_name' : 'icici',
156 'parent_account': '',
157 'debit_or_credit': 'Debit',
158 'company' : 'comp',
159 'lft': 3,
160 'rgt': 4,
161 'group_or_ledger' : 'Ledger',
162 'is_pl_account': 'No',
163 'name' : 'icici - co'
164 }
165 ),
166
167 # Income Account
168 #----------------------------------
169 'income_acc': Document(
170 fielddata={
171 'doctype':'Account',
172 'docstatus':0,
173 'account_name' : 'income',
174 'debit_or_credit': 'Credit',
175 'company' : 'comp',
176 'lft': 7,
177 'rgt': 8,
178 'group_or_ledger' : 'Ledger',
179 'is_pl_account': 'Yes',
180 'name' : 'income - co'
181 }
182 ),
183
184 # Expense Account
185 #----------------------------------
186 'expense_acc': Document(
187 fielddata={
188 'doctype':'Account',
189 'docstatus':0,
190 'account_name' : 'expense',
191 'debit_or_credit': 'Debit',
192 'company' : 'comp',
193 'lft': 9,
194 'rgt': 10,
195 'group_or_ledger' : 'Ledger',
196 'is_pl_account': 'Yes',
197 'name' : 'expense - co'
198 }
199 ),
200
201 # Cost Center
202 #----------------------------------
203 'cost_center': Document(
204 fielddata={
205 'doctype':'Cost Center',
206 'docstatus':0,
207 'cost_center_name' : 'cc',
208 'lft': 1,
209 'rgt': 2,
210 'group_or_ledger' : 'Ledger',
211 'name' : 'cc'
212 }
213 ),
214
215 # Item
216 #----------------------------------
217 # Stock item / non-serialized
218
219 'item': [
220 Document(
221 fielddata = {
222 'doctype': 'Item',
223 'docstatus': 0,
224 'name': 'it',
225 'item_name': 'it',
226 'item_code': 'it',
227 'item_group': 'ig',
228 'is_stock_item': 'Yes',
229 'has_serial_no': 'Yes',
230 'stock_uom': 'Nos',
231 'is_sales_item': 'Yes',
232 'is_purchase_item': 'Yes',
233 'is_service_item': 'No',
234 'is_sub_contracted_item': 'No',
235 'is_pro_applicable': 'Yes',
236 'is_manufactured_item': 'Yes'
237 }
238 ),
239 Document(
240 fielddata = {
Anand Doshifedfd892012-03-30 12:29:06 +0530241 'doctype': 'Item Price',
Nabin Hait31665e52011-09-29 10:41:02 +0530242 'parentfield': 'ref_rate_details',
243 'parenttype': 'Item',
244 'parent' : 'it',
245 'price_list_name': 'pl',
246 'ref_currency': 'INR',
247 'ref_rate': 100
248 }
249 ),
250 Document(
251 fielddata = {
252 'doctype': 'Item Tax',
253 'parentfield': 'item_tax',
254 'parenttype': 'Item',
255 'parent' : 'it',
256 'tax_type' : 'Tax1',
257 'tax_rate': 10
258 }
259 )
260 ],
261
262 # Warehouse
263 #-----------------------------
264 'warehouse': [
265 Document(
266 fielddata = {
267 'doctype': 'Warehouse',
268 'name' : 'wh1',
269 'warehouse_name' : 'wh1',
270 'warehouse_type': 'normal',
271 'company': 'comp'
272 }
273 ),
274 Document(
275 fielddata = {
276 'doctype': 'Warehouse',
277 'name' : 'wh2',
278 'warehouse_name' : 'wh2',
279 'warehouse_type': 'normal',
280 'company': 'comp'
281 }
282 )
283 ]
284}
285
286
287
288# Save all master records
289#----------------------------------
290def create_master_records():
291 for m in master_groups.keys():
292 master_groups[m].save(1)
293
294 for m in main_masters.keys():
295 if type(main_masters[m]) == list:
296 for each in main_masters[m]:
297 each.save(1)
298 else:
299 main_masters[m].save(1)