blob: 0f6d4fe1940b99d55b18822345c107df8417814f [file] [log] [blame]
Rushabh Mehtae67d1fb2013-08-05 14:59:54 +05301# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
2# License: GNU General Public License v3. See license.txt
Rushabh Mehta95e4e142012-09-13 19:40:56 +05303
Nabin Hait9a90c892012-09-18 13:37:27 +05304from __future__ import unicode_literals
Rushabh Mehta823c0212012-09-19 12:01:01 +05305
6# mappings for table dumps
7# "remember to add indexes!"
8
Rushabh Mehta95e4e142012-09-13 19:40:56 +05309data_map = {
Rushabh Mehtaf200c522012-09-21 15:19:40 +053010 "Company": {
11 "columns": ["name"],
12 "conditions": ["docstatus < 2"]
13 },
14 "Fiscal Year": {
15 "columns": ["name", "year_start_date",
Anand Doshi73519e12012-10-11 14:04:27 +053016 "adddate(adddate(year_start_date, interval 1 year), interval -1 day) as year_end_date"],
17 "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +053018 },
19
20 # Accounts
Rushabh Mehta95e4e142012-09-13 19:40:56 +053021 "Account": {
Anand Doshibc243de2012-09-24 18:03:35 +053022 "columns": ["name", "parent_account", "lft", "rgt", "debit_or_credit",
Rushabh Mehtac68fc3f2012-11-13 13:28:26 +053023 "is_pl_account", "company", "group_or_ledger"],
Anand Doshi73519e12012-10-11 14:04:27 +053024 "conditions": ["docstatus < 2"],
Rushabh Mehtac68fc3f2012-11-13 13:28:26 +053025 "order_by": "lft",
26 "links": {
27 "company": ["Company", "name"],
28 }
29
Rushabh Mehta95e4e142012-09-13 19:40:56 +053030 },
Rushabh Mehta41565232012-09-17 19:10:36 +053031 "Cost Center": {
Rushabh Mehta09d84b62012-09-21 19:46:24 +053032 "columns": ["name", "lft", "rgt"],
Anand Doshi73519e12012-10-11 14:04:27 +053033 "conditions": ["docstatus < 2"],
Rushabh Mehta41565232012-09-17 19:10:36 +053034 "order_by": "lft"
35 },
Rushabh Mehta95e4e142012-09-13 19:40:56 +053036 "GL Entry": {
Nabin Haitf78d16c2013-06-21 15:13:49 +053037 "columns": ["name", "account", "posting_date", "cost_center", "debit", "credit",
Nabin Hait8b96ba12013-06-24 13:54:16 +053038 "is_opening", "company", "voucher_type", "voucher_no", "remarks"],
Rushabh Mehta95e4e142012-09-13 19:40:56 +053039 "conditions": ["ifnull(is_cancelled, 'No')='No'"],
Rushabh Mehta823c0212012-09-19 12:01:01 +053040 "order_by": "posting_date, account",
41 "links": {
42 "account": ["Account", "name"],
Rushabh Mehta09d84b62012-09-21 19:46:24 +053043 "company": ["Company", "name"],
44 "cost_center": ["Cost Center", "name"]
Rushabh Mehta823c0212012-09-19 12:01:01 +053045 }
Rushabh Mehta95e4e142012-09-13 19:40:56 +053046 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +053047
48 # Stock
49 "Item": {
Nabin Hait6072a682012-12-31 17:16:23 +053050 "columns": ["name", "if(item_name=name, '', item_name) as item_name", "description",
Nabin Hait44ffd432013-01-16 11:16:21 +053051 "item_group as parent_item_group", "stock_uom", "brand", "valuation_method",
52 "re_order_level", "re_order_qty"],
Nabin Hait1c08aee2012-12-31 13:30:18 +053053 # "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +053054 "order_by": "name",
55 "links": {
56 "parent_item_group": ["Item Group", "name"],
Nabin Haitce159ab2012-12-25 18:04:10 +053057 "brand": ["Brand", "name"]
Rushabh Mehtaf200c522012-09-21 15:19:40 +053058 }
Rushabh Mehta95e4e142012-09-13 19:40:56 +053059 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +053060 "Item Group": {
61 "columns": ["name", "parent_item_group"],
Nabin Hait3e8eca32013-06-24 17:18:24 +053062 # "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +053063 "order_by": "lft"
64 },
Nabin Haitce159ab2012-12-25 18:04:10 +053065 "Brand": {
66 "columns": ["name"],
67 "conditions": ["docstatus < 2"],
68 "order_by": "name"
69 },
Rushabh Mehta06d186b2013-03-25 17:03:52 +053070 "Project": {
71 "columns": ["name"],
72 "conditions": ["docstatus < 2"],
73 "order_by": "name"
74 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +053075 "Warehouse": {
76 "columns": ["name"],
Anand Doshi73519e12012-10-11 14:04:27 +053077 "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +053078 "order_by": "name"
Rushabh Mehta2ad0d422012-09-18 18:52:05 +053079 },
80 "Stock Ledger Entry": {
Anand Doshid5aeb212013-03-08 12:46:48 +053081 "columns": ["name", "posting_date", "posting_time", "item_code", "warehouse",
Rushabh Mehta06d186b2013-03-25 17:03:52 +053082 "actual_qty as qty", "voucher_type", "voucher_no", "project",
Anand Doshid5aeb212013-03-08 12:46:48 +053083 "ifnull(incoming_rate,0) as incoming_rate", "stock_uom", "serial_no"],
Rushabh Mehta823c0212012-09-19 12:01:01 +053084 "conditions": ["ifnull(is_cancelled, 'No')='No'"],
Rushabh Mehta2ad0d422012-09-18 18:52:05 +053085 "order_by": "posting_date, posting_time, name",
86 "links": {
87 "item_code": ["Item", "name"],
Rushabh Mehta06d186b2013-03-25 17:03:52 +053088 "warehouse": ["Warehouse", "name"],
89 "project": ["Project", "name"]
Rushabh Mehta823c0212012-09-19 12:01:01 +053090 },
Nabin Hait30f53462012-12-28 15:39:55 +053091 "force_index": "posting_sort_index"
Rushabh Mehta2ad0d422012-09-18 18:52:05 +053092 },
Nabin Haitce159ab2012-12-25 18:04:10 +053093 "Stock Entry": {
94 "columns": ["name", "purpose"],
95 "conditions": ["docstatus=1"],
96 "order_by": "posting_date, posting_time, name",
97 },
Nabin Hait30f53462012-12-28 15:39:55 +053098 "Production Order": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +053099 "columns": ["name", "production_item as item_code",
Nabin Hait30f53462012-12-28 15:39:55 +0530100 "(ifnull(qty, 0) - ifnull(produced_qty, 0)) as qty",
101 "fg_warehouse as warehouse"],
102 "conditions": ["docstatus=1", "status != 'Stopped'", "ifnull(fg_warehouse, '')!=''",
103 "ifnull(qty, 0) > ifnull(produced_qty, 0)"],
104 "links": {
105 "item_code": ["Item", "name"],
106 "warehouse": ["Warehouse", "name"]
107 },
108 },
Anand Doshi236cc172013-02-18 13:49:15 +0530109 "Material Request Item": {
Rushabh Mehta66aa2652013-02-08 15:06:05 +0530110 "columns": ["item.name as name", "item_code", "warehouse",
Nabin Hait30f53462012-12-28 15:39:55 +0530111 "(ifnull(qty, 0) - ifnull(ordered_qty, 0)) as qty"],
Anand Doshi236cc172013-02-18 13:49:15 +0530112 "from": "`tabMaterial Request Item` item, `tabMaterial Request` main",
Anand Doshicf055802013-02-20 18:44:10 +0530113 "conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'",
Anand Doshi1678f6d2013-02-21 16:55:14 +0530114 "ifnull(warehouse, '')!=''", "ifnull(qty, 0) > ifnull(ordered_qty, 0)"],
Nabin Hait30f53462012-12-28 15:39:55 +0530115 "links": {
116 "item_code": ["Item", "name"],
117 "warehouse": ["Warehouse", "name"]
118 },
119 },
120 "Purchase Order Item": {
Rushabh Mehta66aa2652013-02-08 15:06:05 +0530121 "columns": ["item.name as name", "item_code", "warehouse",
Nabin Hait30f53462012-12-28 15:39:55 +0530122 "(ifnull(qty, 0) - ifnull(received_qty, 0)) as qty"],
123 "from": "`tabPurchase Order Item` item, `tabPurchase Order` main",
124 "conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'",
125 "ifnull(warehouse, '')!=''", "ifnull(qty, 0) > ifnull(received_qty, 0)"],
126 "links": {
127 "item_code": ["Item", "name"],
128 "warehouse": ["Warehouse", "name"]
129 },
130 },
Nabin Hait96601592013-01-24 18:24:33 +0530131
Nabin Hait30f53462012-12-28 15:39:55 +0530132 "Sales Order Item": {
Rushabh Mehta66aa2652013-02-08 15:06:05 +0530133 "columns": ["item.name as name", "item_code", "(ifnull(qty, 0) - ifnull(delivered_qty, 0)) as qty",
Nabin Hait30f53462012-12-28 15:39:55 +0530134 "reserved_warehouse as warehouse"],
135 "from": "`tabSales Order Item` item, `tabSales Order` main",
136 "conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'",
137 "ifnull(reserved_warehouse, '')!=''", "ifnull(qty, 0) > ifnull(delivered_qty, 0)"],
138 "links": {
139 "item_code": ["Item", "name"],
140 "warehouse": ["Warehouse", "name"]
141 },
142 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530143
144 # Sales
145 "Customer": {
146 "columns": ["name", "if(customer_name=name, '', customer_name) as customer_name",
147 "customer_group as parent_customer_group", "territory as parent_territory"],
Anand Doshi73519e12012-10-11 14:04:27 +0530148 "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530149 "order_by": "name",
150 "links": {
151 "parent_customer_group": ["Customer Group", "name"],
152 "parent_territory": ["Territory", "name"],
153 }
Rushabh Mehta2ad0d422012-09-18 18:52:05 +0530154 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530155 "Customer Group": {
156 "columns": ["name", "parent_customer_group"],
Anand Doshi73519e12012-10-11 14:04:27 +0530157 "conditions": ["docstatus < 2"],
Rushabh Mehta2ad0d422012-09-18 18:52:05 +0530158 "order_by": "lft"
159 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530160 "Territory": {
161 "columns": ["name", "parent_territory"],
Anand Doshi73519e12012-10-11 14:04:27 +0530162 "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530163 "order_by": "lft"
164 },
165 "Sales Invoice": {
166 "columns": ["name", "customer", "posting_date", "company"],
167 "conditions": ["docstatus=1"],
168 "order_by": "posting_date",
169 "links": {
170 "customer": ["Customer", "name"],
171 "company":["Company", "name"]
172 }
173 },
174 "Sales Invoice Item": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530175 "columns": ["name", "parent", "item_code", "qty", "amount"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530176 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
177 "order_by": "parent",
178 "links": {
179 "parent": ["Sales Invoice", "name"],
180 "item_code": ["Item", "name"]
181 }
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530182 },
Nabin Hait96601592013-01-24 18:24:33 +0530183 "Sales Order": {
184 "columns": ["name", "customer", "transaction_date as posting_date", "company"],
185 "conditions": ["docstatus=1"],
186 "order_by": "transaction_date",
187 "links": {
188 "customer": ["Customer", "name"],
189 "company":["Company", "name"]
190 }
191 },
192 "Sales Order Item[Sales Analytics]": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530193 "columns": ["name", "parent", "item_code", "qty", "amount"],
Nabin Hait96601592013-01-24 18:24:33 +0530194 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
195 "order_by": "parent",
196 "links": {
197 "parent": ["Sales Order", "name"],
198 "item_code": ["Item", "name"]
199 }
200 },
201 "Delivery Note": {
202 "columns": ["name", "customer", "posting_date", "company"],
203 "conditions": ["docstatus=1"],
204 "order_by": "posting_date",
205 "links": {
206 "customer": ["Customer", "name"],
207 "company":["Company", "name"]
208 }
209 },
210 "Delivery Note Item[Sales Analytics]": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530211 "columns": ["name", "parent", "item_code", "qty", "amount"],
Nabin Hait96601592013-01-24 18:24:33 +0530212 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
213 "order_by": "parent",
214 "links": {
215 "parent": ["Delivery Note", "name"],
216 "item_code": ["Item", "name"]
217 }
218 },
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530219 "Supplier": {
220 "columns": ["name", "if(supplier_name=name, '', supplier_name) as supplier_name",
221 "supplier_type as parent_supplier_type"],
Anand Doshi73519e12012-10-11 14:04:27 +0530222 "conditions": ["docstatus < 2"],
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530223 "order_by": "name",
224 "links": {
225 "parent_supplier_type": ["Supplier Type", "name"],
226 }
227 },
228 "Supplier Type": {
229 "columns": ["name"],
Anand Doshi73519e12012-10-11 14:04:27 +0530230 "conditions": ["docstatus < 2"],
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530231 "order_by": "name"
232 },
233 "Purchase Invoice": {
234 "columns": ["name", "supplier", "posting_date", "company"],
235 "conditions": ["docstatus=1"],
236 "order_by": "posting_date",
237 "links": {
238 "supplier": ["Supplier", "name"],
239 "company":["Company", "name"]
240 }
241 },
242 "Purchase Invoice Item": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530243 "columns": ["name", "parent", "item_code", "qty", "amount"],
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530244 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
245 "order_by": "parent",
246 "links": {
247 "parent": ["Purchase Invoice", "name"],
248 "item_code": ["Item", "name"]
249 }
Rushabh Mehta607a2212013-01-04 16:42:33 +0530250 },
Nabin Haitd1301c72013-01-24 18:38:30 +0530251 "Purchase Order": {
252 "columns": ["name", "supplier", "transaction_date as posting_date", "company"],
253 "conditions": ["docstatus=1"],
254 "order_by": "posting_date",
255 "links": {
256 "supplier": ["Supplier", "name"],
257 "company":["Company", "name"]
258 }
259 },
260 "Purchase Order Item[Purchase Analytics]": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530261 "columns": ["name", "parent", "item_code", "qty", "amount"],
Nabin Haitd1301c72013-01-24 18:38:30 +0530262 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
263 "order_by": "parent",
264 "links": {
265 "parent": ["Purchase Order", "name"],
266 "item_code": ["Item", "name"]
267 }
268 },
269 "Purchase Receipt": {
270 "columns": ["name", "supplier", "posting_date", "company"],
271 "conditions": ["docstatus=1"],
272 "order_by": "posting_date",
273 "links": {
274 "supplier": ["Supplier", "name"],
275 "company":["Company", "name"]
276 }
277 },
278 "Purchase Receipt Item[Purchase Analytics]": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530279 "columns": ["name", "parent", "item_code", "qty", "amount"],
Nabin Haitd1301c72013-01-24 18:38:30 +0530280 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
281 "order_by": "parent",
282 "links": {
283 "parent": ["Purchase Receipt", "name"],
284 "item_code": ["Item", "name"]
285 }
286 },
Rushabh Mehta607a2212013-01-04 16:42:33 +0530287 # Support
288 "Support Ticket": {
Rushabh Mehtabe9ef4a2013-01-14 15:48:00 +0530289 "columns": ["name","status","creation","resolution_date","first_responded_on"],
Rushabh Mehta607a2212013-01-04 16:42:33 +0530290 "conditions": ["docstatus < 2"],
291 "order_by": "creation"
Rushabh Mehta95e4e142012-09-13 19:40:56 +0530292 }
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530293
Rushabh Mehta95e4e142012-09-13 19:40:56 +0530294}