blob: dc1833d1e2b84fb812d020a10803211271b56d6a [file] [log] [blame]
Rushabh Mehta95e4e142012-09-13 19:40:56 +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 Hait9a90c892012-09-18 13:37:27 +053017from __future__ import unicode_literals
Rushabh Mehta823c0212012-09-19 12:01:01 +053018
19# mappings for table dumps
20# "remember to add indexes!"
21
Rushabh Mehta95e4e142012-09-13 19:40:56 +053022data_map = {
Rushabh Mehtaf200c522012-09-21 15:19:40 +053023 "Company": {
24 "columns": ["name"],
25 "conditions": ["docstatus < 2"]
26 },
27 "Fiscal Year": {
28 "columns": ["name", "year_start_date",
Anand Doshi73519e12012-10-11 14:04:27 +053029 "adddate(adddate(year_start_date, interval 1 year), interval -1 day) as year_end_date"],
30 "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +053031 },
32
33 # Accounts
Rushabh Mehta95e4e142012-09-13 19:40:56 +053034 "Account": {
Anand Doshibc243de2012-09-24 18:03:35 +053035 "columns": ["name", "parent_account", "lft", "rgt", "debit_or_credit",
Rushabh Mehtac68fc3f2012-11-13 13:28:26 +053036 "is_pl_account", "company", "group_or_ledger"],
Anand Doshi73519e12012-10-11 14:04:27 +053037 "conditions": ["docstatus < 2"],
Rushabh Mehtac68fc3f2012-11-13 13:28:26 +053038 "order_by": "lft",
39 "links": {
40 "company": ["Company", "name"],
41 }
42
Rushabh Mehta95e4e142012-09-13 19:40:56 +053043 },
Rushabh Mehta41565232012-09-17 19:10:36 +053044 "Cost Center": {
Rushabh Mehta09d84b62012-09-21 19:46:24 +053045 "columns": ["name", "lft", "rgt"],
Anand Doshi73519e12012-10-11 14:04:27 +053046 "conditions": ["docstatus < 2"],
Rushabh Mehta41565232012-09-17 19:10:36 +053047 "order_by": "lft"
48 },
Rushabh Mehta95e4e142012-09-13 19:40:56 +053049 "GL Entry": {
50 "columns": ["account", "posting_date", "cost_center", "debit", "credit", "is_opening",
Rushabh Mehtacfb54662012-09-14 18:12:17 +053051 "company", "voucher_type", "voucher_no", "remarks"],
Rushabh Mehta95e4e142012-09-13 19:40:56 +053052 "conditions": ["ifnull(is_cancelled, 'No')='No'"],
Rushabh Mehta823c0212012-09-19 12:01:01 +053053 "order_by": "posting_date, account",
54 "links": {
55 "account": ["Account", "name"],
Rushabh Mehta09d84b62012-09-21 19:46:24 +053056 "company": ["Company", "name"],
57 "cost_center": ["Cost Center", "name"]
Rushabh Mehta823c0212012-09-19 12:01:01 +053058 }
Rushabh Mehta95e4e142012-09-13 19:40:56 +053059 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +053060
61 # Stock
62 "Item": {
Nabin Hait6072a682012-12-31 17:16:23 +053063 "columns": ["name", "if(item_name=name, '', item_name) as item_name", "description",
Nabin Hait44ffd432013-01-16 11:16:21 +053064 "item_group as parent_item_group", "stock_uom", "brand", "valuation_method",
65 "re_order_level", "re_order_qty"],
Nabin Hait1c08aee2012-12-31 13:30:18 +053066 # "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +053067 "order_by": "name",
68 "links": {
69 "parent_item_group": ["Item Group", "name"],
Nabin Haitce159ab2012-12-25 18:04:10 +053070 "brand": ["Brand", "name"]
Rushabh Mehtaf200c522012-09-21 15:19:40 +053071 }
Rushabh Mehta95e4e142012-09-13 19:40:56 +053072 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +053073 "Item Group": {
74 "columns": ["name", "parent_item_group"],
Anand Doshi73519e12012-10-11 14:04:27 +053075 "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +053076 "order_by": "lft"
77 },
Nabin Haitce159ab2012-12-25 18:04:10 +053078 "Brand": {
79 "columns": ["name"],
80 "conditions": ["docstatus < 2"],
81 "order_by": "name"
82 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +053083 "Warehouse": {
84 "columns": ["name"],
Anand Doshi73519e12012-10-11 14:04:27 +053085 "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +053086 "order_by": "name"
Rushabh Mehta2ad0d422012-09-18 18:52:05 +053087 },
88 "Stock Ledger Entry": {
89 "columns": ["posting_date", "posting_time", "item_code", "warehouse", "actual_qty as qty",
Rushabh Mehta6ca80542012-09-20 19:03:14 +053090 "voucher_type", "voucher_no", "ifnull(incoming_rate,0) as incoming_rate"],
Rushabh Mehta823c0212012-09-19 12:01:01 +053091 "conditions": ["ifnull(is_cancelled, 'No')='No'"],
Rushabh Mehta2ad0d422012-09-18 18:52:05 +053092 "order_by": "posting_date, posting_time, name",
93 "links": {
94 "item_code": ["Item", "name"],
95 "warehouse": ["Warehouse", "name"]
Rushabh Mehta823c0212012-09-19 12:01:01 +053096 },
Nabin Hait30f53462012-12-28 15:39:55 +053097 "force_index": "posting_sort_index"
Rushabh Mehta2ad0d422012-09-18 18:52:05 +053098 },
Nabin Haitce159ab2012-12-25 18:04:10 +053099 "Stock Entry": {
100 "columns": ["name", "purpose"],
101 "conditions": ["docstatus=1"],
102 "order_by": "posting_date, posting_time, name",
103 },
Nabin Hait30f53462012-12-28 15:39:55 +0530104 "Production Order": {
105 "columns": ["production_item as item_code",
106 "(ifnull(qty, 0) - ifnull(produced_qty, 0)) as qty",
107 "fg_warehouse as warehouse"],
108 "conditions": ["docstatus=1", "status != 'Stopped'", "ifnull(fg_warehouse, '')!=''",
109 "ifnull(qty, 0) > ifnull(produced_qty, 0)"],
110 "links": {
111 "item_code": ["Item", "name"],
112 "warehouse": ["Warehouse", "name"]
113 },
114 },
115 "Purchase Request Item": {
116 "columns": ["item_code", "warehouse",
117 "(ifnull(qty, 0) - ifnull(ordered_qty, 0)) as qty"],
118 "from": "`tabPurchase Request Item` item, `tabPurchase Request` main",
119 "conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'",
120 "ifnull(warehouse, '')!=''", "ifnull(qty, 0) > ifnull(ordered_qty, 0)"],
121 "links": {
122 "item_code": ["Item", "name"],
123 "warehouse": ["Warehouse", "name"]
124 },
125 },
126 "Purchase Order Item": {
127 "columns": ["item_code", "warehouse",
128 "(ifnull(qty, 0) - ifnull(received_qty, 0)) as qty"],
129 "from": "`tabPurchase Order Item` item, `tabPurchase Order` main",
130 "conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'",
131 "ifnull(warehouse, '')!=''", "ifnull(qty, 0) > ifnull(received_qty, 0)"],
132 "links": {
133 "item_code": ["Item", "name"],
134 "warehouse": ["Warehouse", "name"]
135 },
136 },
Nabin Hait96601592013-01-24 18:24:33 +0530137
Nabin Hait30f53462012-12-28 15:39:55 +0530138 "Sales Order Item": {
139 "columns": ["item_code", "(ifnull(qty, 0) - ifnull(delivered_qty, 0)) as qty",
140 "reserved_warehouse as warehouse"],
141 "from": "`tabSales Order Item` item, `tabSales Order` main",
142 "conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'",
143 "ifnull(reserved_warehouse, '')!=''", "ifnull(qty, 0) > ifnull(delivered_qty, 0)"],
144 "links": {
145 "item_code": ["Item", "name"],
146 "warehouse": ["Warehouse", "name"]
147 },
148 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530149
150 # Sales
151 "Customer": {
152 "columns": ["name", "if(customer_name=name, '', customer_name) as customer_name",
153 "customer_group as parent_customer_group", "territory as parent_territory"],
Anand Doshi73519e12012-10-11 14:04:27 +0530154 "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530155 "order_by": "name",
156 "links": {
157 "parent_customer_group": ["Customer Group", "name"],
158 "parent_territory": ["Territory", "name"],
159 }
Rushabh Mehta2ad0d422012-09-18 18:52:05 +0530160 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530161 "Customer Group": {
162 "columns": ["name", "parent_customer_group"],
Anand Doshi73519e12012-10-11 14:04:27 +0530163 "conditions": ["docstatus < 2"],
Rushabh Mehta2ad0d422012-09-18 18:52:05 +0530164 "order_by": "lft"
165 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530166 "Territory": {
167 "columns": ["name", "parent_territory"],
Anand Doshi73519e12012-10-11 14:04:27 +0530168 "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530169 "order_by": "lft"
170 },
171 "Sales Invoice": {
172 "columns": ["name", "customer", "posting_date", "company"],
173 "conditions": ["docstatus=1"],
174 "order_by": "posting_date",
175 "links": {
176 "customer": ["Customer", "name"],
177 "company":["Company", "name"]
178 }
179 },
180 "Sales Invoice Item": {
181 "columns": ["parent", "item_code", "qty", "amount"],
182 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
183 "order_by": "parent",
184 "links": {
185 "parent": ["Sales Invoice", "name"],
186 "item_code": ["Item", "name"]
187 }
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530188 },
Nabin Hait96601592013-01-24 18:24:33 +0530189 "Sales Order": {
190 "columns": ["name", "customer", "transaction_date as posting_date", "company"],
191 "conditions": ["docstatus=1"],
192 "order_by": "transaction_date",
193 "links": {
194 "customer": ["Customer", "name"],
195 "company":["Company", "name"]
196 }
197 },
198 "Sales Order Item[Sales Analytics]": {
199 "columns": ["parent", "item_code", "qty", "amount"],
200 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
201 "order_by": "parent",
202 "links": {
203 "parent": ["Sales Order", "name"],
204 "item_code": ["Item", "name"]
205 }
206 },
207 "Delivery Note": {
208 "columns": ["name", "customer", "posting_date", "company"],
209 "conditions": ["docstatus=1"],
210 "order_by": "posting_date",
211 "links": {
212 "customer": ["Customer", "name"],
213 "company":["Company", "name"]
214 }
215 },
216 "Delivery Note Item[Sales Analytics]": {
217 "columns": ["parent", "item_code", "qty", "amount"],
218 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
219 "order_by": "parent",
220 "links": {
221 "parent": ["Delivery Note", "name"],
222 "item_code": ["Item", "name"]
223 }
224 },
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530225 "Supplier": {
226 "columns": ["name", "if(supplier_name=name, '', supplier_name) as supplier_name",
227 "supplier_type as parent_supplier_type"],
Anand Doshi73519e12012-10-11 14:04:27 +0530228 "conditions": ["docstatus < 2"],
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530229 "order_by": "name",
230 "links": {
231 "parent_supplier_type": ["Supplier Type", "name"],
232 }
233 },
234 "Supplier Type": {
235 "columns": ["name"],
Anand Doshi73519e12012-10-11 14:04:27 +0530236 "conditions": ["docstatus < 2"],
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530237 "order_by": "name"
238 },
239 "Purchase Invoice": {
240 "columns": ["name", "supplier", "posting_date", "company"],
241 "conditions": ["docstatus=1"],
242 "order_by": "posting_date",
243 "links": {
244 "supplier": ["Supplier", "name"],
245 "company":["Company", "name"]
246 }
247 },
248 "Purchase Invoice Item": {
249 "columns": ["parent", "item_code", "qty", "amount"],
250 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
251 "order_by": "parent",
252 "links": {
253 "parent": ["Purchase Invoice", "name"],
254 "item_code": ["Item", "name"]
255 }
Rushabh Mehta607a2212013-01-04 16:42:33 +0530256 },
Nabin Haitd1301c72013-01-24 18:38:30 +0530257 "Purchase Order": {
258 "columns": ["name", "supplier", "transaction_date as posting_date", "company"],
259 "conditions": ["docstatus=1"],
260 "order_by": "posting_date",
261 "links": {
262 "supplier": ["Supplier", "name"],
263 "company":["Company", "name"]
264 }
265 },
266 "Purchase Order Item[Purchase Analytics]": {
267 "columns": ["parent", "item_code", "qty", "amount"],
268 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
269 "order_by": "parent",
270 "links": {
271 "parent": ["Purchase Order", "name"],
272 "item_code": ["Item", "name"]
273 }
274 },
275 "Purchase Receipt": {
276 "columns": ["name", "supplier", "posting_date", "company"],
277 "conditions": ["docstatus=1"],
278 "order_by": "posting_date",
279 "links": {
280 "supplier": ["Supplier", "name"],
281 "company":["Company", "name"]
282 }
283 },
284 "Purchase Receipt Item[Purchase Analytics]": {
285 "columns": ["parent", "item_code", "qty", "amount"],
286 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
287 "order_by": "parent",
288 "links": {
289 "parent": ["Purchase Receipt", "name"],
290 "item_code": ["Item", "name"]
291 }
292 },
Rushabh Mehta607a2212013-01-04 16:42:33 +0530293 # Support
294 "Support Ticket": {
Rushabh Mehtabe9ef4a2013-01-14 15:48:00 +0530295 "columns": ["name","status","creation","resolution_date","first_responded_on"],
Rushabh Mehta607a2212013-01-04 16:42:33 +0530296 "conditions": ["docstatus < 2"],
297 "order_by": "creation"
Rushabh Mehta95e4e142012-09-13 19:40:56 +0530298 }
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530299
Rushabh Mehta95e4e142012-09-13 19:40:56 +0530300}