blob: ae3a53fb40b255be6fc948f70f340c03d21a6bce [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": {
Nabin Haitf78d16c2013-06-21 15:13:49 +053050 "columns": ["name", "account", "posting_date", "cost_center", "debit", "credit",
51 "is_opening", "company", "voucher_type", "voucher_no", "remarks",
52 "against_voucher_type", "against_voucher"],
Rushabh Mehta95e4e142012-09-13 19:40:56 +053053 "conditions": ["ifnull(is_cancelled, 'No')='No'"],
Rushabh Mehta823c0212012-09-19 12:01:01 +053054 "order_by": "posting_date, account",
55 "links": {
56 "account": ["Account", "name"],
Rushabh Mehta09d84b62012-09-21 19:46:24 +053057 "company": ["Company", "name"],
58 "cost_center": ["Cost Center", "name"]
Rushabh Mehta823c0212012-09-19 12:01:01 +053059 }
Rushabh Mehta95e4e142012-09-13 19:40:56 +053060 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +053061
62 # Stock
63 "Item": {
Nabin Hait6072a682012-12-31 17:16:23 +053064 "columns": ["name", "if(item_name=name, '', item_name) as item_name", "description",
Nabin Hait44ffd432013-01-16 11:16:21 +053065 "item_group as parent_item_group", "stock_uom", "brand", "valuation_method",
66 "re_order_level", "re_order_qty"],
Nabin Hait1c08aee2012-12-31 13:30:18 +053067 # "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +053068 "order_by": "name",
69 "links": {
70 "parent_item_group": ["Item Group", "name"],
Nabin Haitce159ab2012-12-25 18:04:10 +053071 "brand": ["Brand", "name"]
Rushabh Mehtaf200c522012-09-21 15:19:40 +053072 }
Rushabh Mehta95e4e142012-09-13 19:40:56 +053073 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +053074 "Item Group": {
75 "columns": ["name", "parent_item_group"],
Anand Doshi73519e12012-10-11 14:04:27 +053076 "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +053077 "order_by": "lft"
78 },
Nabin Haitce159ab2012-12-25 18:04:10 +053079 "Brand": {
80 "columns": ["name"],
81 "conditions": ["docstatus < 2"],
82 "order_by": "name"
83 },
Rushabh Mehta06d186b2013-03-25 17:03:52 +053084 "Project": {
85 "columns": ["name"],
86 "conditions": ["docstatus < 2"],
87 "order_by": "name"
88 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +053089 "Warehouse": {
90 "columns": ["name"],
Anand Doshi73519e12012-10-11 14:04:27 +053091 "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +053092 "order_by": "name"
Rushabh Mehta2ad0d422012-09-18 18:52:05 +053093 },
94 "Stock Ledger Entry": {
Anand Doshid5aeb212013-03-08 12:46:48 +053095 "columns": ["name", "posting_date", "posting_time", "item_code", "warehouse",
Rushabh Mehta06d186b2013-03-25 17:03:52 +053096 "actual_qty as qty", "voucher_type", "voucher_no", "project",
Anand Doshid5aeb212013-03-08 12:46:48 +053097 "ifnull(incoming_rate,0) as incoming_rate", "stock_uom", "serial_no"],
Rushabh Mehta823c0212012-09-19 12:01:01 +053098 "conditions": ["ifnull(is_cancelled, 'No')='No'"],
Rushabh Mehta2ad0d422012-09-18 18:52:05 +053099 "order_by": "posting_date, posting_time, name",
100 "links": {
101 "item_code": ["Item", "name"],
Rushabh Mehta06d186b2013-03-25 17:03:52 +0530102 "warehouse": ["Warehouse", "name"],
103 "project": ["Project", "name"]
Rushabh Mehta823c0212012-09-19 12:01:01 +0530104 },
Nabin Hait30f53462012-12-28 15:39:55 +0530105 "force_index": "posting_sort_index"
Rushabh Mehta2ad0d422012-09-18 18:52:05 +0530106 },
Nabin Haitce159ab2012-12-25 18:04:10 +0530107 "Stock Entry": {
108 "columns": ["name", "purpose"],
109 "conditions": ["docstatus=1"],
110 "order_by": "posting_date, posting_time, name",
111 },
Nabin Hait30f53462012-12-28 15:39:55 +0530112 "Production Order": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530113 "columns": ["name", "production_item as item_code",
Nabin Hait30f53462012-12-28 15:39:55 +0530114 "(ifnull(qty, 0) - ifnull(produced_qty, 0)) as qty",
115 "fg_warehouse as warehouse"],
116 "conditions": ["docstatus=1", "status != 'Stopped'", "ifnull(fg_warehouse, '')!=''",
117 "ifnull(qty, 0) > ifnull(produced_qty, 0)"],
118 "links": {
119 "item_code": ["Item", "name"],
120 "warehouse": ["Warehouse", "name"]
121 },
122 },
Anand Doshi236cc172013-02-18 13:49:15 +0530123 "Material Request Item": {
Rushabh Mehta66aa2652013-02-08 15:06:05 +0530124 "columns": ["item.name as name", "item_code", "warehouse",
Nabin Hait30f53462012-12-28 15:39:55 +0530125 "(ifnull(qty, 0) - ifnull(ordered_qty, 0)) as qty"],
Anand Doshi236cc172013-02-18 13:49:15 +0530126 "from": "`tabMaterial Request Item` item, `tabMaterial Request` main",
Anand Doshicf055802013-02-20 18:44:10 +0530127 "conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'",
Anand Doshi1678f6d2013-02-21 16:55:14 +0530128 "ifnull(warehouse, '')!=''", "ifnull(qty, 0) > ifnull(ordered_qty, 0)"],
Nabin Hait30f53462012-12-28 15:39:55 +0530129 "links": {
130 "item_code": ["Item", "name"],
131 "warehouse": ["Warehouse", "name"]
132 },
133 },
134 "Purchase Order Item": {
Rushabh Mehta66aa2652013-02-08 15:06:05 +0530135 "columns": ["item.name as name", "item_code", "warehouse",
Nabin Hait30f53462012-12-28 15:39:55 +0530136 "(ifnull(qty, 0) - ifnull(received_qty, 0)) as qty"],
137 "from": "`tabPurchase Order Item` item, `tabPurchase Order` main",
138 "conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'",
139 "ifnull(warehouse, '')!=''", "ifnull(qty, 0) > ifnull(received_qty, 0)"],
140 "links": {
141 "item_code": ["Item", "name"],
142 "warehouse": ["Warehouse", "name"]
143 },
144 },
Nabin Hait96601592013-01-24 18:24:33 +0530145
Nabin Hait30f53462012-12-28 15:39:55 +0530146 "Sales Order Item": {
Rushabh Mehta66aa2652013-02-08 15:06:05 +0530147 "columns": ["item.name as name", "item_code", "(ifnull(qty, 0) - ifnull(delivered_qty, 0)) as qty",
Nabin Hait30f53462012-12-28 15:39:55 +0530148 "reserved_warehouse as warehouse"],
149 "from": "`tabSales Order Item` item, `tabSales Order` main",
150 "conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'",
151 "ifnull(reserved_warehouse, '')!=''", "ifnull(qty, 0) > ifnull(delivered_qty, 0)"],
152 "links": {
153 "item_code": ["Item", "name"],
154 "warehouse": ["Warehouse", "name"]
155 },
156 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530157
158 # Sales
159 "Customer": {
160 "columns": ["name", "if(customer_name=name, '', customer_name) as customer_name",
161 "customer_group as parent_customer_group", "territory as parent_territory"],
Anand Doshi73519e12012-10-11 14:04:27 +0530162 "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530163 "order_by": "name",
164 "links": {
165 "parent_customer_group": ["Customer Group", "name"],
166 "parent_territory": ["Territory", "name"],
167 }
Rushabh Mehta2ad0d422012-09-18 18:52:05 +0530168 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530169 "Customer Group": {
170 "columns": ["name", "parent_customer_group"],
Anand Doshi73519e12012-10-11 14:04:27 +0530171 "conditions": ["docstatus < 2"],
Rushabh Mehta2ad0d422012-09-18 18:52:05 +0530172 "order_by": "lft"
173 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530174 "Territory": {
175 "columns": ["name", "parent_territory"],
Anand Doshi73519e12012-10-11 14:04:27 +0530176 "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530177 "order_by": "lft"
178 },
179 "Sales Invoice": {
180 "columns": ["name", "customer", "posting_date", "company"],
181 "conditions": ["docstatus=1"],
182 "order_by": "posting_date",
183 "links": {
184 "customer": ["Customer", "name"],
185 "company":["Company", "name"]
186 }
187 },
188 "Sales Invoice Item": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530189 "columns": ["name", "parent", "item_code", "qty", "amount"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530190 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
191 "order_by": "parent",
192 "links": {
193 "parent": ["Sales Invoice", "name"],
194 "item_code": ["Item", "name"]
195 }
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530196 },
Nabin Hait96601592013-01-24 18:24:33 +0530197 "Sales Order": {
198 "columns": ["name", "customer", "transaction_date as posting_date", "company"],
199 "conditions": ["docstatus=1"],
200 "order_by": "transaction_date",
201 "links": {
202 "customer": ["Customer", "name"],
203 "company":["Company", "name"]
204 }
205 },
206 "Sales Order Item[Sales Analytics]": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530207 "columns": ["name", "parent", "item_code", "qty", "amount"],
Nabin Hait96601592013-01-24 18:24:33 +0530208 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
209 "order_by": "parent",
210 "links": {
211 "parent": ["Sales Order", "name"],
212 "item_code": ["Item", "name"]
213 }
214 },
215 "Delivery Note": {
216 "columns": ["name", "customer", "posting_date", "company"],
217 "conditions": ["docstatus=1"],
218 "order_by": "posting_date",
219 "links": {
220 "customer": ["Customer", "name"],
221 "company":["Company", "name"]
222 }
223 },
224 "Delivery Note Item[Sales Analytics]": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530225 "columns": ["name", "parent", "item_code", "qty", "amount"],
Nabin Hait96601592013-01-24 18:24:33 +0530226 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
227 "order_by": "parent",
228 "links": {
229 "parent": ["Delivery Note", "name"],
230 "item_code": ["Item", "name"]
231 }
232 },
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530233 "Supplier": {
234 "columns": ["name", "if(supplier_name=name, '', supplier_name) as supplier_name",
235 "supplier_type as parent_supplier_type"],
Anand Doshi73519e12012-10-11 14:04:27 +0530236 "conditions": ["docstatus < 2"],
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530237 "order_by": "name",
238 "links": {
239 "parent_supplier_type": ["Supplier Type", "name"],
240 }
241 },
242 "Supplier Type": {
243 "columns": ["name"],
Anand Doshi73519e12012-10-11 14:04:27 +0530244 "conditions": ["docstatus < 2"],
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530245 "order_by": "name"
246 },
247 "Purchase Invoice": {
248 "columns": ["name", "supplier", "posting_date", "company"],
249 "conditions": ["docstatus=1"],
250 "order_by": "posting_date",
251 "links": {
252 "supplier": ["Supplier", "name"],
253 "company":["Company", "name"]
254 }
255 },
256 "Purchase Invoice Item": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530257 "columns": ["name", "parent", "item_code", "qty", "amount"],
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530258 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
259 "order_by": "parent",
260 "links": {
261 "parent": ["Purchase Invoice", "name"],
262 "item_code": ["Item", "name"]
263 }
Rushabh Mehta607a2212013-01-04 16:42:33 +0530264 },
Nabin Haitd1301c72013-01-24 18:38:30 +0530265 "Purchase Order": {
266 "columns": ["name", "supplier", "transaction_date as posting_date", "company"],
267 "conditions": ["docstatus=1"],
268 "order_by": "posting_date",
269 "links": {
270 "supplier": ["Supplier", "name"],
271 "company":["Company", "name"]
272 }
273 },
274 "Purchase Order Item[Purchase Analytics]": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530275 "columns": ["name", "parent", "item_code", "qty", "amount"],
Nabin Haitd1301c72013-01-24 18:38:30 +0530276 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
277 "order_by": "parent",
278 "links": {
279 "parent": ["Purchase Order", "name"],
280 "item_code": ["Item", "name"]
281 }
282 },
283 "Purchase Receipt": {
284 "columns": ["name", "supplier", "posting_date", "company"],
285 "conditions": ["docstatus=1"],
286 "order_by": "posting_date",
287 "links": {
288 "supplier": ["Supplier", "name"],
289 "company":["Company", "name"]
290 }
291 },
292 "Purchase Receipt Item[Purchase Analytics]": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530293 "columns": ["name", "parent", "item_code", "qty", "amount"],
Nabin Haitd1301c72013-01-24 18:38:30 +0530294 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
295 "order_by": "parent",
296 "links": {
297 "parent": ["Purchase Receipt", "name"],
298 "item_code": ["Item", "name"]
299 }
300 },
Rushabh Mehta607a2212013-01-04 16:42:33 +0530301 # Support
302 "Support Ticket": {
Rushabh Mehtabe9ef4a2013-01-14 15:48:00 +0530303 "columns": ["name","status","creation","resolution_date","first_responded_on"],
Rushabh Mehta607a2212013-01-04 16:42:33 +0530304 "conditions": ["docstatus < 2"],
305 "order_by": "creation"
Rushabh Mehta95e4e142012-09-13 19:40:56 +0530306 }
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530307
Rushabh Mehta95e4e142012-09-13 19:40:56 +0530308}