Rushabh Mehta | 95e4e14 | 2012-09-13 19:40:56 +0530 | [diff] [blame] | 1 | # 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 Hait | 9a90c89 | 2012-09-18 13:37:27 +0530 | [diff] [blame] | 17 | from __future__ import unicode_literals |
Rushabh Mehta | 823c021 | 2012-09-19 12:01:01 +0530 | [diff] [blame] | 18 | |
| 19 | # mappings for table dumps |
| 20 | # "remember to add indexes!" |
| 21 | |
Rushabh Mehta | 95e4e14 | 2012-09-13 19:40:56 +0530 | [diff] [blame] | 22 | data_map = { |
Rushabh Mehta | f200c52 | 2012-09-21 15:19:40 +0530 | [diff] [blame] | 23 | "Company": { |
| 24 | "columns": ["name"], |
| 25 | "conditions": ["docstatus < 2"] |
| 26 | }, |
| 27 | "Fiscal Year": { |
| 28 | "columns": ["name", "year_start_date", |
Anand Doshi | 73519e1 | 2012-10-11 14:04:27 +0530 | [diff] [blame] | 29 | "adddate(adddate(year_start_date, interval 1 year), interval -1 day) as year_end_date"], |
| 30 | "conditions": ["docstatus < 2"], |
Rushabh Mehta | f200c52 | 2012-09-21 15:19:40 +0530 | [diff] [blame] | 31 | }, |
| 32 | |
| 33 | # Accounts |
Rushabh Mehta | 95e4e14 | 2012-09-13 19:40:56 +0530 | [diff] [blame] | 34 | "Account": { |
Anand Doshi | bc243de | 2012-09-24 18:03:35 +0530 | [diff] [blame] | 35 | "columns": ["name", "parent_account", "lft", "rgt", "debit_or_credit", |
Rushabh Mehta | c68fc3f | 2012-11-13 13:28:26 +0530 | [diff] [blame] | 36 | "is_pl_account", "company", "group_or_ledger"], |
Anand Doshi | 73519e1 | 2012-10-11 14:04:27 +0530 | [diff] [blame] | 37 | "conditions": ["docstatus < 2"], |
Rushabh Mehta | c68fc3f | 2012-11-13 13:28:26 +0530 | [diff] [blame] | 38 | "order_by": "lft", |
| 39 | "links": { |
| 40 | "company": ["Company", "name"], |
| 41 | } |
| 42 | |
Rushabh Mehta | 95e4e14 | 2012-09-13 19:40:56 +0530 | [diff] [blame] | 43 | }, |
Rushabh Mehta | 4156523 | 2012-09-17 19:10:36 +0530 | [diff] [blame] | 44 | "Cost Center": { |
Rushabh Mehta | 09d84b6 | 2012-09-21 19:46:24 +0530 | [diff] [blame] | 45 | "columns": ["name", "lft", "rgt"], |
Anand Doshi | 73519e1 | 2012-10-11 14:04:27 +0530 | [diff] [blame] | 46 | "conditions": ["docstatus < 2"], |
Rushabh Mehta | 4156523 | 2012-09-17 19:10:36 +0530 | [diff] [blame] | 47 | "order_by": "lft" |
| 48 | }, |
Rushabh Mehta | 95e4e14 | 2012-09-13 19:40:56 +0530 | [diff] [blame] | 49 | "GL Entry": { |
| 50 | "columns": ["account", "posting_date", "cost_center", "debit", "credit", "is_opening", |
Rushabh Mehta | cfb5466 | 2012-09-14 18:12:17 +0530 | [diff] [blame] | 51 | "company", "voucher_type", "voucher_no", "remarks"], |
Rushabh Mehta | 95e4e14 | 2012-09-13 19:40:56 +0530 | [diff] [blame] | 52 | "conditions": ["ifnull(is_cancelled, 'No')='No'"], |
Rushabh Mehta | 823c021 | 2012-09-19 12:01:01 +0530 | [diff] [blame] | 53 | "order_by": "posting_date, account", |
| 54 | "links": { |
| 55 | "account": ["Account", "name"], |
Rushabh Mehta | 09d84b6 | 2012-09-21 19:46:24 +0530 | [diff] [blame] | 56 | "company": ["Company", "name"], |
| 57 | "cost_center": ["Cost Center", "name"] |
Rushabh Mehta | 823c021 | 2012-09-19 12:01:01 +0530 | [diff] [blame] | 58 | } |
Rushabh Mehta | 95e4e14 | 2012-09-13 19:40:56 +0530 | [diff] [blame] | 59 | }, |
Rushabh Mehta | f200c52 | 2012-09-21 15:19:40 +0530 | [diff] [blame] | 60 | |
| 61 | # Stock |
| 62 | "Item": { |
Nabin Hait | 6072a68 | 2012-12-31 17:16:23 +0530 | [diff] [blame] | 63 | "columns": ["name", "if(item_name=name, '', item_name) as item_name", "description", |
Nabin Hait | 44ffd43 | 2013-01-16 11:16:21 +0530 | [diff] [blame] | 64 | "item_group as parent_item_group", "stock_uom", "brand", "valuation_method", |
| 65 | "re_order_level", "re_order_qty"], |
Nabin Hait | 1c08aee | 2012-12-31 13:30:18 +0530 | [diff] [blame] | 66 | # "conditions": ["docstatus < 2"], |
Rushabh Mehta | f200c52 | 2012-09-21 15:19:40 +0530 | [diff] [blame] | 67 | "order_by": "name", |
| 68 | "links": { |
| 69 | "parent_item_group": ["Item Group", "name"], |
Nabin Hait | ce159ab | 2012-12-25 18:04:10 +0530 | [diff] [blame] | 70 | "brand": ["Brand", "name"] |
Rushabh Mehta | f200c52 | 2012-09-21 15:19:40 +0530 | [diff] [blame] | 71 | } |
Rushabh Mehta | 95e4e14 | 2012-09-13 19:40:56 +0530 | [diff] [blame] | 72 | }, |
Rushabh Mehta | f200c52 | 2012-09-21 15:19:40 +0530 | [diff] [blame] | 73 | "Item Group": { |
| 74 | "columns": ["name", "parent_item_group"], |
Anand Doshi | 73519e1 | 2012-10-11 14:04:27 +0530 | [diff] [blame] | 75 | "conditions": ["docstatus < 2"], |
Rushabh Mehta | f200c52 | 2012-09-21 15:19:40 +0530 | [diff] [blame] | 76 | "order_by": "lft" |
| 77 | }, |
Nabin Hait | ce159ab | 2012-12-25 18:04:10 +0530 | [diff] [blame] | 78 | "Brand": { |
| 79 | "columns": ["name"], |
| 80 | "conditions": ["docstatus < 2"], |
| 81 | "order_by": "name" |
| 82 | }, |
Rushabh Mehta | f200c52 | 2012-09-21 15:19:40 +0530 | [diff] [blame] | 83 | "Warehouse": { |
| 84 | "columns": ["name"], |
Anand Doshi | 73519e1 | 2012-10-11 14:04:27 +0530 | [diff] [blame] | 85 | "conditions": ["docstatus < 2"], |
Rushabh Mehta | f200c52 | 2012-09-21 15:19:40 +0530 | [diff] [blame] | 86 | "order_by": "name" |
Rushabh Mehta | 2ad0d42 | 2012-09-18 18:52:05 +0530 | [diff] [blame] | 87 | }, |
| 88 | "Stock Ledger Entry": { |
| 89 | "columns": ["posting_date", "posting_time", "item_code", "warehouse", "actual_qty as qty", |
Rushabh Mehta | 6ca8054 | 2012-09-20 19:03:14 +0530 | [diff] [blame] | 90 | "voucher_type", "voucher_no", "ifnull(incoming_rate,0) as incoming_rate"], |
Rushabh Mehta | 823c021 | 2012-09-19 12:01:01 +0530 | [diff] [blame] | 91 | "conditions": ["ifnull(is_cancelled, 'No')='No'"], |
Rushabh Mehta | 2ad0d42 | 2012-09-18 18:52:05 +0530 | [diff] [blame] | 92 | "order_by": "posting_date, posting_time, name", |
| 93 | "links": { |
| 94 | "item_code": ["Item", "name"], |
| 95 | "warehouse": ["Warehouse", "name"] |
Rushabh Mehta | 823c021 | 2012-09-19 12:01:01 +0530 | [diff] [blame] | 96 | }, |
Nabin Hait | 30f5346 | 2012-12-28 15:39:55 +0530 | [diff] [blame] | 97 | "force_index": "posting_sort_index" |
Rushabh Mehta | 2ad0d42 | 2012-09-18 18:52:05 +0530 | [diff] [blame] | 98 | }, |
Nabin Hait | ce159ab | 2012-12-25 18:04:10 +0530 | [diff] [blame] | 99 | "Stock Entry": { |
| 100 | "columns": ["name", "purpose"], |
| 101 | "conditions": ["docstatus=1"], |
| 102 | "order_by": "posting_date, posting_time, name", |
| 103 | }, |
Nabin Hait | 30f5346 | 2012-12-28 15:39:55 +0530 | [diff] [blame] | 104 | "Production Order": { |
| 105 | "columns": ["production_item as item_code", |
| 106 | "(ifnull(qty, 0) - ifnull(produced_qty, 0)) as qty", |
| 107 | "fg_warehouse as warehouse"], |
| 108 | "conditions": ["docstatus=1", "status != 'Stopped'", "ifnull(fg_warehouse, '')!=''", |
| 109 | "ifnull(qty, 0) > ifnull(produced_qty, 0)"], |
| 110 | "links": { |
| 111 | "item_code": ["Item", "name"], |
| 112 | "warehouse": ["Warehouse", "name"] |
| 113 | }, |
| 114 | }, |
| 115 | "Purchase Request Item": { |
| 116 | "columns": ["item_code", "warehouse", |
| 117 | "(ifnull(qty, 0) - ifnull(ordered_qty, 0)) as qty"], |
| 118 | "from": "`tabPurchase Request Item` item, `tabPurchase Request` main", |
| 119 | "conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'", |
| 120 | "ifnull(warehouse, '')!=''", "ifnull(qty, 0) > ifnull(ordered_qty, 0)"], |
| 121 | "links": { |
| 122 | "item_code": ["Item", "name"], |
| 123 | "warehouse": ["Warehouse", "name"] |
| 124 | }, |
| 125 | }, |
| 126 | "Purchase Order Item": { |
| 127 | "columns": ["item_code", "warehouse", |
| 128 | "(ifnull(qty, 0) - ifnull(received_qty, 0)) as qty"], |
| 129 | "from": "`tabPurchase Order Item` item, `tabPurchase Order` main", |
| 130 | "conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'", |
| 131 | "ifnull(warehouse, '')!=''", "ifnull(qty, 0) > ifnull(received_qty, 0)"], |
| 132 | "links": { |
| 133 | "item_code": ["Item", "name"], |
| 134 | "warehouse": ["Warehouse", "name"] |
| 135 | }, |
| 136 | }, |
Nabin Hait | 9660159 | 2013-01-24 18:24:33 +0530 | [diff] [blame] | 137 | |
Nabin Hait | 30f5346 | 2012-12-28 15:39:55 +0530 | [diff] [blame] | 138 | "Sales Order Item": { |
| 139 | "columns": ["item_code", "(ifnull(qty, 0) - ifnull(delivered_qty, 0)) as qty", |
| 140 | "reserved_warehouse as warehouse"], |
| 141 | "from": "`tabSales Order Item` item, `tabSales Order` main", |
| 142 | "conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'", |
| 143 | "ifnull(reserved_warehouse, '')!=''", "ifnull(qty, 0) > ifnull(delivered_qty, 0)"], |
| 144 | "links": { |
| 145 | "item_code": ["Item", "name"], |
| 146 | "warehouse": ["Warehouse", "name"] |
| 147 | }, |
| 148 | }, |
Rushabh Mehta | f200c52 | 2012-09-21 15:19:40 +0530 | [diff] [blame] | 149 | |
| 150 | # Sales |
| 151 | "Customer": { |
| 152 | "columns": ["name", "if(customer_name=name, '', customer_name) as customer_name", |
| 153 | "customer_group as parent_customer_group", "territory as parent_territory"], |
Anand Doshi | 73519e1 | 2012-10-11 14:04:27 +0530 | [diff] [blame] | 154 | "conditions": ["docstatus < 2"], |
Rushabh Mehta | f200c52 | 2012-09-21 15:19:40 +0530 | [diff] [blame] | 155 | "order_by": "name", |
| 156 | "links": { |
| 157 | "parent_customer_group": ["Customer Group", "name"], |
| 158 | "parent_territory": ["Territory", "name"], |
| 159 | } |
Rushabh Mehta | 2ad0d42 | 2012-09-18 18:52:05 +0530 | [diff] [blame] | 160 | }, |
Rushabh Mehta | f200c52 | 2012-09-21 15:19:40 +0530 | [diff] [blame] | 161 | "Customer Group": { |
| 162 | "columns": ["name", "parent_customer_group"], |
Anand Doshi | 73519e1 | 2012-10-11 14:04:27 +0530 | [diff] [blame] | 163 | "conditions": ["docstatus < 2"], |
Rushabh Mehta | 2ad0d42 | 2012-09-18 18:52:05 +0530 | [diff] [blame] | 164 | "order_by": "lft" |
| 165 | }, |
Rushabh Mehta | f200c52 | 2012-09-21 15:19:40 +0530 | [diff] [blame] | 166 | "Territory": { |
| 167 | "columns": ["name", "parent_territory"], |
Anand Doshi | 73519e1 | 2012-10-11 14:04:27 +0530 | [diff] [blame] | 168 | "conditions": ["docstatus < 2"], |
Rushabh Mehta | f200c52 | 2012-09-21 15:19:40 +0530 | [diff] [blame] | 169 | "order_by": "lft" |
| 170 | }, |
| 171 | "Sales Invoice": { |
| 172 | "columns": ["name", "customer", "posting_date", "company"], |
| 173 | "conditions": ["docstatus=1"], |
| 174 | "order_by": "posting_date", |
| 175 | "links": { |
| 176 | "customer": ["Customer", "name"], |
| 177 | "company":["Company", "name"] |
| 178 | } |
| 179 | }, |
| 180 | "Sales Invoice Item": { |
| 181 | "columns": ["parent", "item_code", "qty", "amount"], |
| 182 | "conditions": ["docstatus=1", "ifnull(parent, '')!=''"], |
| 183 | "order_by": "parent", |
| 184 | "links": { |
| 185 | "parent": ["Sales Invoice", "name"], |
| 186 | "item_code": ["Item", "name"] |
| 187 | } |
Rushabh Mehta | 09d84b6 | 2012-09-21 19:46:24 +0530 | [diff] [blame] | 188 | }, |
Nabin Hait | 9660159 | 2013-01-24 18:24:33 +0530 | [diff] [blame] | 189 | "Sales Order": { |
| 190 | "columns": ["name", "customer", "transaction_date as posting_date", "company"], |
| 191 | "conditions": ["docstatus=1"], |
| 192 | "order_by": "transaction_date", |
| 193 | "links": { |
| 194 | "customer": ["Customer", "name"], |
| 195 | "company":["Company", "name"] |
| 196 | } |
| 197 | }, |
| 198 | "Sales Order Item[Sales Analytics]": { |
| 199 | "columns": ["parent", "item_code", "qty", "amount"], |
| 200 | "conditions": ["docstatus=1", "ifnull(parent, '')!=''"], |
| 201 | "order_by": "parent", |
| 202 | "links": { |
| 203 | "parent": ["Sales Order", "name"], |
| 204 | "item_code": ["Item", "name"] |
| 205 | } |
| 206 | }, |
| 207 | "Delivery Note": { |
| 208 | "columns": ["name", "customer", "posting_date", "company"], |
| 209 | "conditions": ["docstatus=1"], |
| 210 | "order_by": "posting_date", |
| 211 | "links": { |
| 212 | "customer": ["Customer", "name"], |
| 213 | "company":["Company", "name"] |
| 214 | } |
| 215 | }, |
| 216 | "Delivery Note Item[Sales Analytics]": { |
| 217 | "columns": ["parent", "item_code", "qty", "amount"], |
| 218 | "conditions": ["docstatus=1", "ifnull(parent, '')!=''"], |
| 219 | "order_by": "parent", |
| 220 | "links": { |
| 221 | "parent": ["Delivery Note", "name"], |
| 222 | "item_code": ["Item", "name"] |
| 223 | } |
| 224 | }, |
Rushabh Mehta | 09d84b6 | 2012-09-21 19:46:24 +0530 | [diff] [blame] | 225 | "Supplier": { |
| 226 | "columns": ["name", "if(supplier_name=name, '', supplier_name) as supplier_name", |
| 227 | "supplier_type as parent_supplier_type"], |
Anand Doshi | 73519e1 | 2012-10-11 14:04:27 +0530 | [diff] [blame] | 228 | "conditions": ["docstatus < 2"], |
Rushabh Mehta | 09d84b6 | 2012-09-21 19:46:24 +0530 | [diff] [blame] | 229 | "order_by": "name", |
| 230 | "links": { |
| 231 | "parent_supplier_type": ["Supplier Type", "name"], |
| 232 | } |
| 233 | }, |
| 234 | "Supplier Type": { |
| 235 | "columns": ["name"], |
Anand Doshi | 73519e1 | 2012-10-11 14:04:27 +0530 | [diff] [blame] | 236 | "conditions": ["docstatus < 2"], |
Rushabh Mehta | 09d84b6 | 2012-09-21 19:46:24 +0530 | [diff] [blame] | 237 | "order_by": "name" |
| 238 | }, |
| 239 | "Purchase Invoice": { |
| 240 | "columns": ["name", "supplier", "posting_date", "company"], |
| 241 | "conditions": ["docstatus=1"], |
| 242 | "order_by": "posting_date", |
| 243 | "links": { |
| 244 | "supplier": ["Supplier", "name"], |
| 245 | "company":["Company", "name"] |
| 246 | } |
| 247 | }, |
| 248 | "Purchase Invoice Item": { |
| 249 | "columns": ["parent", "item_code", "qty", "amount"], |
| 250 | "conditions": ["docstatus=1", "ifnull(parent, '')!=''"], |
| 251 | "order_by": "parent", |
| 252 | "links": { |
| 253 | "parent": ["Purchase Invoice", "name"], |
| 254 | "item_code": ["Item", "name"] |
| 255 | } |
Rushabh Mehta | 607a221 | 2013-01-04 16:42:33 +0530 | [diff] [blame] | 256 | }, |
Nabin Hait | d1301c7 | 2013-01-24 18:38:30 +0530 | [diff] [blame] | 257 | "Purchase Order": { |
| 258 | "columns": ["name", "supplier", "transaction_date as posting_date", "company"], |
| 259 | "conditions": ["docstatus=1"], |
| 260 | "order_by": "posting_date", |
| 261 | "links": { |
| 262 | "supplier": ["Supplier", "name"], |
| 263 | "company":["Company", "name"] |
| 264 | } |
| 265 | }, |
| 266 | "Purchase Order Item[Purchase Analytics]": { |
| 267 | "columns": ["parent", "item_code", "qty", "amount"], |
| 268 | "conditions": ["docstatus=1", "ifnull(parent, '')!=''"], |
| 269 | "order_by": "parent", |
| 270 | "links": { |
| 271 | "parent": ["Purchase Order", "name"], |
| 272 | "item_code": ["Item", "name"] |
| 273 | } |
| 274 | }, |
| 275 | "Purchase Receipt": { |
| 276 | "columns": ["name", "supplier", "posting_date", "company"], |
| 277 | "conditions": ["docstatus=1"], |
| 278 | "order_by": "posting_date", |
| 279 | "links": { |
| 280 | "supplier": ["Supplier", "name"], |
| 281 | "company":["Company", "name"] |
| 282 | } |
| 283 | }, |
| 284 | "Purchase Receipt Item[Purchase Analytics]": { |
| 285 | "columns": ["parent", "item_code", "qty", "amount"], |
| 286 | "conditions": ["docstatus=1", "ifnull(parent, '')!=''"], |
| 287 | "order_by": "parent", |
| 288 | "links": { |
| 289 | "parent": ["Purchase Receipt", "name"], |
| 290 | "item_code": ["Item", "name"] |
| 291 | } |
| 292 | }, |
Rushabh Mehta | 607a221 | 2013-01-04 16:42:33 +0530 | [diff] [blame] | 293 | # Support |
| 294 | "Support Ticket": { |
Rushabh Mehta | be9ef4a | 2013-01-14 15:48:00 +0530 | [diff] [blame] | 295 | "columns": ["name","status","creation","resolution_date","first_responded_on"], |
Rushabh Mehta | 607a221 | 2013-01-04 16:42:33 +0530 | [diff] [blame] | 296 | "conditions": ["docstatus < 2"], |
| 297 | "order_by": "creation" |
Rushabh Mehta | 95e4e14 | 2012-09-13 19:40:56 +0530 | [diff] [blame] | 298 | } |
Rushabh Mehta | 09d84b6 | 2012-09-21 19:46:24 +0530 | [diff] [blame] | 299 | |
Rushabh Mehta | 95e4e14 | 2012-09-13 19:40:56 +0530 | [diff] [blame] | 300 | } |