blob: 368e6e40acd0393d70318d3c7cf5b610865c07a5 [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
Nabin Hait31665e52011-09-29 10:41:02 +053017"""
18 All master data in one place, can be created by 1 function call
19
20"""
21
22import webnotes
23from webnotes.model.doc import Document
24
25
26master_groups = {
27 # Company
28 #----------------------------------
29 'company': Document(
30 fielddata={
31 'doctype':'Company',
32 'abbr': 'co',
33 'company_name' : 'comp',
34 'name': 'comp'
35 }
36 ),
37
38 # Customer Group
39 #----------------------------------
40 'customer_group': Document(
41 fielddata={
42 'doctype':'Customer Group',
43 'customer_group_name' : 'cg',
44 'name': 'cg',
45 'is_group': 'No',
46 'parent_customer_group':'',
47 'lft' : 1,
48 'rgt': 2
49 }
50 ),
51
52 # Item Group
53 #----------------------------------
54 'item_group': Document(
55 fielddata = {
56 'doctype': 'Item Group',
57 'item_group_name': 'ig',
58 'lft': 1,
59 'rgt': 2,
60 'parent_item_group' : '',
61 'is_group': 'No',
62 'name': 'ig'
63 }
64 ),
65
66 # Warehouse Type
67 #-----------------------------
68 'warehouse_type' : Document(
69 fielddata = {
70 'doctype' : 'Warehouse Type',
71 'name': 'normal',
72 'warehouse_type' : 'normal'
73 }
74 ),
75
76 # Supplier Type
77 #-----------------------------
78 'supplier_type' : Document(
79 fielddata = {
80 'doctype': 'Supplier Type',
81 'supplier_type': 'stype'
82 }
83 )
84
85}
86
87
88main_masters = {
89 # Customer
90 #----------------------------------
91 'customer': Document(
92 fielddata={
93 'doctype':'Customer',
94 'docstatus':0,
95 'customer_name' : 'cust',
96 'company' : 'comp',
97 'customer_group' : '',
98 'name': 'cust'
99 }
100 ),
101
102
103 # Supplier
104 #----------------------------------
105 'supplier': Document(
106 fielddata = {
107 'doctype': 'Supplier',
108 'supplier_name': 'supp',
109 'name': 'supp',
110 'supplier_type' : 'stype'
111 }
112 ),
113
114 # Customer Account
115 #----------------------------------
116 'customer_acc': Document(
117 fielddata={
118 'doctype':'Account',
119 'docstatus':0,
120 'account_name' : 'cust',
121 'debit_or_credit': 'Debit',
122 'company' : 'comp',
123 'lft': 1,
124 'rgt': 2,
125 'group_or_ledger' : 'Ledger',
126 'is_pl_account': 'No',
127 'name' : 'cust - co'
128 }
129 ),
130
131 # Customer Account
132 #----------------------------------
133 'supplier_acc': Document(
134 fielddata={
135 'doctype':'Account',
136 'docstatus':0,
137 'account_name' : 'supp',
138 'debit_or_credit': 'Credit',
139 'company' : 'comp',
140 'lft': 5,
141 'rgt': 6,
142 'group_or_ledger' : 'Ledger',
143 'is_pl_account': 'No',
144 'name' : 'supp - co'
145 }
146 ),
147
148 # Bank Account
149 #----------------------------------
150 'bank_acc': Document(
151 fielddata={
152 'doctype':'Account',
153 'docstatus':0,
154 'account_name' : 'icici',
155 'parent_account': '',
156 'debit_or_credit': 'Debit',
157 'company' : 'comp',
158 'lft': 3,
159 'rgt': 4,
160 'group_or_ledger' : 'Ledger',
161 'is_pl_account': 'No',
162 'name' : 'icici - co'
163 }
164 ),
165
166 # Income Account
167 #----------------------------------
168 'income_acc': Document(
169 fielddata={
170 'doctype':'Account',
171 'docstatus':0,
172 'account_name' : 'income',
173 'debit_or_credit': 'Credit',
174 'company' : 'comp',
175 'lft': 7,
176 'rgt': 8,
177 'group_or_ledger' : 'Ledger',
178 'is_pl_account': 'Yes',
179 'name' : 'income - co'
180 }
181 ),
182
183 # Expense Account
184 #----------------------------------
185 'expense_acc': Document(
186 fielddata={
187 'doctype':'Account',
188 'docstatus':0,
189 'account_name' : 'expense',
190 'debit_or_credit': 'Debit',
191 'company' : 'comp',
192 'lft': 9,
193 'rgt': 10,
194 'group_or_ledger' : 'Ledger',
195 'is_pl_account': 'Yes',
196 'name' : 'expense - co'
197 }
198 ),
199
200 # Cost Center
201 #----------------------------------
202 'cost_center': Document(
203 fielddata={
204 'doctype':'Cost Center',
205 'docstatus':0,
206 'cost_center_name' : 'cc',
207 'lft': 1,
208 'rgt': 2,
209 'group_or_ledger' : 'Ledger',
210 'name' : 'cc'
211 }
212 ),
213
214 # Item
215 #----------------------------------
216 # Stock item / non-serialized
217
218 'item': [
219 Document(
220 fielddata = {
221 'doctype': 'Item',
222 'docstatus': 0,
223 'name': 'it',
224 'item_name': 'it',
225 'item_code': 'it',
226 'item_group': 'ig',
227 'is_stock_item': 'Yes',
228 'has_serial_no': 'Yes',
229 'stock_uom': 'Nos',
230 'is_sales_item': 'Yes',
231 'is_purchase_item': 'Yes',
232 'is_service_item': 'No',
233 'is_sub_contracted_item': 'No',
234 'is_pro_applicable': 'Yes',
235 'is_manufactured_item': 'Yes'
236 }
237 ),
238 Document(
239 fielddata = {
240 'doctype': 'Ref Rate Detail',
241 'parentfield': 'ref_rate_details',
242 'parenttype': 'Item',
243 'parent' : 'it',
244 'price_list_name': 'pl',
245 'ref_currency': 'INR',
246 'ref_rate': 100
247 }
248 ),
249 Document(
250 fielddata = {
251 'doctype': 'Item Tax',
252 'parentfield': 'item_tax',
253 'parenttype': 'Item',
254 'parent' : 'it',
255 'tax_type' : 'Tax1',
256 'tax_rate': 10
257 }
258 )
259 ],
260
261 # Warehouse
262 #-----------------------------
263 'warehouse': [
264 Document(
265 fielddata = {
266 'doctype': 'Warehouse',
267 'name' : 'wh1',
268 'warehouse_name' : 'wh1',
269 'warehouse_type': 'normal',
270 'company': 'comp'
271 }
272 ),
273 Document(
274 fielddata = {
275 'doctype': 'Warehouse',
276 'name' : 'wh2',
277 'warehouse_name' : 'wh2',
278 'warehouse_type': 'normal',
279 'company': 'comp'
280 }
281 )
282 ]
283}
284
285
286
287# Save all master records
288#----------------------------------
289def create_master_records():
290 for m in master_groups.keys():
291 master_groups[m].save(1)
292
293 for m in main_masters.keys():
294 if type(main_masters[m]) == list:
295 for each in main_masters[m]:
296 each.save(1)
297 else:
298 main_masters[m].save(1)