blob: c1f962790efd424375507b5deea2640d36ca8132 [file] [log] [blame]
Rushabh Mehtaad45e312013-11-20 12:59:58 +05301# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
Rushabh Mehtae67d1fb2013-08-05 14:59:54 +05302# 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 Mehta823c0212012-09-19 12:01:01 +053039 "order_by": "posting_date, account",
40 "links": {
41 "account": ["Account", "name"],
Rushabh Mehta09d84b62012-09-21 19:46:24 +053042 "company": ["Company", "name"],
43 "cost_center": ["Cost Center", "name"]
Rushabh Mehta823c0212012-09-19 12:01:01 +053044 }
Rushabh Mehta95e4e142012-09-13 19:40:56 +053045 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +053046
47 # Stock
48 "Item": {
Nabin Hait6072a682012-12-31 17:16:23 +053049 "columns": ["name", "if(item_name=name, '', item_name) as item_name", "description",
Nabin Hait44ffd432013-01-16 11:16:21 +053050 "item_group as parent_item_group", "stock_uom", "brand", "valuation_method",
51 "re_order_level", "re_order_qty"],
Nabin Hait1c08aee2012-12-31 13:30:18 +053052 # "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +053053 "order_by": "name",
54 "links": {
55 "parent_item_group": ["Item Group", "name"],
Nabin Haitce159ab2012-12-25 18:04:10 +053056 "brand": ["Brand", "name"]
Rushabh Mehtaf200c522012-09-21 15:19:40 +053057 }
Rushabh Mehta95e4e142012-09-13 19:40:56 +053058 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +053059 "Item Group": {
60 "columns": ["name", "parent_item_group"],
Nabin Hait3e8eca32013-06-24 17:18:24 +053061 # "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +053062 "order_by": "lft"
63 },
Nabin Haitce159ab2012-12-25 18:04:10 +053064 "Brand": {
65 "columns": ["name"],
66 "conditions": ["docstatus < 2"],
67 "order_by": "name"
68 },
Rushabh Mehta06d186b2013-03-25 17:03:52 +053069 "Project": {
70 "columns": ["name"],
71 "conditions": ["docstatus < 2"],
72 "order_by": "name"
73 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +053074 "Warehouse": {
75 "columns": ["name"],
Anand Doshi73519e12012-10-11 14:04:27 +053076 "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +053077 "order_by": "name"
Rushabh Mehta2ad0d422012-09-18 18:52:05 +053078 },
79 "Stock Ledger Entry": {
Anand Doshid5aeb212013-03-08 12:46:48 +053080 "columns": ["name", "posting_date", "posting_time", "item_code", "warehouse",
Rushabh Mehta06d186b2013-03-25 17:03:52 +053081 "actual_qty as qty", "voucher_type", "voucher_no", "project",
Anand Doshid5aeb212013-03-08 12:46:48 +053082 "ifnull(incoming_rate,0) as incoming_rate", "stock_uom", "serial_no"],
Rushabh Mehta2ad0d422012-09-18 18:52:05 +053083 "order_by": "posting_date, posting_time, name",
84 "links": {
85 "item_code": ["Item", "name"],
Rushabh Mehta06d186b2013-03-25 17:03:52 +053086 "warehouse": ["Warehouse", "name"],
87 "project": ["Project", "name"]
Rushabh Mehta823c0212012-09-19 12:01:01 +053088 },
Nabin Hait30f53462012-12-28 15:39:55 +053089 "force_index": "posting_sort_index"
Rushabh Mehta2ad0d422012-09-18 18:52:05 +053090 },
Nabin Haite505fbe2013-11-15 13:38:23 +053091 "Serial No": {
92 "columns": ["name", "purchase_rate as incoming_rate"],
93 "conditions": ["docstatus < 2"],
94 "order_by": "name"
95 },
Nabin Haitce159ab2012-12-25 18:04:10 +053096 "Stock Entry": {
97 "columns": ["name", "purpose"],
98 "conditions": ["docstatus=1"],
99 "order_by": "posting_date, posting_time, name",
100 },
Nabin Hait30f53462012-12-28 15:39:55 +0530101 "Production Order": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530102 "columns": ["name", "production_item as item_code",
Nabin Hait30f53462012-12-28 15:39:55 +0530103 "(ifnull(qty, 0) - ifnull(produced_qty, 0)) as qty",
104 "fg_warehouse as warehouse"],
105 "conditions": ["docstatus=1", "status != 'Stopped'", "ifnull(fg_warehouse, '')!=''",
106 "ifnull(qty, 0) > ifnull(produced_qty, 0)"],
107 "links": {
108 "item_code": ["Item", "name"],
109 "warehouse": ["Warehouse", "name"]
110 },
111 },
Anand Doshi236cc172013-02-18 13:49:15 +0530112 "Material Request Item": {
Rushabh Mehta66aa2652013-02-08 15:06:05 +0530113 "columns": ["item.name as name", "item_code", "warehouse",
Nabin Hait30f53462012-12-28 15:39:55 +0530114 "(ifnull(qty, 0) - ifnull(ordered_qty, 0)) as qty"],
Anand Doshi236cc172013-02-18 13:49:15 +0530115 "from": "`tabMaterial Request Item` item, `tabMaterial Request` main",
Anand Doshicf055802013-02-20 18:44:10 +0530116 "conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'",
Anand Doshi1678f6d2013-02-21 16:55:14 +0530117 "ifnull(warehouse, '')!=''", "ifnull(qty, 0) > ifnull(ordered_qty, 0)"],
Nabin Hait30f53462012-12-28 15:39:55 +0530118 "links": {
119 "item_code": ["Item", "name"],
120 "warehouse": ["Warehouse", "name"]
121 },
122 },
123 "Purchase Order 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(received_qty, 0)) as qty"],
126 "from": "`tabPurchase Order Item` item, `tabPurchase Order` main",
127 "conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'",
128 "ifnull(warehouse, '')!=''", "ifnull(qty, 0) > ifnull(received_qty, 0)"],
129 "links": {
130 "item_code": ["Item", "name"],
131 "warehouse": ["Warehouse", "name"]
132 },
133 },
Nabin Hait96601592013-01-24 18:24:33 +0530134
Nabin Hait30f53462012-12-28 15:39:55 +0530135 "Sales Order Item": {
Rushabh Mehta66aa2652013-02-08 15:06:05 +0530136 "columns": ["item.name as name", "item_code", "(ifnull(qty, 0) - ifnull(delivered_qty, 0)) as qty",
Nabin Hait30f53462012-12-28 15:39:55 +0530137 "reserved_warehouse as warehouse"],
138 "from": "`tabSales Order Item` item, `tabSales Order` main",
139 "conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'",
140 "ifnull(reserved_warehouse, '')!=''", "ifnull(qty, 0) > ifnull(delivered_qty, 0)"],
141 "links": {
142 "item_code": ["Item", "name"],
143 "warehouse": ["Warehouse", "name"]
144 },
145 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530146
147 # Sales
148 "Customer": {
149 "columns": ["name", "if(customer_name=name, '', customer_name) as customer_name",
150 "customer_group as parent_customer_group", "territory as parent_territory"],
Anand Doshi73519e12012-10-11 14:04:27 +0530151 "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530152 "order_by": "name",
153 "links": {
154 "parent_customer_group": ["Customer Group", "name"],
155 "parent_territory": ["Territory", "name"],
156 }
Rushabh Mehta2ad0d422012-09-18 18:52:05 +0530157 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530158 "Customer Group": {
159 "columns": ["name", "parent_customer_group"],
Anand Doshi73519e12012-10-11 14:04:27 +0530160 "conditions": ["docstatus < 2"],
Rushabh Mehta2ad0d422012-09-18 18:52:05 +0530161 "order_by": "lft"
162 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530163 "Territory": {
164 "columns": ["name", "parent_territory"],
Anand Doshi73519e12012-10-11 14:04:27 +0530165 "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530166 "order_by": "lft"
167 },
168 "Sales Invoice": {
169 "columns": ["name", "customer", "posting_date", "company"],
170 "conditions": ["docstatus=1"],
171 "order_by": "posting_date",
172 "links": {
173 "customer": ["Customer", "name"],
174 "company":["Company", "name"]
175 }
176 },
177 "Sales Invoice Item": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530178 "columns": ["name", "parent", "item_code", "qty", "amount"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530179 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
180 "order_by": "parent",
181 "links": {
182 "parent": ["Sales Invoice", "name"],
183 "item_code": ["Item", "name"]
184 }
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530185 },
Nabin Hait96601592013-01-24 18:24:33 +0530186 "Sales Order": {
187 "columns": ["name", "customer", "transaction_date as posting_date", "company"],
188 "conditions": ["docstatus=1"],
189 "order_by": "transaction_date",
190 "links": {
191 "customer": ["Customer", "name"],
192 "company":["Company", "name"]
193 }
194 },
195 "Sales Order Item[Sales Analytics]": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530196 "columns": ["name", "parent", "item_code", "qty", "amount"],
Nabin Hait96601592013-01-24 18:24:33 +0530197 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
198 "order_by": "parent",
199 "links": {
200 "parent": ["Sales Order", "name"],
201 "item_code": ["Item", "name"]
202 }
203 },
204 "Delivery Note": {
205 "columns": ["name", "customer", "posting_date", "company"],
206 "conditions": ["docstatus=1"],
207 "order_by": "posting_date",
208 "links": {
209 "customer": ["Customer", "name"],
210 "company":["Company", "name"]
211 }
212 },
213 "Delivery Note Item[Sales Analytics]": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530214 "columns": ["name", "parent", "item_code", "qty", "amount"],
Nabin Hait96601592013-01-24 18:24:33 +0530215 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
216 "order_by": "parent",
217 "links": {
218 "parent": ["Delivery Note", "name"],
219 "item_code": ["Item", "name"]
220 }
221 },
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530222 "Supplier": {
223 "columns": ["name", "if(supplier_name=name, '', supplier_name) as supplier_name",
224 "supplier_type as parent_supplier_type"],
Anand Doshi73519e12012-10-11 14:04:27 +0530225 "conditions": ["docstatus < 2"],
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530226 "order_by": "name",
227 "links": {
228 "parent_supplier_type": ["Supplier Type", "name"],
229 }
230 },
231 "Supplier Type": {
232 "columns": ["name"],
Anand Doshi73519e12012-10-11 14:04:27 +0530233 "conditions": ["docstatus < 2"],
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530234 "order_by": "name"
235 },
236 "Purchase Invoice": {
237 "columns": ["name", "supplier", "posting_date", "company"],
238 "conditions": ["docstatus=1"],
239 "order_by": "posting_date",
240 "links": {
241 "supplier": ["Supplier", "name"],
242 "company":["Company", "name"]
243 }
244 },
245 "Purchase Invoice Item": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530246 "columns": ["name", "parent", "item_code", "qty", "amount"],
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530247 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
248 "order_by": "parent",
249 "links": {
250 "parent": ["Purchase Invoice", "name"],
251 "item_code": ["Item", "name"]
252 }
Rushabh Mehta607a2212013-01-04 16:42:33 +0530253 },
Nabin Haitd1301c72013-01-24 18:38:30 +0530254 "Purchase Order": {
255 "columns": ["name", "supplier", "transaction_date as posting_date", "company"],
256 "conditions": ["docstatus=1"],
257 "order_by": "posting_date",
258 "links": {
259 "supplier": ["Supplier", "name"],
260 "company":["Company", "name"]
261 }
262 },
263 "Purchase Order Item[Purchase Analytics]": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530264 "columns": ["name", "parent", "item_code", "qty", "amount"],
Nabin Haitd1301c72013-01-24 18:38:30 +0530265 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
266 "order_by": "parent",
267 "links": {
268 "parent": ["Purchase Order", "name"],
269 "item_code": ["Item", "name"]
270 }
271 },
272 "Purchase Receipt": {
273 "columns": ["name", "supplier", "posting_date", "company"],
274 "conditions": ["docstatus=1"],
275 "order_by": "posting_date",
276 "links": {
277 "supplier": ["Supplier", "name"],
278 "company":["Company", "name"]
279 }
280 },
281 "Purchase Receipt Item[Purchase Analytics]": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530282 "columns": ["name", "parent", "item_code", "qty", "amount"],
Nabin Haitd1301c72013-01-24 18:38:30 +0530283 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
284 "order_by": "parent",
285 "links": {
286 "parent": ["Purchase Receipt", "name"],
287 "item_code": ["Item", "name"]
288 }
289 },
Rushabh Mehta607a2212013-01-04 16:42:33 +0530290 # Support
291 "Support Ticket": {
Rushabh Mehtabe9ef4a2013-01-14 15:48:00 +0530292 "columns": ["name","status","creation","resolution_date","first_responded_on"],
Rushabh Mehta607a2212013-01-04 16:42:33 +0530293 "conditions": ["docstatus < 2"],
294 "order_by": "creation"
Rushabh Mehta95e4e142012-09-13 19:40:56 +0530295 }
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530296
Rushabh Mehta95e4e142012-09-13 19:40:56 +0530297}