blob: c3a5dd2cce9b4d8a300754e1ed7311ac49c8ad32 [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",
Nabin Hait8b96ba12013-06-24 13:54:16 +053051 "is_opening", "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"],
Nabin Hait3e8eca32013-06-24 17:18:24 +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 Mehta06d186b2013-03-25 17:03:52 +053083 "Project": {
84 "columns": ["name"],
85 "conditions": ["docstatus < 2"],
86 "order_by": "name"
87 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +053088 "Warehouse": {
89 "columns": ["name"],
Anand Doshi73519e12012-10-11 14:04:27 +053090 "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +053091 "order_by": "name"
Rushabh Mehta2ad0d422012-09-18 18:52:05 +053092 },
93 "Stock Ledger Entry": {
Anand Doshid5aeb212013-03-08 12:46:48 +053094 "columns": ["name", "posting_date", "posting_time", "item_code", "warehouse",
Rushabh Mehta06d186b2013-03-25 17:03:52 +053095 "actual_qty as qty", "voucher_type", "voucher_no", "project",
Anand Doshid5aeb212013-03-08 12:46:48 +053096 "ifnull(incoming_rate,0) as incoming_rate", "stock_uom", "serial_no"],
Rushabh Mehta823c0212012-09-19 12:01:01 +053097 "conditions": ["ifnull(is_cancelled, 'No')='No'"],
Rushabh Mehta2ad0d422012-09-18 18:52:05 +053098 "order_by": "posting_date, posting_time, name",
99 "links": {
100 "item_code": ["Item", "name"],
Rushabh Mehta06d186b2013-03-25 17:03:52 +0530101 "warehouse": ["Warehouse", "name"],
102 "project": ["Project", "name"]
Rushabh Mehta823c0212012-09-19 12:01:01 +0530103 },
Nabin Hait30f53462012-12-28 15:39:55 +0530104 "force_index": "posting_sort_index"
Rushabh Mehta2ad0d422012-09-18 18:52:05 +0530105 },
Nabin Haitce159ab2012-12-25 18:04:10 +0530106 "Stock Entry": {
107 "columns": ["name", "purpose"],
108 "conditions": ["docstatus=1"],
109 "order_by": "posting_date, posting_time, name",
110 },
Nabin Hait30f53462012-12-28 15:39:55 +0530111 "Production Order": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530112 "columns": ["name", "production_item as item_code",
Nabin Hait30f53462012-12-28 15:39:55 +0530113 "(ifnull(qty, 0) - ifnull(produced_qty, 0)) as qty",
114 "fg_warehouse as warehouse"],
115 "conditions": ["docstatus=1", "status != 'Stopped'", "ifnull(fg_warehouse, '')!=''",
116 "ifnull(qty, 0) > ifnull(produced_qty, 0)"],
117 "links": {
118 "item_code": ["Item", "name"],
119 "warehouse": ["Warehouse", "name"]
120 },
121 },
Anand Doshi236cc172013-02-18 13:49:15 +0530122 "Material Request Item": {
Rushabh Mehta66aa2652013-02-08 15:06:05 +0530123 "columns": ["item.name as name", "item_code", "warehouse",
Nabin Hait30f53462012-12-28 15:39:55 +0530124 "(ifnull(qty, 0) - ifnull(ordered_qty, 0)) as qty"],
Anand Doshi236cc172013-02-18 13:49:15 +0530125 "from": "`tabMaterial Request Item` item, `tabMaterial Request` main",
Anand Doshicf055802013-02-20 18:44:10 +0530126 "conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'",
Anand Doshi1678f6d2013-02-21 16:55:14 +0530127 "ifnull(warehouse, '')!=''", "ifnull(qty, 0) > ifnull(ordered_qty, 0)"],
Nabin Hait30f53462012-12-28 15:39:55 +0530128 "links": {
129 "item_code": ["Item", "name"],
130 "warehouse": ["Warehouse", "name"]
131 },
132 },
133 "Purchase Order Item": {
Rushabh Mehta66aa2652013-02-08 15:06:05 +0530134 "columns": ["item.name as name", "item_code", "warehouse",
Nabin Hait30f53462012-12-28 15:39:55 +0530135 "(ifnull(qty, 0) - ifnull(received_qty, 0)) as qty"],
136 "from": "`tabPurchase Order Item` item, `tabPurchase Order` main",
137 "conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'",
138 "ifnull(warehouse, '')!=''", "ifnull(qty, 0) > ifnull(received_qty, 0)"],
139 "links": {
140 "item_code": ["Item", "name"],
141 "warehouse": ["Warehouse", "name"]
142 },
143 },
Nabin Hait96601592013-01-24 18:24:33 +0530144
Nabin Hait30f53462012-12-28 15:39:55 +0530145 "Sales Order Item": {
Rushabh Mehta66aa2652013-02-08 15:06:05 +0530146 "columns": ["item.name as name", "item_code", "(ifnull(qty, 0) - ifnull(delivered_qty, 0)) as qty",
Nabin Hait30f53462012-12-28 15:39:55 +0530147 "reserved_warehouse as warehouse"],
148 "from": "`tabSales Order Item` item, `tabSales Order` main",
149 "conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'",
150 "ifnull(reserved_warehouse, '')!=''", "ifnull(qty, 0) > ifnull(delivered_qty, 0)"],
151 "links": {
152 "item_code": ["Item", "name"],
153 "warehouse": ["Warehouse", "name"]
154 },
155 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530156
157 # Sales
158 "Customer": {
159 "columns": ["name", "if(customer_name=name, '', customer_name) as customer_name",
160 "customer_group as parent_customer_group", "territory as parent_territory"],
Anand Doshi73519e12012-10-11 14:04:27 +0530161 "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530162 "order_by": "name",
163 "links": {
164 "parent_customer_group": ["Customer Group", "name"],
165 "parent_territory": ["Territory", "name"],
166 }
Rushabh Mehta2ad0d422012-09-18 18:52:05 +0530167 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530168 "Customer Group": {
169 "columns": ["name", "parent_customer_group"],
Anand Doshi73519e12012-10-11 14:04:27 +0530170 "conditions": ["docstatus < 2"],
Rushabh Mehta2ad0d422012-09-18 18:52:05 +0530171 "order_by": "lft"
172 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530173 "Territory": {
174 "columns": ["name", "parent_territory"],
Anand Doshi73519e12012-10-11 14:04:27 +0530175 "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530176 "order_by": "lft"
177 },
178 "Sales Invoice": {
179 "columns": ["name", "customer", "posting_date", "company"],
180 "conditions": ["docstatus=1"],
181 "order_by": "posting_date",
182 "links": {
183 "customer": ["Customer", "name"],
184 "company":["Company", "name"]
185 }
186 },
187 "Sales Invoice Item": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530188 "columns": ["name", "parent", "item_code", "qty", "amount"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530189 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
190 "order_by": "parent",
191 "links": {
192 "parent": ["Sales Invoice", "name"],
193 "item_code": ["Item", "name"]
194 }
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530195 },
Nabin Hait96601592013-01-24 18:24:33 +0530196 "Sales Order": {
197 "columns": ["name", "customer", "transaction_date as posting_date", "company"],
198 "conditions": ["docstatus=1"],
199 "order_by": "transaction_date",
200 "links": {
201 "customer": ["Customer", "name"],
202 "company":["Company", "name"]
203 }
204 },
205 "Sales Order Item[Sales Analytics]": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530206 "columns": ["name", "parent", "item_code", "qty", "amount"],
Nabin Hait96601592013-01-24 18:24:33 +0530207 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
208 "order_by": "parent",
209 "links": {
210 "parent": ["Sales Order", "name"],
211 "item_code": ["Item", "name"]
212 }
213 },
214 "Delivery Note": {
215 "columns": ["name", "customer", "posting_date", "company"],
216 "conditions": ["docstatus=1"],
217 "order_by": "posting_date",
218 "links": {
219 "customer": ["Customer", "name"],
220 "company":["Company", "name"]
221 }
222 },
223 "Delivery Note Item[Sales Analytics]": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530224 "columns": ["name", "parent", "item_code", "qty", "amount"],
Nabin Hait96601592013-01-24 18:24:33 +0530225 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
226 "order_by": "parent",
227 "links": {
228 "parent": ["Delivery Note", "name"],
229 "item_code": ["Item", "name"]
230 }
231 },
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530232 "Supplier": {
233 "columns": ["name", "if(supplier_name=name, '', supplier_name) as supplier_name",
234 "supplier_type as parent_supplier_type"],
Anand Doshi73519e12012-10-11 14:04:27 +0530235 "conditions": ["docstatus < 2"],
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530236 "order_by": "name",
237 "links": {
238 "parent_supplier_type": ["Supplier Type", "name"],
239 }
240 },
241 "Supplier Type": {
242 "columns": ["name"],
Anand Doshi73519e12012-10-11 14:04:27 +0530243 "conditions": ["docstatus < 2"],
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530244 "order_by": "name"
245 },
246 "Purchase Invoice": {
247 "columns": ["name", "supplier", "posting_date", "company"],
248 "conditions": ["docstatus=1"],
249 "order_by": "posting_date",
250 "links": {
251 "supplier": ["Supplier", "name"],
252 "company":["Company", "name"]
253 }
254 },
255 "Purchase Invoice Item": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530256 "columns": ["name", "parent", "item_code", "qty", "amount"],
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530257 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
258 "order_by": "parent",
259 "links": {
260 "parent": ["Purchase Invoice", "name"],
261 "item_code": ["Item", "name"]
262 }
Rushabh Mehta607a2212013-01-04 16:42:33 +0530263 },
Nabin Haitd1301c72013-01-24 18:38:30 +0530264 "Purchase Order": {
265 "columns": ["name", "supplier", "transaction_date as posting_date", "company"],
266 "conditions": ["docstatus=1"],
267 "order_by": "posting_date",
268 "links": {
269 "supplier": ["Supplier", "name"],
270 "company":["Company", "name"]
271 }
272 },
273 "Purchase Order Item[Purchase Analytics]": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530274 "columns": ["name", "parent", "item_code", "qty", "amount"],
Nabin Haitd1301c72013-01-24 18:38:30 +0530275 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
276 "order_by": "parent",
277 "links": {
278 "parent": ["Purchase Order", "name"],
279 "item_code": ["Item", "name"]
280 }
281 },
282 "Purchase Receipt": {
283 "columns": ["name", "supplier", "posting_date", "company"],
284 "conditions": ["docstatus=1"],
285 "order_by": "posting_date",
286 "links": {
287 "supplier": ["Supplier", "name"],
288 "company":["Company", "name"]
289 }
290 },
291 "Purchase Receipt Item[Purchase Analytics]": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530292 "columns": ["name", "parent", "item_code", "qty", "amount"],
Nabin Haitd1301c72013-01-24 18:38:30 +0530293 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
294 "order_by": "parent",
295 "links": {
296 "parent": ["Purchase Receipt", "name"],
297 "item_code": ["Item", "name"]
298 }
299 },
Rushabh Mehta607a2212013-01-04 16:42:33 +0530300 # Support
301 "Support Ticket": {
Rushabh Mehtabe9ef4a2013-01-14 15:48:00 +0530302 "columns": ["name","status","creation","resolution_date","first_responded_on"],
Rushabh Mehta607a2212013-01-04 16:42:33 +0530303 "conditions": ["docstatus < 2"],
304 "order_by": "creation"
Rushabh Mehta95e4e142012-09-13 19:40:56 +0530305 }
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530306
Rushabh Mehta95e4e142012-09-13 19:40:56 +0530307}