blob: c2e4023e9d0e60255d84771447c8e7383594e846 [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": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +053050 "columns": ["name", "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": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +053089 "columns": ["name", "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": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530105 "columns": ["name", "production_item as item_code",
Nabin Hait30f53462012-12-28 15:39:55 +0530106 "(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 },
Anand Doshi236cc172013-02-18 13:49:15 +0530115 "Material Request Item": {
Rushabh Mehta66aa2652013-02-08 15:06:05 +0530116 "columns": ["item.name as name", "item_code", "warehouse",
Nabin Hait30f53462012-12-28 15:39:55 +0530117 "(ifnull(qty, 0) - ifnull(ordered_qty, 0)) as qty"],
Anand Doshi236cc172013-02-18 13:49:15 +0530118 "from": "`tabMaterial Request Item` item, `tabMaterial Request` main",
Anand Doshicf055802013-02-20 18:44:10 +0530119 "conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'",
120 "material_request_type = 'Purchase'", "ifnull(warehouse, '')!=''",
121 "ifnull(qty, 0) > ifnull(ordered_qty, 0)"],
Nabin Hait30f53462012-12-28 15:39:55 +0530122 "links": {
123 "item_code": ["Item", "name"],
124 "warehouse": ["Warehouse", "name"]
125 },
126 },
127 "Purchase Order Item": {
Rushabh Mehta66aa2652013-02-08 15:06:05 +0530128 "columns": ["item.name as name", "item_code", "warehouse",
Nabin Hait30f53462012-12-28 15:39:55 +0530129 "(ifnull(qty, 0) - ifnull(received_qty, 0)) as qty"],
130 "from": "`tabPurchase Order Item` item, `tabPurchase Order` main",
131 "conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'",
132 "ifnull(warehouse, '')!=''", "ifnull(qty, 0) > ifnull(received_qty, 0)"],
133 "links": {
134 "item_code": ["Item", "name"],
135 "warehouse": ["Warehouse", "name"]
136 },
137 },
Nabin Hait96601592013-01-24 18:24:33 +0530138
Nabin Hait30f53462012-12-28 15:39:55 +0530139 "Sales Order Item": {
Rushabh Mehta66aa2652013-02-08 15:06:05 +0530140 "columns": ["item.name as name", "item_code", "(ifnull(qty, 0) - ifnull(delivered_qty, 0)) as qty",
Nabin Hait30f53462012-12-28 15:39:55 +0530141 "reserved_warehouse as warehouse"],
142 "from": "`tabSales Order Item` item, `tabSales Order` main",
143 "conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'",
144 "ifnull(reserved_warehouse, '')!=''", "ifnull(qty, 0) > ifnull(delivered_qty, 0)"],
145 "links": {
146 "item_code": ["Item", "name"],
147 "warehouse": ["Warehouse", "name"]
148 },
149 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530150
151 # Sales
152 "Customer": {
153 "columns": ["name", "if(customer_name=name, '', customer_name) as customer_name",
154 "customer_group as parent_customer_group", "territory as parent_territory"],
Anand Doshi73519e12012-10-11 14:04:27 +0530155 "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530156 "order_by": "name",
157 "links": {
158 "parent_customer_group": ["Customer Group", "name"],
159 "parent_territory": ["Territory", "name"],
160 }
Rushabh Mehta2ad0d422012-09-18 18:52:05 +0530161 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530162 "Customer Group": {
163 "columns": ["name", "parent_customer_group"],
Anand Doshi73519e12012-10-11 14:04:27 +0530164 "conditions": ["docstatus < 2"],
Rushabh Mehta2ad0d422012-09-18 18:52:05 +0530165 "order_by": "lft"
166 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530167 "Territory": {
168 "columns": ["name", "parent_territory"],
Anand Doshi73519e12012-10-11 14:04:27 +0530169 "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530170 "order_by": "lft"
171 },
172 "Sales Invoice": {
173 "columns": ["name", "customer", "posting_date", "company"],
174 "conditions": ["docstatus=1"],
175 "order_by": "posting_date",
176 "links": {
177 "customer": ["Customer", "name"],
178 "company":["Company", "name"]
179 }
180 },
181 "Sales Invoice Item": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530182 "columns": ["name", "parent", "item_code", "qty", "amount"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530183 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
184 "order_by": "parent",
185 "links": {
186 "parent": ["Sales Invoice", "name"],
187 "item_code": ["Item", "name"]
188 }
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530189 },
Nabin Hait96601592013-01-24 18:24:33 +0530190 "Sales Order": {
191 "columns": ["name", "customer", "transaction_date as posting_date", "company"],
192 "conditions": ["docstatus=1"],
193 "order_by": "transaction_date",
194 "links": {
195 "customer": ["Customer", "name"],
196 "company":["Company", "name"]
197 }
198 },
199 "Sales Order Item[Sales Analytics]": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530200 "columns": ["name", "parent", "item_code", "qty", "amount"],
Nabin Hait96601592013-01-24 18:24:33 +0530201 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
202 "order_by": "parent",
203 "links": {
204 "parent": ["Sales Order", "name"],
205 "item_code": ["Item", "name"]
206 }
207 },
208 "Delivery Note": {
209 "columns": ["name", "customer", "posting_date", "company"],
210 "conditions": ["docstatus=1"],
211 "order_by": "posting_date",
212 "links": {
213 "customer": ["Customer", "name"],
214 "company":["Company", "name"]
215 }
216 },
217 "Delivery Note Item[Sales Analytics]": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530218 "columns": ["name", "parent", "item_code", "qty", "amount"],
Nabin Hait96601592013-01-24 18:24:33 +0530219 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
220 "order_by": "parent",
221 "links": {
222 "parent": ["Delivery Note", "name"],
223 "item_code": ["Item", "name"]
224 }
225 },
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530226 "Supplier": {
227 "columns": ["name", "if(supplier_name=name, '', supplier_name) as supplier_name",
228 "supplier_type as parent_supplier_type"],
Anand Doshi73519e12012-10-11 14:04:27 +0530229 "conditions": ["docstatus < 2"],
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530230 "order_by": "name",
231 "links": {
232 "parent_supplier_type": ["Supplier Type", "name"],
233 }
234 },
235 "Supplier Type": {
236 "columns": ["name"],
Anand Doshi73519e12012-10-11 14:04:27 +0530237 "conditions": ["docstatus < 2"],
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530238 "order_by": "name"
239 },
240 "Purchase Invoice": {
241 "columns": ["name", "supplier", "posting_date", "company"],
242 "conditions": ["docstatus=1"],
243 "order_by": "posting_date",
244 "links": {
245 "supplier": ["Supplier", "name"],
246 "company":["Company", "name"]
247 }
248 },
249 "Purchase Invoice Item": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530250 "columns": ["name", "parent", "item_code", "qty", "amount"],
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530251 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
252 "order_by": "parent",
253 "links": {
254 "parent": ["Purchase Invoice", "name"],
255 "item_code": ["Item", "name"]
256 }
Rushabh Mehta607a2212013-01-04 16:42:33 +0530257 },
Nabin Haitd1301c72013-01-24 18:38:30 +0530258 "Purchase Order": {
259 "columns": ["name", "supplier", "transaction_date as posting_date", "company"],
260 "conditions": ["docstatus=1"],
261 "order_by": "posting_date",
262 "links": {
263 "supplier": ["Supplier", "name"],
264 "company":["Company", "name"]
265 }
266 },
267 "Purchase Order Item[Purchase Analytics]": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530268 "columns": ["name", "parent", "item_code", "qty", "amount"],
Nabin Haitd1301c72013-01-24 18:38:30 +0530269 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
270 "order_by": "parent",
271 "links": {
272 "parent": ["Purchase Order", "name"],
273 "item_code": ["Item", "name"]
274 }
275 },
276 "Purchase Receipt": {
277 "columns": ["name", "supplier", "posting_date", "company"],
278 "conditions": ["docstatus=1"],
279 "order_by": "posting_date",
280 "links": {
281 "supplier": ["Supplier", "name"],
282 "company":["Company", "name"]
283 }
284 },
285 "Purchase Receipt Item[Purchase Analytics]": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530286 "columns": ["name", "parent", "item_code", "qty", "amount"],
Nabin Haitd1301c72013-01-24 18:38:30 +0530287 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
288 "order_by": "parent",
289 "links": {
290 "parent": ["Purchase Receipt", "name"],
291 "item_code": ["Item", "name"]
292 }
293 },
Rushabh Mehta607a2212013-01-04 16:42:33 +0530294 # Support
295 "Support Ticket": {
Rushabh Mehtabe9ef4a2013-01-14 15:48:00 +0530296 "columns": ["name","status","creation","resolution_date","first_responded_on"],
Rushabh Mehta607a2212013-01-04 16:42:33 +0530297 "conditions": ["docstatus < 2"],
298 "order_by": "creation"
Rushabh Mehta95e4e142012-09-13 19:40:56 +0530299 }
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530300
Rushabh Mehta95e4e142012-09-13 19:40:56 +0530301}