blob: 54453f68bbd4e419ec9ab1d41c8ebd1b49f34f43 [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 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 Haitce159ab2012-12-25 18:04:10 +053091 "Stock Entry": {
92 "columns": ["name", "purpose"],
93 "conditions": ["docstatus=1"],
94 "order_by": "posting_date, posting_time, name",
95 },
Nabin Hait30f53462012-12-28 15:39:55 +053096 "Production Order": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +053097 "columns": ["name", "production_item as item_code",
Nabin Hait30f53462012-12-28 15:39:55 +053098 "(ifnull(qty, 0) - ifnull(produced_qty, 0)) as qty",
99 "fg_warehouse as warehouse"],
100 "conditions": ["docstatus=1", "status != 'Stopped'", "ifnull(fg_warehouse, '')!=''",
101 "ifnull(qty, 0) > ifnull(produced_qty, 0)"],
102 "links": {
103 "item_code": ["Item", "name"],
104 "warehouse": ["Warehouse", "name"]
105 },
106 },
Anand Doshi236cc172013-02-18 13:49:15 +0530107 "Material Request Item": {
Rushabh Mehta66aa2652013-02-08 15:06:05 +0530108 "columns": ["item.name as name", "item_code", "warehouse",
Nabin Hait30f53462012-12-28 15:39:55 +0530109 "(ifnull(qty, 0) - ifnull(ordered_qty, 0)) as qty"],
Anand Doshi236cc172013-02-18 13:49:15 +0530110 "from": "`tabMaterial Request Item` item, `tabMaterial Request` main",
Anand Doshicf055802013-02-20 18:44:10 +0530111 "conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'",
Anand Doshi1678f6d2013-02-21 16:55:14 +0530112 "ifnull(warehouse, '')!=''", "ifnull(qty, 0) > ifnull(ordered_qty, 0)"],
Nabin Hait30f53462012-12-28 15:39:55 +0530113 "links": {
114 "item_code": ["Item", "name"],
115 "warehouse": ["Warehouse", "name"]
116 },
117 },
118 "Purchase Order Item": {
Rushabh Mehta66aa2652013-02-08 15:06:05 +0530119 "columns": ["item.name as name", "item_code", "warehouse",
Nabin Hait30f53462012-12-28 15:39:55 +0530120 "(ifnull(qty, 0) - ifnull(received_qty, 0)) as qty"],
121 "from": "`tabPurchase Order Item` item, `tabPurchase Order` main",
122 "conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'",
123 "ifnull(warehouse, '')!=''", "ifnull(qty, 0) > ifnull(received_qty, 0)"],
124 "links": {
125 "item_code": ["Item", "name"],
126 "warehouse": ["Warehouse", "name"]
127 },
128 },
Nabin Hait96601592013-01-24 18:24:33 +0530129
Nabin Hait30f53462012-12-28 15:39:55 +0530130 "Sales Order Item": {
Rushabh Mehta66aa2652013-02-08 15:06:05 +0530131 "columns": ["item.name as name", "item_code", "(ifnull(qty, 0) - ifnull(delivered_qty, 0)) as qty",
Nabin Hait30f53462012-12-28 15:39:55 +0530132 "reserved_warehouse as warehouse"],
133 "from": "`tabSales Order Item` item, `tabSales Order` main",
134 "conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'",
135 "ifnull(reserved_warehouse, '')!=''", "ifnull(qty, 0) > ifnull(delivered_qty, 0)"],
136 "links": {
137 "item_code": ["Item", "name"],
138 "warehouse": ["Warehouse", "name"]
139 },
140 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530141
142 # Sales
143 "Customer": {
144 "columns": ["name", "if(customer_name=name, '', customer_name) as customer_name",
145 "customer_group as parent_customer_group", "territory as parent_territory"],
Anand Doshi73519e12012-10-11 14:04:27 +0530146 "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530147 "order_by": "name",
148 "links": {
149 "parent_customer_group": ["Customer Group", "name"],
150 "parent_territory": ["Territory", "name"],
151 }
Rushabh Mehta2ad0d422012-09-18 18:52:05 +0530152 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530153 "Customer Group": {
154 "columns": ["name", "parent_customer_group"],
Anand Doshi73519e12012-10-11 14:04:27 +0530155 "conditions": ["docstatus < 2"],
Rushabh Mehta2ad0d422012-09-18 18:52:05 +0530156 "order_by": "lft"
157 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530158 "Territory": {
159 "columns": ["name", "parent_territory"],
Anand Doshi73519e12012-10-11 14:04:27 +0530160 "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530161 "order_by": "lft"
162 },
163 "Sales Invoice": {
164 "columns": ["name", "customer", "posting_date", "company"],
165 "conditions": ["docstatus=1"],
166 "order_by": "posting_date",
167 "links": {
168 "customer": ["Customer", "name"],
169 "company":["Company", "name"]
170 }
171 },
172 "Sales Invoice Item": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530173 "columns": ["name", "parent", "item_code", "qty", "amount"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530174 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
175 "order_by": "parent",
176 "links": {
177 "parent": ["Sales Invoice", "name"],
178 "item_code": ["Item", "name"]
179 }
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530180 },
Nabin Hait96601592013-01-24 18:24:33 +0530181 "Sales Order": {
182 "columns": ["name", "customer", "transaction_date as posting_date", "company"],
183 "conditions": ["docstatus=1"],
184 "order_by": "transaction_date",
185 "links": {
186 "customer": ["Customer", "name"],
187 "company":["Company", "name"]
188 }
189 },
190 "Sales Order Item[Sales Analytics]": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530191 "columns": ["name", "parent", "item_code", "qty", "amount"],
Nabin Hait96601592013-01-24 18:24:33 +0530192 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
193 "order_by": "parent",
194 "links": {
195 "parent": ["Sales Order", "name"],
196 "item_code": ["Item", "name"]
197 }
198 },
199 "Delivery Note": {
200 "columns": ["name", "customer", "posting_date", "company"],
201 "conditions": ["docstatus=1"],
202 "order_by": "posting_date",
203 "links": {
204 "customer": ["Customer", "name"],
205 "company":["Company", "name"]
206 }
207 },
208 "Delivery Note Item[Sales Analytics]": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530209 "columns": ["name", "parent", "item_code", "qty", "amount"],
Nabin Hait96601592013-01-24 18:24:33 +0530210 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
211 "order_by": "parent",
212 "links": {
213 "parent": ["Delivery Note", "name"],
214 "item_code": ["Item", "name"]
215 }
216 },
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530217 "Supplier": {
218 "columns": ["name", "if(supplier_name=name, '', supplier_name) as supplier_name",
219 "supplier_type as parent_supplier_type"],
Anand Doshi73519e12012-10-11 14:04:27 +0530220 "conditions": ["docstatus < 2"],
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530221 "order_by": "name",
222 "links": {
223 "parent_supplier_type": ["Supplier Type", "name"],
224 }
225 },
226 "Supplier Type": {
227 "columns": ["name"],
Anand Doshi73519e12012-10-11 14:04:27 +0530228 "conditions": ["docstatus < 2"],
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530229 "order_by": "name"
230 },
231 "Purchase Invoice": {
232 "columns": ["name", "supplier", "posting_date", "company"],
233 "conditions": ["docstatus=1"],
234 "order_by": "posting_date",
235 "links": {
236 "supplier": ["Supplier", "name"],
237 "company":["Company", "name"]
238 }
239 },
240 "Purchase Invoice Item": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530241 "columns": ["name", "parent", "item_code", "qty", "amount"],
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530242 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
243 "order_by": "parent",
244 "links": {
245 "parent": ["Purchase Invoice", "name"],
246 "item_code": ["Item", "name"]
247 }
Rushabh Mehta607a2212013-01-04 16:42:33 +0530248 },
Nabin Haitd1301c72013-01-24 18:38:30 +0530249 "Purchase Order": {
250 "columns": ["name", "supplier", "transaction_date as posting_date", "company"],
251 "conditions": ["docstatus=1"],
252 "order_by": "posting_date",
253 "links": {
254 "supplier": ["Supplier", "name"],
255 "company":["Company", "name"]
256 }
257 },
258 "Purchase Order Item[Purchase Analytics]": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530259 "columns": ["name", "parent", "item_code", "qty", "amount"],
Nabin Haitd1301c72013-01-24 18:38:30 +0530260 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
261 "order_by": "parent",
262 "links": {
263 "parent": ["Purchase Order", "name"],
264 "item_code": ["Item", "name"]
265 }
266 },
267 "Purchase Receipt": {
268 "columns": ["name", "supplier", "posting_date", "company"],
269 "conditions": ["docstatus=1"],
270 "order_by": "posting_date",
271 "links": {
272 "supplier": ["Supplier", "name"],
273 "company":["Company", "name"]
274 }
275 },
276 "Purchase Receipt Item[Purchase Analytics]": {
Rushabh Mehta677b4b42013-02-07 22:19:47 +0530277 "columns": ["name", "parent", "item_code", "qty", "amount"],
Nabin Haitd1301c72013-01-24 18:38:30 +0530278 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
279 "order_by": "parent",
280 "links": {
281 "parent": ["Purchase Receipt", "name"],
282 "item_code": ["Item", "name"]
283 }
284 },
Rushabh Mehta607a2212013-01-04 16:42:33 +0530285 # Support
286 "Support Ticket": {
Rushabh Mehtabe9ef4a2013-01-14 15:48:00 +0530287 "columns": ["name","status","creation","resolution_date","first_responded_on"],
Rushabh Mehta607a2212013-01-04 16:42:33 +0530288 "conditions": ["docstatus < 2"],
289 "order_by": "creation"
Rushabh Mehta95e4e142012-09-13 19:40:56 +0530290 }
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530291
Rushabh Mehta95e4e142012-09-13 19:40:56 +0530292}