blob: 228a8ae2a19129a4a442e1b45a82443a02bfe9ab [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": {
50 "columns": ["account", "posting_date", "cost_center", "debit", "credit", "is_opening",
Rushabh Mehtacfb54662012-09-14 18:12:17 +053051 "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",
Rushabh Mehta09d84b62012-09-21 19:46:24 +053064 "item_group as parent_item_group", "stock_uom", "brand", "valuation_method"],
Nabin Hait1c08aee2012-12-31 13:30:18 +053065 # "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +053066 "order_by": "name",
67 "links": {
68 "parent_item_group": ["Item Group", "name"],
Nabin Haitce159ab2012-12-25 18:04:10 +053069 "brand": ["Brand", "name"]
Rushabh Mehtaf200c522012-09-21 15:19:40 +053070 }
Rushabh Mehta95e4e142012-09-13 19:40:56 +053071 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +053072 "Item Group": {
73 "columns": ["name", "parent_item_group"],
Anand Doshi73519e12012-10-11 14:04:27 +053074 "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +053075 "order_by": "lft"
76 },
Nabin Haitce159ab2012-12-25 18:04:10 +053077 "Brand": {
78 "columns": ["name"],
79 "conditions": ["docstatus < 2"],
80 "order_by": "name"
81 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +053082 "Warehouse": {
83 "columns": ["name"],
Anand Doshi73519e12012-10-11 14:04:27 +053084 "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +053085 "order_by": "name"
Rushabh Mehta2ad0d422012-09-18 18:52:05 +053086 },
87 "Stock Ledger Entry": {
88 "columns": ["posting_date", "posting_time", "item_code", "warehouse", "actual_qty as qty",
Rushabh Mehta6ca80542012-09-20 19:03:14 +053089 "voucher_type", "voucher_no", "ifnull(incoming_rate,0) as incoming_rate"],
Rushabh Mehta823c0212012-09-19 12:01:01 +053090 "conditions": ["ifnull(is_cancelled, 'No')='No'"],
Rushabh Mehta2ad0d422012-09-18 18:52:05 +053091 "order_by": "posting_date, posting_time, name",
92 "links": {
93 "item_code": ["Item", "name"],
94 "warehouse": ["Warehouse", "name"]
Rushabh Mehta823c0212012-09-19 12:01:01 +053095 },
Nabin Hait30f53462012-12-28 15:39:55 +053096 "force_index": "posting_sort_index"
Rushabh Mehta2ad0d422012-09-18 18:52:05 +053097 },
Nabin Haitce159ab2012-12-25 18:04:10 +053098 "Stock Entry": {
99 "columns": ["name", "purpose"],
100 "conditions": ["docstatus=1"],
101 "order_by": "posting_date, posting_time, name",
102 },
Nabin Hait30f53462012-12-28 15:39:55 +0530103 "Production Order": {
104 "columns": ["production_item as item_code",
105 "(ifnull(qty, 0) - ifnull(produced_qty, 0)) as qty",
106 "fg_warehouse as warehouse"],
107 "conditions": ["docstatus=1", "status != 'Stopped'", "ifnull(fg_warehouse, '')!=''",
108 "ifnull(qty, 0) > ifnull(produced_qty, 0)"],
109 "links": {
110 "item_code": ["Item", "name"],
111 "warehouse": ["Warehouse", "name"]
112 },
113 },
114 "Purchase Request Item": {
115 "columns": ["item_code", "warehouse",
116 "(ifnull(qty, 0) - ifnull(ordered_qty, 0)) as qty"],
117 "from": "`tabPurchase Request Item` item, `tabPurchase Request` main",
118 "conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'",
119 "ifnull(warehouse, '')!=''", "ifnull(qty, 0) > ifnull(ordered_qty, 0)"],
120 "links": {
121 "item_code": ["Item", "name"],
122 "warehouse": ["Warehouse", "name"]
123 },
124 },
125 "Purchase Order Item": {
126 "columns": ["item_code", "warehouse",
127 "(ifnull(qty, 0) - ifnull(received_qty, 0)) as qty"],
128 "from": "`tabPurchase Order Item` item, `tabPurchase Order` main",
129 "conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'",
130 "ifnull(warehouse, '')!=''", "ifnull(qty, 0) > ifnull(received_qty, 0)"],
131 "links": {
132 "item_code": ["Item", "name"],
133 "warehouse": ["Warehouse", "name"]
134 },
135 },
136 "Sales Order Item": {
137 "columns": ["item_code", "(ifnull(qty, 0) - ifnull(delivered_qty, 0)) as qty",
138 "reserved_warehouse as warehouse"],
139 "from": "`tabSales Order Item` item, `tabSales Order` main",
140 "conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'",
141 "ifnull(reserved_warehouse, '')!=''", "ifnull(qty, 0) > ifnull(delivered_qty, 0)"],
142 "links": {
143 "item_code": ["Item", "name"],
144 "warehouse": ["Warehouse", "name"]
145 },
146 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530147
148 # Sales
149 "Customer": {
150 "columns": ["name", "if(customer_name=name, '', customer_name) as customer_name",
151 "customer_group as parent_customer_group", "territory as parent_territory"],
Anand Doshi73519e12012-10-11 14:04:27 +0530152 "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530153 "order_by": "name",
154 "links": {
155 "parent_customer_group": ["Customer Group", "name"],
156 "parent_territory": ["Territory", "name"],
157 }
Rushabh Mehta2ad0d422012-09-18 18:52:05 +0530158 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530159 "Customer Group": {
160 "columns": ["name", "parent_customer_group"],
Anand Doshi73519e12012-10-11 14:04:27 +0530161 "conditions": ["docstatus < 2"],
Rushabh Mehta2ad0d422012-09-18 18:52:05 +0530162 "order_by": "lft"
163 },
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530164 "Territory": {
165 "columns": ["name", "parent_territory"],
Anand Doshi73519e12012-10-11 14:04:27 +0530166 "conditions": ["docstatus < 2"],
Rushabh Mehtaf200c522012-09-21 15:19:40 +0530167 "order_by": "lft"
168 },
169 "Sales Invoice": {
170 "columns": ["name", "customer", "posting_date", "company"],
171 "conditions": ["docstatus=1"],
172 "order_by": "posting_date",
173 "links": {
174 "customer": ["Customer", "name"],
175 "company":["Company", "name"]
176 }
177 },
178 "Sales Invoice Item": {
179 "columns": ["parent", "item_code", "qty", "amount"],
180 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
181 "order_by": "parent",
182 "links": {
183 "parent": ["Sales Invoice", "name"],
184 "item_code": ["Item", "name"]
185 }
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530186 },
187 "Supplier": {
188 "columns": ["name", "if(supplier_name=name, '', supplier_name) as supplier_name",
189 "supplier_type as parent_supplier_type"],
Anand Doshi73519e12012-10-11 14:04:27 +0530190 "conditions": ["docstatus < 2"],
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530191 "order_by": "name",
192 "links": {
193 "parent_supplier_type": ["Supplier Type", "name"],
194 }
195 },
196 "Supplier Type": {
197 "columns": ["name"],
Anand Doshi73519e12012-10-11 14:04:27 +0530198 "conditions": ["docstatus < 2"],
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530199 "order_by": "name"
200 },
201 "Purchase Invoice": {
202 "columns": ["name", "supplier", "posting_date", "company"],
203 "conditions": ["docstatus=1"],
204 "order_by": "posting_date",
205 "links": {
206 "supplier": ["Supplier", "name"],
207 "company":["Company", "name"]
208 }
209 },
210 "Purchase Invoice Item": {
211 "columns": ["parent", "item_code", "qty", "amount"],
212 "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
213 "order_by": "parent",
214 "links": {
215 "parent": ["Purchase Invoice", "name"],
216 "item_code": ["Item", "name"]
217 }
Rushabh Mehta607a2212013-01-04 16:42:33 +0530218 },
219
220 # Support
221 "Support Ticket": {
Rushabh Mehtabe9ef4a2013-01-14 15:48:00 +0530222 "columns": ["name","status","creation","resolution_date","first_responded_on"],
Rushabh Mehta607a2212013-01-04 16:42:33 +0530223 "conditions": ["docstatus < 2"],
224 "order_by": "creation"
Rushabh Mehta95e4e142012-09-13 19:40:56 +0530225 }
Rushabh Mehta09d84b62012-09-21 19:46:24 +0530226
Rushabh Mehta95e4e142012-09-13 19:40:56 +0530227}