Merge lp:~xmo-deactivatedaccount/openobject-addons/5.0-sql-fixes into lp:openobject-addons/5.0
- 5.0-sql-fixes
- Merge into 5.0
Proposed by
Xavier (Open ERP)
Status: | Merged |
---|---|
Merged at revision: | 2746 |
Proposed branch: | lp:~xmo-deactivatedaccount/openobject-addons/5.0-sql-fixes |
Merge into: | lp:openobject-addons/5.0 |
Diff against target: |
4074 lines (+1024/-1065) (has conflicts) 70 files modified
.bzrignore (+1/-0) account/account.py (+109/-57) account/account_move_line.py (+9/-7) account/invoice.py (+15/-9) account/partner.py (+41/-32) account/project/project.py (+84/-62) account/project/report/analytic_balance.py (+17/-105) account/project/report/analytic_check.py (+0/-37) account/project/report/cost_ledger.py (+8/-4) account/project/report/inverted_analytic_balance.py (+26/-10) account/project/report/quantity_cost_ledger.py (+12/-17) account/report/account_balance.py (+1/-25) account/report/aged_trial_balance.py (+199/-193) account/report/general_journal.py (+50/-27) account/report/general_ledger.py (+28/-13) account/report/general_ledger_landscape.py (+19/-14) account/report/partner_balance.py (+30/-31) account/report/tax_report.py (+7/-7) account/wizard/wizard_account_balance_report.py (+2/-2) account/wizard/wizard_general_ledger_report.py (+2/-2) account/wizard/wizard_open_closed_fiscalyear.py (+1/-10) account/wizard/wizard_partner_balance_report.py (+2/-2) account/wizard/wizard_third_party_ledger.py (+2/-2) account_analytic_plans/report/crossovered_analytic.py (+40/-14) account_payment/account_move_line.py (+7/-5) account_payment/payment.py (+2/-93) account_voucher/account.py (+5/-3) account_voucher/voucher.py (+2/-1) auction/auction.py (+16/-5) auction/report/auction_objects.py (+0/-13) auction/report/auction_total_rml.py (+4/-1) auction/report/buyer_list.py (+10/-6) base_module_quality/speed_test/speed_test.py (+3/-1) crm/crm.py (+3/-1) crm/report/report_businessopp.py (+7/-1) crm_profiling/crm_profiling.py (+20/-18) document/document.py (+4/-2) event/event.py (+4/-4) event_project/event.py (+2/-2) hr/hr.py (+4/-2) hr/hr_department.py (+3/-2) hr_attendance/hr_attendance.py (+3/-3) hr_attendance/wizard/print_attendance_error.py (+6/-3) hr_expense/hr_expense.py (+12/-8) hr_holidays/hr.py (+1/-1) hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py (+12/-10) hr_timesheet_sheet/hr_timesheet_sheet.py (+7/-7) idea/idea.py (+14/-14) l10n_be/wizard/wizard_vat_intra.py (+16/-23) membership/membership.py (+3/-3) membership/wizard/invoice_membership.py (+2/-3) mrp/mrp.py (+1/-1) mrp/report/workcenter_load.py (+3/-4) point_of_sale/pos.py (+3/-4) product/pricelist.py (+7/-11) product/product.py (+1/-1) product_margin/product_margin.py (+39/-40) project/project.py (+5/-5) purchase/purchase.py (+3/-2) report_account/report_receivable.py (+3/-3) report_analytic_planning/report_analytic_planning.py (+8/-6) report_crm/report_crm.py (+14/-15) report_timesheet/report_timesheet.py (+2/-2) sale/sale.py (+3/-3) scrum/report/_burndown.py (+4/-7) scrum/report/task_burndown.py (+4/-4) stock/product.py (+22/-16) stock/stock.py (+20/-18) stock/wizard/inventory_merge_zero.py (+2/-2) wiki/wizard/make_index.py (+3/-4) Text conflict in account/account.py |
To merge this branch: | bzr merge lp:~xmo-deactivatedaccount/openobject-addons/5.0-sql-fixes |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Christophe Simonis (OpenERP) | Needs Fixing | ||
Olivier Dony (Odoo) | Pending | ||
Stephane Wirtel (OpenERP) | Pending | ||
Review via email:
|
Commit message
Description of the change
Fixes sql moche, potentiellement injectable.
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Christophe Simonis (OpenERP) (kangol) wrote : | # |
review:
Needs Fixing
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Xavier (Open ERP) (xmo-deactivatedaccount) wrote : | # |
Done, logging.getLogger calls were moved back to netsvc.Logger.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added file '.bzrignore' | |||
2 | --- .bzrignore 1970-01-01 00:00:00 +0000 | |||
3 | +++ .bzrignore 2010-03-17 11:50:49 +0000 | |||
4 | @@ -0,0 +1,1 @@ | |||
5 | 1 | ./.ropeproject | ||
6 | 0 | 2 | ||
7 | === modified file 'account/account.py' | |||
8 | --- account/account.py 2010-03-16 09:19:35 +0000 | |||
9 | +++ account/account.py 2010-03-17 11:50:49 +0000 | |||
10 | @@ -20,8 +20,10 @@ | |||
11 | 20 | # | 20 | # |
12 | 21 | ############################################################################## | 21 | ############################################################################## |
13 | 22 | import time | 22 | import time |
14 | 23 | |||
15 | 24 | from operator import itemgetter | ||
16 | 25 | |||
17 | 23 | import netsvc | 26 | import netsvc |
18 | 24 | |||
19 | 25 | from osv import fields, osv | 27 | from osv import fields, osv |
20 | 26 | 28 | ||
21 | 27 | from tools.misc import currency | 29 | from tools.misc import currency |
22 | @@ -32,6 +34,26 @@ | |||
23 | 32 | 34 | ||
24 | 33 | from tools import config | 35 | from tools import config |
25 | 34 | 36 | ||
26 | 37 | def check_cycle(self, cr, uid, ids): | ||
27 | 38 | """ climbs the ``self._table.parent_id`` chains for 100 levels or | ||
28 | 39 | until it can't find any more parent(s) | ||
29 | 40 | |||
30 | 41 | Returns true if it runs out of parents (no cycle), false if | ||
31 | 42 | it can recurse 100 times without ending all chains | ||
32 | 43 | """ | ||
33 | 44 | level = 100 | ||
34 | 45 | while len(ids): | ||
35 | 46 | cr.execute('SELECT DISTINCT parent_id '\ | ||
36 | 47 | 'FROM '+self._table+' '\ | ||
37 | 48 | 'WHERE id IN %s '\ | ||
38 | 49 | 'AND parent_id IS NOT NULL', | ||
39 | 50 | (tuple(ids),)) | ||
40 | 51 | ids = map(itemgetter(0), cr.fetchall()) | ||
41 | 52 | if not level: | ||
42 | 53 | return False | ||
43 | 54 | level -= 1 | ||
44 | 55 | return True | ||
45 | 56 | |||
46 | 35 | class account_payment_term(osv.osv): | 57 | class account_payment_term(osv.osv): |
47 | 36 | _name = "account.payment.term" | 58 | _name = "account.payment.term" |
48 | 37 | _description = "Payment Term" | 59 | _description = "Payment Term" |
49 | @@ -149,6 +171,7 @@ | |||
50 | 149 | _name = "account.account" | 171 | _name = "account.account" |
51 | 150 | _description = "Account" | 172 | _description = "Account" |
52 | 151 | _parent_store = True | 173 | _parent_store = True |
53 | 174 | logger = netsvc.Logger() | ||
54 | 152 | 175 | ||
55 | 153 | def search(self, cr, uid, args, offset=0, limit=None, order=None, | 176 | def search(self, cr, uid, args, offset=0, limit=None, order=None, |
56 | 154 | context=None, count=False): | 177 | context=None, count=False): |
57 | @@ -195,19 +218,33 @@ | |||
58 | 195 | ids3 = self._get_children_and_consol(cr, uid, ids3, context) | 218 | ids3 = self._get_children_and_consol(cr, uid, ids3, context) |
59 | 196 | return ids2 + ids3 | 219 | return ids2 + ids3 |
60 | 197 | 220 | ||
63 | 198 | def __compute(self, cr, uid, ids, field_names, arg, context={}, query=''): | 221 | def __compute(self, cr, uid, ids, field_names, arg=None, context=None, |
64 | 199 | #compute the balance/debit/credit accordingly to the value of field_name for the given account ids | 222 | query='', query_params=()): |
65 | 223 | """ compute the balance, debit and/or credit for the provided | ||
66 | 224 | account ids | ||
67 | 225 | |||
68 | 226 | Arguments: | ||
69 | 227 | `ids`: account ids | ||
70 | 228 | `field_names`: the fields to compute (a list of any of | ||
71 | 229 | 'balance', 'debit' and 'credit') | ||
72 | 230 | `arg`: unused fields.function stuff | ||
73 | 231 | `query`: additional query filter (as a string) | ||
74 | 232 | `query_params`: parameters for the provided query string | ||
75 | 233 | (__compute will handle their escaping) as a | ||
76 | 234 | tuple | ||
77 | 235 | """ | ||
78 | 200 | mapping = { | 236 | mapping = { |
82 | 201 | 'balance': "COALESCE(SUM(l.debit),0) - COALESCE(SUM(l.credit), 0) as balance ", | 237 | 'balance': "COALESCE(SUM(l.debit),0) " \ |
83 | 202 | 'debit': "COALESCE(SUM(l.debit), 0) as debit ", | 238 | "- COALESCE(SUM(l.credit), 0) as balance", |
84 | 203 | 'credit': "COALESCE(SUM(l.credit), 0) as credit " | 239 | 'debit': "COALESCE(SUM(l.debit), 0) as debit", |
85 | 240 | 'credit': "COALESCE(SUM(l.credit), 0) as credit" | ||
86 | 204 | } | 241 | } |
87 | 205 | #get all the necessary accounts | 242 | #get all the necessary accounts |
90 | 206 | ids2 = self._get_children_and_consol(cr, uid, ids, context) | 243 | children_and_consolidated = self._get_children_and_consol( |
91 | 207 | acc_set = ",".join(map(str, ids2)) | 244 | cr, uid, ids, context=context) |
92 | 208 | #compute for each account the balance/debit/credit from the move lines | 245 | #compute for each account the balance/debit/credit from the move lines |
93 | 209 | accounts = {} | 246 | accounts = {} |
95 | 210 | if ids2: | 247 | if children_and_consolidated: |
96 | 211 | aml_query = self.pool.get('account.move.line')._query_get(cr, uid, context=context) | 248 | aml_query = self.pool.get('account.move.line')._query_get(cr, uid, context=context) |
97 | 212 | 249 | ||
98 | 213 | wheres = [""] | 250 | wheres = [""] |
99 | @@ -215,23 +252,33 @@ | |||
100 | 215 | wheres.append(query.strip()) | 252 | wheres.append(query.strip()) |
101 | 216 | if aml_query: | 253 | if aml_query: |
102 | 217 | wheres.append(aml_query.strip()) | 254 | wheres.append(aml_query.strip()) |
113 | 218 | query = " AND ".join(wheres) | 255 | filters = " AND ".join(wheres) |
114 | 219 | 256 | self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG, | |
115 | 220 | cr.execute(("SELECT l.account_id as id, " +\ | 257 | 'Filters: %s'%filters) |
116 | 221 | ' , '.join(map(lambda x: mapping[x], field_names)) + | 258 | # IN might not work ideally in case there are too many |
117 | 222 | "FROM " \ | 259 | # children_and_consolidated, in that case join on a |
118 | 223 | "account_move_line l " \ | 260 | # values() e.g.: |
119 | 224 | "WHERE " \ | 261 | # SELECT l.account_id as id FROM account_move_line l |
120 | 225 | "l.account_id IN (%s) " \ | 262 | # INNER JOIN (VALUES (id1), (id2), (id3), ...) AS tmp (id) |
121 | 226 | + query + | 263 | # ON l.account_id = tmp.id |
122 | 227 | " GROUP BY l.account_id") % (acc_set, )) | 264 | # or make _get_children_and_consol return a query and join on that |
123 | 265 | request = ("SELECT l.account_id as id, " +\ | ||
124 | 266 | ' , '.join(map(mapping.__getitem__, field_names)) + | ||
125 | 267 | " FROM account_move_line l" \ | ||
126 | 268 | " WHERE l.account_id IN %s " \ | ||
127 | 269 | + filters + | ||
128 | 270 | " GROUP BY l.account_id") | ||
129 | 271 | params = (tuple(children_and_consolidated),) + query_params | ||
130 | 272 | cr.execute(request, params) | ||
131 | 273 | self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG, | ||
132 | 274 | 'Status: %s'%cr.statusmessage) | ||
133 | 228 | 275 | ||
134 | 229 | for res in cr.dictfetchall(): | 276 | for res in cr.dictfetchall(): |
135 | 230 | accounts[res['id']] = res | 277 | accounts[res['id']] = res |
136 | 231 | 278 | ||
137 | 232 | |||
138 | 233 | # consolidate accounts with direct children | 279 | # consolidate accounts with direct children |
140 | 234 | brs = list(self.browse(cr, uid, ids2, context=context)) | 280 | brs = list(self.browse(cr, uid, children_and_consolidated, |
141 | 281 | context=context)) | ||
142 | 235 | sums = {} | 282 | sums = {} |
143 | 236 | while brs: | 283 | while brs: |
144 | 237 | current = brs[0] | 284 | current = brs[0] |
145 | @@ -341,8 +388,10 @@ | |||
146 | 341 | if (obj_self in obj_self.child_consol_ids) or (p_id and (p_id is obj_self.id)): | 388 | if (obj_self in obj_self.child_consol_ids) or (p_id and (p_id is obj_self.id)): |
147 | 342 | return False | 389 | return False |
148 | 343 | while(ids): | 390 | while(ids): |
151 | 344 | cr.execute('select distinct child_id from account_account_consol_rel where parent_id in ('+','.join(map(str, ids))+')') | 391 | cr.execute('SELECT DISTINCT child_id '\ |
152 | 345 | child_ids = filter(None, map(lambda x: x[0], cr.fetchall())) | 392 | 'FROM account_account_consol_rel '\ |
153 | 393 | 'WHERE parent_id IN %s', (tuple(ids),)) | ||
154 | 394 | child_ids = map(itemgetter(0), cr.fetchall()) | ||
155 | 346 | c_ids = child_ids | 395 | c_ids = child_ids |
156 | 347 | if (p_id and (p_id in c_ids)) or (obj_self.id in c_ids): | 396 | if (p_id and (p_id in c_ids)) or (obj_self.id in c_ids): |
157 | 348 | return False | 397 | return False |
158 | @@ -767,7 +816,10 @@ | |||
159 | 767 | 816 | ||
160 | 768 | def _amount_compute(self, cr, uid, ids, name, args, context, where =''): | 817 | def _amount_compute(self, cr, uid, ids, name, args, context, where =''): |
161 | 769 | if not ids: return {} | 818 | if not ids: return {} |
163 | 770 | cr.execute('select move_id,sum(debit) from account_move_line where move_id in ('+','.join(map(str,ids))+') group by move_id') | 819 | cr.execute('SELECT move_id, SUM(debit) '\ |
164 | 820 | 'FROM account_move_line '\ | ||
165 | 821 | 'WHERE move_id IN %s '\ | ||
166 | 822 | 'GROUP BY move_id', (tuple(ids),)) | ||
167 | 771 | result = dict(cr.fetchall()) | 823 | result = dict(cr.fetchall()) |
168 | 772 | for id in ids: | 824 | for id in ids: |
169 | 773 | result.setdefault(id, 0.0) | 825 | result.setdefault(id, 0.0) |
170 | @@ -862,7 +914,10 @@ | |||
171 | 862 | if new_name: | 914 | if new_name: |
172 | 863 | self.write(cr, uid, [move.id], {'name':new_name}) | 915 | self.write(cr, uid, [move.id], {'name':new_name}) |
173 | 864 | 916 | ||
175 | 865 | cr.execute('update account_move set state=%s where id in ('+','.join(map(str,ids))+')', ('posted',)) | 917 | cr.execute('UPDATE account_move '\ |
176 | 918 | 'SET state=%s '\ | ||
177 | 919 | 'WHERE id IN %s', | ||
178 | 920 | ('posted', tuple(ids))) | ||
179 | 866 | else: | 921 | else: |
180 | 867 | raise osv.except_osv(_('Integrity Error !'), _('You can not validate a non-balanced entry !')) | 922 | raise osv.except_osv(_('Integrity Error !'), _('You can not validate a non-balanced entry !')) |
181 | 868 | return True | 923 | return True |
182 | @@ -875,7 +930,9 @@ | |||
183 | 875 | if not line.journal_id.update_posted: | 930 | if not line.journal_id.update_posted: |
184 | 876 | raise osv.except_osv(_('Error !'), _('You can not modify a posted entry of this journal !\nYou should set the journal to allow cancelling entries if you want to do that.')) | 931 | raise osv.except_osv(_('Error !'), _('You can not modify a posted entry of this journal !\nYou should set the journal to allow cancelling entries if you want to do that.')) |
185 | 877 | if len(ids): | 932 | if len(ids): |
187 | 878 | cr.execute('update account_move set state=%s where id in ('+','.join(map(str,ids))+')', ('draft',)) | 933 | cr.execute('UPDATE account_move '\ |
188 | 934 | 'SET state=%s '\ | ||
189 | 935 | 'WHERE id IN %s', ('draft', tuple(ids))) | ||
190 | 879 | return True | 936 | return True |
191 | 880 | 937 | ||
192 | 881 | def write(self, cr, uid, ids, vals, context={}): | 938 | def write(self, cr, uid, ids, vals, context={}): |
193 | @@ -995,7 +1052,10 @@ | |||
194 | 995 | else: | 1052 | else: |
195 | 996 | line_id2 = 0 | 1053 | line_id2 = 0 |
196 | 997 | 1054 | ||
198 | 998 | cr.execute('select sum('+mode+') from account_move_line where move_id=%s and id<>%s', (move.id, line_id2)) | 1055 | cr.execute('SELECT SUM(%s) '\ |
199 | 1056 | 'FROM account_move_line '\ | ||
200 | 1057 | 'WHERE move_id=%s AND id<>%s', | ||
201 | 1058 | (mode, move.id, line_id2)) | ||
202 | 999 | result = cr.fetchone()[0] or 0.0 | 1059 | result = cr.fetchone()[0] or 0.0 |
203 | 1000 | cr.execute('update account_move_line set '+mode2+'=%s where id=%s', (result, line_id)) | 1060 | cr.execute('update account_move_line set '+mode2+'=%s where id=%s', (result, line_id)) |
204 | 1001 | return True | 1061 | return True |
205 | @@ -1143,25 +1203,28 @@ | |||
206 | 1143 | 1203 | ||
207 | 1144 | This code is used for some tax declarations. | 1204 | This code is used for some tax declarations. |
208 | 1145 | """ | 1205 | """ |
212 | 1146 | def _sum(self, cr, uid, ids, name, args, context, where =''): | 1206 | def _sum(self, cr, uid, ids, name, args, context, |
213 | 1147 | ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) | 1207 | where ='', where_params=()): |
214 | 1148 | acc_set = ",".join(map(str, ids2)) | 1208 | parent_ids = tuple(self.search( |
215 | 1209 | cr, uid, [('parent_id', 'child_of', ids)])) | ||
216 | 1149 | if context.get('based_on', 'invoices') == 'payments': | 1210 | if context.get('based_on', 'invoices') == 'payments': |
217 | 1150 | cr.execute('SELECT line.tax_code_id, sum(line.tax_amount) \ | 1211 | cr.execute('SELECT line.tax_code_id, sum(line.tax_amount) \ |
218 | 1151 | FROM account_move_line AS line, \ | 1212 | FROM account_move_line AS line, \ |
219 | 1152 | account_move AS move \ | 1213 | account_move AS move \ |
220 | 1153 | LEFT JOIN account_invoice invoice ON \ | 1214 | LEFT JOIN account_invoice invoice ON \ |
221 | 1154 | (invoice.move_id = move.id) \ | 1215 | (invoice.move_id = move.id) \ |
223 | 1155 | WHERE line.tax_code_id in ('+acc_set+') '+where+' \ | 1216 | WHERE line.tax_code_id in %s '+where+' \ |
224 | 1156 | AND move.id = line.move_id \ | 1217 | AND move.id = line.move_id \ |
225 | 1157 | AND ((invoice.state = \'paid\') \ | 1218 | AND ((invoice.state = \'paid\') \ |
226 | 1158 | OR (invoice.id IS NULL)) \ | 1219 | OR (invoice.id IS NULL)) \ |
228 | 1159 | GROUP BY line.tax_code_id') | 1220 | GROUP BY line.tax_code_id', |
229 | 1221 | (parent_ids,)+where_params) | ||
230 | 1160 | else: | 1222 | else: |
231 | 1161 | cr.execute('SELECT line.tax_code_id, sum(line.tax_amount) \ | 1223 | cr.execute('SELECT line.tax_code_id, sum(line.tax_amount) \ |
232 | 1162 | FROM account_move_line AS line \ | 1224 | FROM account_move_line AS line \ |
235 | 1163 | WHERE line.tax_code_id in ('+acc_set+') '+where+' \ | 1225 | WHERE line.tax_code_id in %s '+where+' \ |
236 | 1164 | GROUP BY line.tax_code_id') | 1226 | GROUP BY line.tax_code_id', |
237 | 1227 | (parent_ids,)+where_params) | ||
238 | 1165 | res=dict(cr.fetchall()) | 1228 | res=dict(cr.fetchall()) |
239 | 1166 | for record in self.browse(cr, uid, ids, context): | 1229 | for record in self.browse(cr, uid, ids, context): |
240 | 1167 | def _rec_get(record): | 1230 | def _rec_get(record): |
241 | @@ -1178,12 +1241,14 @@ | |||
242 | 1178 | else: | 1241 | else: |
243 | 1179 | fiscalyear_id = self.pool.get('account.fiscalyear').find(cr, uid, exception=False) | 1242 | fiscalyear_id = self.pool.get('account.fiscalyear').find(cr, uid, exception=False) |
244 | 1180 | where = '' | 1243 | where = '' |
245 | 1244 | where_params = () | ||
246 | 1181 | if fiscalyear_id: | 1245 | if fiscalyear_id: |
247 | 1182 | pids = map(lambda x: str(x.id), self.pool.get('account.fiscalyear').browse(cr, uid, fiscalyear_id).period_ids) | 1246 | pids = map(lambda x: str(x.id), self.pool.get('account.fiscalyear').browse(cr, uid, fiscalyear_id).period_ids) |
248 | 1183 | if pids: | 1247 | if pids: |
250 | 1184 | where = ' and period_id in (' + (','.join(pids))+')' | 1248 | where = ' and period_id in %s' |
251 | 1249 | where_params = (tuple(pids),) | ||
252 | 1185 | return self._sum(cr, uid, ids, name, args, context, | 1250 | return self._sum(cr, uid, ids, name, args, context, |
254 | 1186 | where=where) | 1251 | where=where, where_params=where_params) |
255 | 1187 | 1252 | ||
256 | 1188 | def _sum_period(self, cr, uid, ids, name, args, context): | 1253 | def _sum_period(self, cr, uid, ids, name, args, context): |
257 | 1189 | if 'period_id' in context and context['period_id']: | 1254 | if 'period_id' in context and context['period_id']: |
258 | @@ -1194,7 +1259,8 @@ | |||
259 | 1194 | return dict.fromkeys(ids, 0.0) | 1259 | return dict.fromkeys(ids, 0.0) |
260 | 1195 | period_id = period_id[0] | 1260 | period_id = period_id[0] |
261 | 1196 | return self._sum(cr, uid, ids, name, args, context, | 1261 | return self._sum(cr, uid, ids, name, args, context, |
263 | 1197 | where=' and line.period_id='+str(period_id)) | 1262 | where=' and line.period_id=%s', |
264 | 1263 | where_params=(period_id,)) | ||
265 | 1198 | 1264 | ||
266 | 1199 | _name = 'account.tax.code' | 1265 | _name = 'account.tax.code' |
267 | 1200 | _description = 'Tax Code' | 1266 | _description = 'Tax Code' |
268 | @@ -1240,6 +1306,7 @@ | |||
269 | 1240 | 'sign': lambda *args: 1.0, | 1306 | 'sign': lambda *args: 1.0, |
270 | 1241 | 'notprintable': lambda *a: False, | 1307 | 'notprintable': lambda *a: False, |
271 | 1242 | } | 1308 | } |
272 | 1309 | <<<<<<< TREE | ||
273 | 1243 | def _check_recursion(self, cr, uid, ids): | 1310 | def _check_recursion(self, cr, uid, ids): |
274 | 1244 | level = 100 | 1311 | level = 100 |
275 | 1245 | while len(ids): | 1312 | while len(ids): |
276 | @@ -1257,6 +1324,9 @@ | |||
277 | 1257 | default.update({'line_ids': []}) | 1324 | default.update({'line_ids': []}) |
278 | 1258 | return super(account_tax_code, self).copy(cr, uid, id, default, context) | 1325 | return super(account_tax_code, self).copy(cr, uid, id, default, context) |
279 | 1259 | 1326 | ||
280 | 1327 | ======= | ||
281 | 1328 | _check_recursion = check_cycle | ||
282 | 1329 | >>>>>>> MERGE-SOURCE | ||
283 | 1260 | _constraints = [ | 1330 | _constraints = [ |
284 | 1261 | (_check_recursion, 'Error ! You can not create recursive accounts.', ['parent_id']) | 1331 | (_check_recursion, 'Error ! You can not create recursive accounts.', ['parent_id']) |
285 | 1262 | ] | 1332 | ] |
286 | @@ -1869,16 +1939,7 @@ | |||
287 | 1869 | 'type' : lambda *a :'view', | 1939 | 'type' : lambda *a :'view', |
288 | 1870 | } | 1940 | } |
289 | 1871 | 1941 | ||
300 | 1872 | def _check_recursion(self, cr, uid, ids): | 1942 | _check_recursion = check_cycle |
291 | 1873 | level = 100 | ||
292 | 1874 | while len(ids): | ||
293 | 1875 | cr.execute('select parent_id from account_account_template where id in ('+','.join(map(str,ids))+')') | ||
294 | 1876 | ids = filter(None, map(lambda x:x[0], cr.fetchall())) | ||
295 | 1877 | if not level: | ||
296 | 1878 | return False | ||
297 | 1879 | level -= 1 | ||
298 | 1880 | return True | ||
299 | 1881 | |||
301 | 1882 | _constraints = [ | 1943 | _constraints = [ |
302 | 1883 | (_check_recursion, 'Error ! You can not create recursive account templates.', ['parent_id']) | 1944 | (_check_recursion, 'Error ! You can not create recursive account templates.', ['parent_id']) |
303 | 1884 | ] | 1945 | ] |
304 | @@ -1928,16 +1989,7 @@ | |||
305 | 1928 | return [(x['id'], (x['code'] and x['code'] + ' - ' or '') + x['name']) \ | 1989 | return [(x['id'], (x['code'] and x['code'] + ' - ' or '') + x['name']) \ |
306 | 1929 | for x in reads] | 1990 | for x in reads] |
307 | 1930 | 1991 | ||
318 | 1931 | def _check_recursion(self, cr, uid, ids): | 1992 | _check_recursion = check_cycle |
309 | 1932 | level = 100 | ||
310 | 1933 | while len(ids): | ||
311 | 1934 | cr.execute('select distinct parent_id from account_tax_code_template where id in ('+','.join(map(str,ids))+')') | ||
312 | 1935 | ids = filter(None, map(lambda x:x[0], cr.fetchall())) | ||
313 | 1936 | if not level: | ||
314 | 1937 | return False | ||
315 | 1938 | level -= 1 | ||
316 | 1939 | return True | ||
317 | 1940 | |||
319 | 1941 | _constraints = [ | 1993 | _constraints = [ |
320 | 1942 | (_check_recursion, 'Error ! You can not create recursive Tax Codes.', ['parent_id']) | 1994 | (_check_recursion, 'Error ! You can not create recursive Tax Codes.', ['parent_id']) |
321 | 1943 | ] | 1995 | ] |
322 | 1944 | 1996 | ||
323 | === modified file 'account/account_move_line.py' | |||
324 | --- account/account_move_line.py 2010-03-04 11:50:58 +0000 | |||
325 | +++ account/account_move_line.py 2010-03-17 11:50:49 +0000 | |||
326 | @@ -257,9 +257,10 @@ | |||
327 | 257 | for line_id in ids: | 257 | for line_id in ids: |
328 | 258 | res[line_id] = False | 258 | res[line_id] = False |
329 | 259 | cursor.execute('SELECT l.id, i.id ' \ | 259 | cursor.execute('SELECT l.id, i.id ' \ |
333 | 260 | 'FROM account_move_line l, account_invoice i ' \ | 260 | 'FROM account_move_line l, account_invoice i ' \ |
334 | 261 | 'WHERE l.move_id = i.move_id ' \ | 261 | 'WHERE l.move_id = i.move_id ' \ |
335 | 262 | 'AND l.id in (' + ','.join([str(x) for x in ids]) + ')') | 262 | 'AND l.id in %s', |
336 | 263 | (tuple(ids),)) | ||
337 | 263 | invoice_ids = [] | 264 | invoice_ids = [] |
338 | 264 | for line_id, invoice_id in cursor.fetchall(): | 265 | for line_id, invoice_id in cursor.fetchall(): |
339 | 265 | res[line_id] = invoice_id | 266 | res[line_id] = invoice_id |
340 | @@ -566,10 +567,11 @@ | |||
341 | 566 | else: | 567 | else: |
342 | 567 | date = time.strftime('%Y-%m-%d') | 568 | date = time.strftime('%Y-%m-%d') |
343 | 568 | 569 | ||
348 | 569 | cr.execute('SELECT account_id, reconcile_id \ | 570 | cr.execute('SELECT account_id, reconcile_id '\ |
349 | 570 | FROM account_move_line \ | 571 | 'FROM account_move_line '\ |
350 | 571 | WHERE id IN ('+id_set+') \ | 572 | 'WHERE id IN %s '\ |
351 | 572 | GROUP BY account_id,reconcile_id') | 573 | 'GROUP BY account_id,reconcile_id', |
352 | 574 | (tuple(ids),)) | ||
353 | 573 | r = cr.fetchall() | 575 | r = cr.fetchall() |
354 | 574 | #TODO: move this check to a constraint in the account_move_reconcile object | 576 | #TODO: move this check to a constraint in the account_move_reconcile object |
355 | 575 | if (len(r) != 1) and not context.get('fy_closing', False): | 577 | if (len(r) != 1) and not context.get('fy_closing', False): |
356 | 576 | 578 | ||
357 | === modified file 'account/invoice.py' | |||
358 | --- account/invoice.py 2010-03-09 12:49:07 +0000 | |||
359 | +++ account/invoice.py 2010-03-17 11:50:49 +0000 | |||
360 | @@ -21,6 +21,8 @@ | |||
361 | 21 | ############################################################################## | 21 | ############################################################################## |
362 | 22 | 22 | ||
363 | 23 | import time | 23 | import time |
364 | 24 | from operator import itemgetter | ||
365 | 25 | |||
366 | 24 | import netsvc | 26 | import netsvc |
367 | 25 | from osv import fields, osv | 27 | from osv import fields, osv |
368 | 26 | import pooler | 28 | import pooler |
369 | @@ -428,12 +430,13 @@ | |||
370 | 428 | def move_line_id_payment_get(self, cr, uid, ids, *args): | 430 | def move_line_id_payment_get(self, cr, uid, ids, *args): |
371 | 429 | res = [] | 431 | res = [] |
372 | 430 | if not ids: return res | 432 | if not ids: return res |
379 | 431 | cr.execute('select \ | 433 | cr.execute('SELECT l.id '\ |
380 | 432 | l.id \ | 434 | 'FROM account_move_line l '\ |
381 | 433 | from account_move_line l \ | 435 | 'LEFT JOIN account_invoice i ON (i.move_id=l.move_id) '\ |
382 | 434 | left join account_invoice i on (i.move_id=l.move_id) \ | 436 | 'WHERE i.id IN %s '\ |
383 | 435 | where i.id in ('+','.join(map(str,ids))+') and l.account_id=i.account_id') | 437 | 'AND l.account_id=i.account_id', |
384 | 436 | res = map(lambda x: x[0], cr.fetchall()) | 438 | (tuple(ids),)) |
385 | 439 | res = map(itemgetter(0), cr.fetchall()) | ||
386 | 437 | return res | 440 | return res |
387 | 438 | 441 | ||
388 | 439 | def copy(self, cr, uid, id, default=None, context=None): | 442 | def copy(self, cr, uid, id, default=None, context=None): |
389 | @@ -714,8 +717,9 @@ | |||
390 | 714 | 717 | ||
391 | 715 | def action_number(self, cr, uid, ids, *args): | 718 | def action_number(self, cr, uid, ids, *args): |
392 | 716 | cr.execute('SELECT id, type, number, move_id, reference ' \ | 719 | cr.execute('SELECT id, type, number, move_id, reference ' \ |
395 | 717 | 'FROM account_invoice ' \ | 720 | 'FROM account_invoice ' \ |
396 | 718 | 'WHERE id IN ('+','.join(map(str,ids))+')') | 721 | 'WHERE id IN %s', |
397 | 722 | (tuple(ids),)) | ||
398 | 719 | obj_inv = self.browse(cr, uid, ids)[0] | 723 | obj_inv = self.browse(cr, uid, ids)[0] |
399 | 720 | for (id, invtype, number, move_id, reference) in cr.fetchall(): | 724 | for (id, invtype, number, move_id, reference) in cr.fetchall(): |
400 | 721 | if not number: | 725 | if not number: |
401 | @@ -949,7 +953,9 @@ | |||
402 | 949 | line_ids = [] | 953 | line_ids = [] |
403 | 950 | total = 0.0 | 954 | total = 0.0 |
404 | 951 | line = self.pool.get('account.move.line') | 955 | line = self.pool.get('account.move.line') |
406 | 952 | cr.execute('select id from account_move_line where move_id in ('+str(move_id)+','+str(invoice.move_id.id)+')') | 956 | cr.execute('SELECT id FROM account_move_line '\ |
407 | 957 | 'WHERE move_id in %s', | ||
408 | 958 | ((move_id, invoice.move_id.id),)) | ||
409 | 953 | lines = line.browse(cr, uid, map(lambda x: x[0], cr.fetchall()) ) | 959 | lines = line.browse(cr, uid, map(lambda x: x[0], cr.fetchall()) ) |
410 | 954 | for l in lines+invoice.payment_ids: | 960 | for l in lines+invoice.payment_ids: |
411 | 955 | if l.account_id.id==src_account_id: | 961 | if l.account_id.id==src_account_id: |
412 | 956 | 962 | ||
413 | === modified file 'account/partner.py' | |||
414 | --- account/partner.py 2010-01-08 11:38:58 +0000 | |||
415 | +++ account/partner.py 2010-03-17 11:50:49 +0000 | |||
416 | @@ -19,6 +19,7 @@ | |||
417 | 19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
418 | 20 | # | 20 | # |
419 | 21 | ############################################################################## | 21 | ############################################################################## |
420 | 22 | from operator import itemgetter | ||
421 | 22 | 23 | ||
422 | 23 | from osv import fields, osv | 24 | from osv import fields, osv |
423 | 24 | import ir | 25 | import ir |
424 | @@ -89,22 +90,19 @@ | |||
425 | 89 | _name = 'res.partner' | 90 | _name = 'res.partner' |
426 | 90 | _inherit = 'res.partner' | 91 | _inherit = 'res.partner' |
427 | 91 | _description = 'Partner' | 92 | _description = 'Partner' |
428 | 93 | |||
429 | 92 | def _credit_debit_get(self, cr, uid, ids, field_names, arg, context): | 94 | def _credit_debit_get(self, cr, uid, ids, field_names, arg, context): |
430 | 93 | query = self.pool.get('account.move.line')._query_get(cr, uid, context=context) | 95 | query = self.pool.get('account.move.line')._query_get(cr, uid, context=context) |
445 | 94 | cr.execute(("""select | 96 | cr.execute("""SELECT l.partner_id, a.type, SUM(l.debit-l.credit) |
446 | 95 | l.partner_id, a.type, sum(l.debit-l.credit) | 97 | FROM account_move_line l |
447 | 96 | from | 98 | LEFT JOIN account_account a ON (l.account_id=a.id) |
448 | 97 | account_move_line l | 99 | WHERE a.type IN ('receivable','payable') |
449 | 98 | left join | 100 | AND l.partner_id in %s |
450 | 99 | account_account a on (l.account_id=a.id) | 101 | AND l.reconcile_id IS NULL |
451 | 100 | where | 102 | AND """ + query + """ |
452 | 101 | a.type in ('receivable','payable') and | 103 | GROUP BY l.partner_id, a.type |
453 | 102 | l.partner_id in (%s) and | 104 | """, |
454 | 103 | l.reconcile_id is null and | 105 | (tuple(ids),)) |
441 | 104 | """ % (','.join(map(str, ids)),))+query+""" | ||
442 | 105 | group by | ||
443 | 106 | l.partner_id, a.type | ||
444 | 107 | """) | ||
455 | 108 | tinvert = { | 106 | tinvert = { |
456 | 109 | 'credit': 'receivable', | 107 | 'credit': 'receivable', |
457 | 110 | 'debit': 'payable' | 108 | 'debit': 'payable' |
458 | @@ -118,27 +116,38 @@ | |||
459 | 118 | res[pid][maps[type]] = (type=='receivable') and val or -val | 116 | res[pid][maps[type]] = (type=='receivable') and val or -val |
460 | 119 | return res | 117 | return res |
461 | 120 | 118 | ||
462 | 119 | def _asset_difference_search(self, cr, uid, obj, name, type, args, | ||
463 | 120 | context=None): | ||
464 | 121 | if not len(args): | ||
465 | 122 | return [] | ||
466 | 123 | having_values = tuple(map(itemgetter(2), args)) | ||
467 | 124 | where = ' AND '.join( | ||
468 | 125 | map(lambda x: '(SUM(debit-credit) %(operator)s %%s)' % { | ||
469 | 126 | 'operator':x[1]}, | ||
470 | 127 | args)) | ||
471 | 128 | query = self.pool.get('account.move.line')._query_get(cr, uid, | ||
472 | 129 | context=context) | ||
473 | 130 | cr.execute(('SELECT partner_id FROM account_move_line l '\ | ||
474 | 131 | 'WHERE account_id IN '\ | ||
475 | 132 | '(SELECT id FROM account_account '\ | ||
476 | 133 | 'WHERE type=%s AND active) '\ | ||
477 | 134 | 'AND reconcile_id IS NULL '\ | ||
478 | 135 | 'AND '+query+' '\ | ||
479 | 136 | 'AND partner_id IS NOT NULL '\ | ||
480 | 137 | 'GROUP BY partner_id HAVING '+where), | ||
481 | 138 | (type,) + having_values) | ||
482 | 139 | res = cr.fetchall() | ||
483 | 140 | if not len(res): | ||
484 | 141 | return [('id','=','0')] | ||
485 | 142 | return [('id','in',map(itemgetter(0), res))] | ||
486 | 143 | |||
487 | 121 | def _credit_search(self, cr, uid, obj, name, args, context): | 144 | def _credit_search(self, cr, uid, obj, name, args, context): |
497 | 122 | if not len(args): | 145 | return self._asset_difference_search( |
498 | 123 | return [] | 146 | cr, uid, obj, name, 'receivable', args, context=context) |
490 | 124 | where = ' and '.join(map(lambda x: '(sum(debit-credit)'+x[1]+str(x[2])+')',args)) | ||
491 | 125 | query = self.pool.get('account.move.line')._query_get(cr, uid, context={}) | ||
492 | 126 | cr.execute(('select partner_id from account_move_line l where account_id in (select id from account_account where type=%s and active) and reconcile_id is null and '+query+' and partner_id is not null group by partner_id having '+where), ('receivable',) ) | ||
493 | 127 | res = cr.fetchall() | ||
494 | 128 | if not len(res): | ||
495 | 129 | return [('id','=','0')] | ||
496 | 130 | return [('id','in',map(lambda x:x[0], res))] | ||
499 | 131 | 147 | ||
500 | 132 | def _debit_search(self, cr, uid, obj, name, args, context): | 148 | def _debit_search(self, cr, uid, obj, name, args, context): |
510 | 133 | if not len(args): | 149 | return self._asset_difference_search( |
511 | 134 | return [] | 150 | cr, uid, obj, name, 'payable', args, context=context) |
503 | 135 | query = self.pool.get('account.move.line')._query_get(cr, uid, context={}) | ||
504 | 136 | where = ' and '.join(map(lambda x: '(sum(debit-credit)'+x[1]+str(x[2])+')',args)) | ||
505 | 137 | cr.execute(('select partner_id from account_move_line l where account_id in (select id from account_account where type=%s and active) and reconcile_id is null and '+query+' and partner_id is not null group by partner_id having '+where), ('payable',) ) | ||
506 | 138 | res = cr.fetchall() | ||
507 | 139 | if not len(res): | ||
508 | 140 | return [('id','=','0')] | ||
509 | 141 | return [('id','in',map(lambda x:x[0], res))] | ||
512 | 142 | 151 | ||
513 | 143 | _columns = { | 152 | _columns = { |
514 | 144 | 'credit': fields.function(_credit_debit_get, | 153 | 'credit': fields.function(_credit_debit_get, |
515 | 145 | 154 | ||
516 | === modified file 'account/project/project.py' | |||
517 | --- account/project/project.py 2010-02-15 07:17:01 +0000 | |||
518 | +++ account/project/project.py 2010-03-17 11:50:49 +0000 | |||
519 | @@ -1,7 +1,7 @@ | |||
520 | 1 | # -*- encoding: utf-8 -*- | 1 | # -*- encoding: utf-8 -*- |
521 | 2 | ############################################################################## | 2 | ############################################################################## |
522 | 3 | # | 3 | # |
524 | 4 | # OpenERP, Open Source Management Solution | 4 | # OpenERP, Open Source Management Solution |
525 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved |
526 | 6 | # $Id$ | 6 | # $Id$ |
527 | 7 | # | 7 | # |
528 | @@ -19,10 +19,10 @@ | |||
529 | 19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
530 | 20 | # | 20 | # |
531 | 21 | ############################################################################## | 21 | ############################################################################## |
532 | 22 | |||
533 | 23 | import time | 22 | import time |
534 | 24 | import operator | 23 | import operator |
535 | 25 | 24 | ||
536 | 25 | import netsvc | ||
537 | 26 | from osv import fields | 26 | from osv import fields |
538 | 27 | from osv import osv | 27 | from osv import osv |
539 | 28 | 28 | ||
540 | @@ -33,47 +33,52 @@ | |||
541 | 33 | class account_analytic_account(osv.osv): | 33 | class account_analytic_account(osv.osv): |
542 | 34 | _name = 'account.analytic.account' | 34 | _name = 'account.analytic.account' |
543 | 35 | _description = 'Analytic Accounts' | 35 | _description = 'Analytic Accounts' |
544 | 36 | logger = netsvc.Logger() | ||
545 | 36 | 37 | ||
546 | 37 | def _credit_calc(self, cr, uid, ids, name, arg, context={}): | 38 | def _credit_calc(self, cr, uid, ids, name, arg, context={}): |
555 | 38 | r = {} | 39 | self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG, |
556 | 39 | acc_set = ",".join(map(str, ids)) | 40 | 'Entering _credit_calc; ids:%s'%ids) |
557 | 40 | 41 | if not ids: return {} | |
550 | 41 | for i in ids: | ||
551 | 42 | r.setdefault(i,0.0) | ||
552 | 43 | |||
553 | 44 | if not acc_set: | ||
554 | 45 | return r | ||
558 | 46 | 42 | ||
559 | 47 | where_date = '' | 43 | where_date = '' |
566 | 48 | if context.get('from_date',False): | 44 | if context.get('from_date'): |
567 | 49 | where_date += " AND l.date >= '" + context['from_date'] + "'" | 45 | where_date += " AND l.date >= %(from_date)s" |
568 | 50 | if context.get('to_date',False): | 46 | if context.get('to_date'): |
569 | 51 | where_date += " AND l.date <= '" + context['to_date'] + "'" | 47 | where_date += " AND l.date <= %(to_date)s" |
570 | 52 | 48 | ||
571 | 53 | cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id %s) WHERE l.amount<0 and a.id IN (%s) GROUP BY a.id" % (where_date,acc_set)) | 49 | cr.execute("SELECT a.id, COALESCE(SUM(l.amount), 0) " |
572 | 50 | "FROM account_analytic_account a " | ||
573 | 51 | "LEFT JOIN account_analytic_line l ON (a.id=l.account_id %s)" | ||
574 | 52 | " WHERE l.amount < 0 AND a.id IN %%(ids)s " | ||
575 | 53 | "GROUP BY a.id" % (where_date), | ||
576 | 54 | dict(context, ids=tuple(ids))) | ||
577 | 54 | r = dict(cr.fetchall()) | 55 | r = dict(cr.fetchall()) |
578 | 56 | self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG, | ||
579 | 57 | '_credit_calc results: %s'%r) | ||
580 | 55 | for i in ids: | 58 | for i in ids: |
581 | 56 | r.setdefault(i,0.0) | 59 | r.setdefault(i,0.0) |
582 | 57 | return r | 60 | return r |
583 | 58 | 61 | ||
584 | 59 | def _debit_calc(self, cr, uid, ids, name, arg, context={}): | 62 | def _debit_calc(self, cr, uid, ids, name, arg, context={}): |
587 | 60 | r = {} | 63 | self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG, |
588 | 61 | acc_set = ",".join(map(str, ids)) | 64 | 'Entering _debit_calc; ids:%s'%ids) |
589 | 65 | if not ids: return {} | ||
590 | 62 | 66 | ||
591 | 63 | for i in ids: | ||
592 | 64 | r.setdefault(i,0.0) | ||
593 | 65 | |||
594 | 66 | if not acc_set: | ||
595 | 67 | return r | ||
596 | 68 | |||
597 | 69 | where_date = '' | 67 | where_date = '' |
605 | 70 | if context.get('from_date',False): | 68 | if context.get('from_date'): |
606 | 71 | where_date += " AND l.date >= '" + context['from_date'] + "'" | 69 | where_date += " AND l.date >= %(from_date)s" |
607 | 72 | if context.get('to_date',False): | 70 | if context.get('to_date'): |
608 | 73 | where_date += " AND l.date <= '" + context['to_date'] + "'" | 71 | where_date += " AND l.date <= %(to_date)s" |
609 | 74 | 72 | ||
610 | 75 | cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id %s) WHERE l.amount>0 and a.id IN (%s) GROUP BY a.id" % (where_date,acc_set)) | 73 | cr.execute("SELECT a.id, COALESCE(SUM(l.amount), 0) " |
611 | 76 | r= dict(cr.fetchall()) | 74 | "FROM account_analytic_account a " |
612 | 75 | "LEFT JOIN account_analytic_line l ON (a.id=l.account_id %s)" | ||
613 | 76 | " WHERE l.amount > 0 AND a.id IN %%(ids)s " | ||
614 | 77 | "GROUP BY a.id" % (where_date), | ||
615 | 78 | dict(context, ids=tuple(ids))) | ||
616 | 79 | r = dict(cr.fetchall()) | ||
617 | 80 | self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG, | ||
618 | 81 | '_debut_calc results: %s'%r) | ||
619 | 77 | for i in ids: | 82 | for i in ids: |
620 | 78 | r.setdefault(i,0.0) | 83 | r.setdefault(i,0.0) |
621 | 79 | return r | 84 | return r |
622 | @@ -81,35 +86,49 @@ | |||
623 | 81 | def _balance_calc(self, cr, uid, ids, name, arg, context={}): | 86 | def _balance_calc(self, cr, uid, ids, name, arg, context={}): |
624 | 82 | res = {} | 87 | res = {} |
625 | 83 | ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) | 88 | ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) |
628 | 84 | acc_set = ",".join(map(str, ids2)) | 89 | self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG, |
629 | 85 | 90 | 'Entering _balance_calc; ids:%s; ids2:%s'%( | |
630 | 91 | ids, ids2)) | ||
631 | 92 | |||
632 | 86 | for i in ids: | 93 | for i in ids: |
633 | 87 | res.setdefault(i,0.0) | 94 | res.setdefault(i,0.0) |
636 | 88 | 95 | ||
637 | 89 | if not acc_set: | 96 | if not ids2: |
638 | 90 | return res | 97 | return res |
640 | 91 | 98 | ||
641 | 92 | where_date = '' | 99 | where_date = '' |
649 | 93 | if context.get('from_date',False): | 100 | if context.get('from_date'): |
650 | 94 | where_date += " AND l.date >= '" + context['from_date'] + "'" | 101 | where_date += " AND l.date >= %(from_date)s" |
651 | 95 | if context.get('to_date',False): | 102 | if context.get('to_date'): |
652 | 96 | where_date += " AND l.date <= '" + context['to_date'] + "'" | 103 | where_date += " AND l.date <= %(to_date)s" |
653 | 97 | 104 | ||
654 | 98 | cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id %s) WHERE a.id IN (%s) GROUP BY a.id" % (where_date,acc_set)) | 105 | cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) " |
655 | 99 | 106 | "FROM account_analytic_account a " | |
656 | 107 | "LEFT JOIN account_analytic_line l ON (a.id=l.account_id %s)" | ||
657 | 108 | " WHERE a.id IN %%(ids)s " | ||
658 | 109 | "GROUP BY a.id" % (where_date), | ||
659 | 110 | dict(context, ids=tuple(ids))) | ||
660 | 111 | |||
661 | 100 | for account_id, sum in cr.fetchall(): | 112 | for account_id, sum in cr.fetchall(): |
662 | 101 | res[account_id] = sum | 113 | res[account_id] = sum |
667 | 102 | 114 | self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG, | |
668 | 103 | cr.execute("SELECT a.id, r.currency_id FROM account_analytic_account a INNER JOIN res_company r ON (a.company_id = r.id) where a.id in (%s)" % acc_set) | 115 | '_balance_calc, (id, sum): %s'%res) |
669 | 104 | 116 | ||
670 | 105 | currency= dict(cr.fetchall()) | 117 | cr.execute("SELECT a.id, r.currency_id " |
671 | 118 | "FROM account_analytic_account a " | ||
672 | 119 | "INNER JOIN res_company r ON (a.company_id = r.id) " | ||
673 | 120 | "WHERE a.id in %s", (tuple(ids),)) | ||
674 | 121 | |||
675 | 122 | currency = dict(cr.fetchall()) | ||
676 | 123 | self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG, | ||
677 | 124 | '_balance_calc currency: %s'%currency) | ||
678 | 106 | 125 | ||
679 | 107 | res_currency= self.pool.get('res.currency') | 126 | res_currency= self.pool.get('res.currency') |
680 | 108 | for id in ids: | 127 | for id in ids: |
681 | 109 | if id not in ids2: | 128 | if id not in ids2: |
682 | 110 | continue | 129 | continue |
683 | 111 | for child in self.search(cr, uid, [('parent_id', 'child_of', [id])]): | 130 | for child in self.search(cr, uid, [('parent_id', 'child_of', [id])]): |
685 | 112 | if child <> id: | 131 | if child != id: |
686 | 113 | res.setdefault(id, 0.0) | 132 | res.setdefault(id, 0.0) |
687 | 114 | if currency[child]<>currency[id]: | 133 | if currency[child]<>currency[id]: |
688 | 115 | res[id] += res_currency.compute(cr, uid, currency[child], currency[id], res.get(child, 0.0), context=context) | 134 | res[id] += res_currency.compute(cr, uid, currency[child], currency[id], res.get(child, 0.0), context=context) |
689 | @@ -125,36 +144,40 @@ | |||
690 | 125 | return dict([(i, res[i]) for i in ids ]) | 144 | return dict([(i, res[i]) for i in ids ]) |
691 | 126 | 145 | ||
692 | 127 | def _quantity_calc(self, cr, uid, ids, name, arg, context={}): | 146 | def _quantity_calc(self, cr, uid, ids, name, arg, context={}): |
693 | 147 | self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG, | ||
694 | 148 | '_quantity_calc ids:%s'%ids) | ||
695 | 128 | #XXX must convert into one uom | 149 | #XXX must convert into one uom |
696 | 129 | res = {} | 150 | res = {} |
697 | 130 | ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) | 151 | ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) |
700 | 131 | acc_set = ",".join(map(str, ids2)) | 152 | |
699 | 132 | |||
701 | 133 | for i in ids: | 153 | for i in ids: |
702 | 134 | res.setdefault(i,0.0) | 154 | res.setdefault(i,0.0) |
705 | 135 | 155 | ||
706 | 136 | if not acc_set: | 156 | if not ids2: |
707 | 137 | return res | 157 | return res |
709 | 138 | 158 | ||
710 | 139 | where_date = '' | 159 | where_date = '' |
716 | 140 | if context.get('from_date',False): | 160 | if context.get('from_date'): |
717 | 141 | where_date += " AND l.date >= '" + context['from_date'] + "'" | 161 | where_date += " AND l.date >= %(from_date)s" |
718 | 142 | if context.get('to_date',False): | 162 | if context.get('to_date'): |
719 | 143 | where_date += " AND l.date <= '" + context['to_date'] + "'" | 163 | where_date += " AND l.date <= %(to_date)s" |
720 | 144 | 164 | ||
721 | 145 | cr.execute('SELECT a.id, COALESCE(SUM(l.unit_amount), 0) \ | 165 | cr.execute('SELECT a.id, COALESCE(SUM(l.unit_amount), 0) \ |
722 | 146 | FROM account_analytic_account a \ | 166 | FROM account_analytic_account a \ |
725 | 147 | LEFT JOIN account_analytic_line l ON (a.id = l.account_id ' + where_date + ') \ | 167 | LEFT JOIN account_analytic_line l ON (a.id = l.account_id %s) \ |
726 | 148 | WHERE a.id IN ('+acc_set+') GROUP BY a.id') | 168 | WHERE a.id IN %%(ids)s GROUP BY a.id'%(where_date), |
727 | 169 | dict(context, ids=tuple(ids2))) | ||
728 | 149 | 170 | ||
729 | 150 | for account_id, sum in cr.fetchall(): | 171 | for account_id, sum in cr.fetchall(): |
730 | 151 | res[account_id] = sum | 172 | res[account_id] = sum |
731 | 173 | self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG, | ||
732 | 174 | '_quantity_calc, (id, sum): %s'%res) | ||
733 | 152 | 175 | ||
734 | 153 | for id in ids: | 176 | for id in ids: |
735 | 154 | if id not in ids2: | 177 | if id not in ids2: |
736 | 155 | continue | 178 | continue |
737 | 156 | for child in self.search(cr, uid, [('parent_id', 'child_of', [id])]): | 179 | for child in self.search(cr, uid, [('parent_id', 'child_of', [id])]): |
739 | 157 | if child <> id: | 180 | if child != id: |
740 | 158 | res.setdefault(id, 0.0) | 181 | res.setdefault(id, 0.0) |
741 | 159 | res[id] += res.get(child, 0.0) | 182 | res[id] += res.get(child, 0.0) |
742 | 160 | return dict([(i, res[i]) for i in ids]) | 183 | return dict([(i, res[i]) for i in ids]) |
743 | @@ -299,4 +322,3 @@ | |||
744 | 299 | account_journal() | 322 | account_journal() |
745 | 300 | 323 | ||
746 | 301 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | 324 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
747 | 302 | |||
748 | 303 | 325 | ||
749 | === modified file 'account/project/report/analytic_balance.py' | |||
750 | --- account/project/report/analytic_balance.py 2009-10-09 11:49:00 +0000 | |||
751 | +++ account/project/report/analytic_balance.py 2010-03-17 11:50:49 +0000 | |||
752 | @@ -33,15 +33,9 @@ | |||
753 | 33 | 'get_objects': self._get_objects, | 33 | 'get_objects': self._get_objects, |
754 | 34 | 'lines_g': self._lines_g, | 34 | 'lines_g': self._lines_g, |
755 | 35 | 'move_sum': self._move_sum, | 35 | 'move_sum': self._move_sum, |
756 | 36 | # 'move_sum_debit': self._move_sum_debit, | ||
757 | 37 | # 'move_sum_credit': self._move_sum_credit, | ||
758 | 38 | 'sum_all': self._sum_all, | 36 | 'sum_all': self._sum_all, |
759 | 39 | # 'sum_debit': self._sum_debit, | ||
760 | 40 | # 'sum_credit': self._sum_credit, | ||
761 | 41 | 'sum_balance': self._sum_balance, | 37 | 'sum_balance': self._sum_balance, |
762 | 42 | # 'sum_quantity': self._sum_quantity, | ||
763 | 43 | 'move_sum_balance': self._move_sum_balance, | 38 | 'move_sum_balance': self._move_sum_balance, |
764 | 44 | # 'move_sum_quantity': self._move_sum_quantity, | ||
765 | 45 | }) | 39 | }) |
766 | 46 | self.acc_ids = [] | 40 | self.acc_ids = [] |
767 | 47 | self.read_data = [] | 41 | self.read_data = [] |
768 | @@ -82,10 +76,10 @@ | |||
769 | 82 | sum(aal.amount) AS balance, sum(aal.unit_amount) AS quantity \ | 76 | sum(aal.amount) AS balance, sum(aal.unit_amount) AS quantity \ |
770 | 83 | FROM account_analytic_line AS aal, account_account AS aa \ | 77 | FROM account_analytic_line AS aal, account_account AS aa \ |
771 | 84 | WHERE (aal.general_account_id=aa.id) \ | 78 | WHERE (aal.general_account_id=aa.id) \ |
773 | 85 | AND (aal.account_id in (" + ','.join(map(str, ids)) + "))\ | 79 | AND (aal.account_id in %s)\ |
774 | 86 | AND (date>=%s) AND (date<=%s) AND aa.active \ | 80 | AND (date>=%s) AND (date<=%s) AND aa.active \ |
775 | 87 | GROUP BY aal.general_account_id, aa.name, aa.code, aal.code \ | 81 | GROUP BY aal.general_account_id, aa.name, aa.code, aal.code \ |
777 | 88 | ORDER BY aal.code", (date1, date2)) | 82 | ORDER BY aal.code", (tuple(ids), date1, date2)) |
778 | 89 | res = self.cr.dictfetchall() | 83 | res = self.cr.dictfetchall() |
779 | 90 | 84 | ||
780 | 91 | for r in res: | 85 | for r in res: |
781 | @@ -108,62 +102,26 @@ | |||
782 | 108 | self.acc_data_dict[account_id] = ids | 102 | self.acc_data_dict[account_id] = ids |
783 | 109 | else: | 103 | else: |
784 | 110 | ids = self.acc_data_dict[account_id] | 104 | ids = self.acc_data_dict[account_id] |
786 | 111 | 105 | ||
787 | 106 | query_params = (tuple(ids), date1, date2) | ||
788 | 112 | if option == "credit" : | 107 | if option == "credit" : |
789 | 113 | self.cr.execute("SELECT -sum(amount) FROM account_analytic_line \ | 108 | self.cr.execute("SELECT -sum(amount) FROM account_analytic_line \ |
793 | 114 | WHERE account_id in ("+ ','.join(map(str, ids)) +") \ | 109 | WHERE account_id in %s \ |
794 | 115 | AND date>=%s AND date<=%s AND amount<0", | 110 | AND date>=%s AND date<=%s AND amount<0", query_params) |
792 | 116 | (date1, date2)) | ||
795 | 117 | elif option == "debit" : | 111 | elif option == "debit" : |
796 | 118 | self.cr.execute("SELECT sum(amount) FROM account_analytic_line \ | 112 | self.cr.execute("SELECT sum(amount) FROM account_analytic_line \ |
800 | 119 | WHERE account_id in ("+ ','.join(map(str, ids)) +") \ | 113 | WHERE account_id in %s \ |
801 | 120 | AND date>=%s AND date<=%s AND amount>0", | 114 | AND date>=%s AND date<=%s AND amount>0", query_params) |
799 | 121 | (date1, date2)) | ||
802 | 122 | elif option == "quantity" : | 115 | elif option == "quantity" : |
803 | 123 | self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line \ | 116 | self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line \ |
807 | 124 | WHERE account_id in ("+ ','.join(map(str, ids)) +") \ | 117 | WHERE account_id in %s \ |
808 | 125 | AND date>=%s AND date<=%s", | 118 | AND date>=%s AND date<=%s", query_params) |
806 | 126 | (date1, date2)) | ||
809 | 127 | return self.cr.fetchone()[0] or 0.0 | 119 | return self.cr.fetchone()[0] or 0.0 |
810 | 128 | |||
811 | 129 | 120 | ||
812 | 130 | # def _move_sum_debit(self, account_id, date1, date2): | ||
813 | 131 | # account_analytic_obj = self.pool.get('account.analytic.account') | ||
814 | 132 | # ids = account_analytic_obj.search(self.cr, self.uid, | ||
815 | 133 | # [('parent_id', 'child_of', [account_id])]) | ||
816 | 134 | # self.cr.execute("SELECT sum(amount) \ | ||
817 | 135 | # FROM account_analytic_line \ | ||
818 | 136 | # WHERE account_id in ("+ ','.join(map(str, ids)) +") \ | ||
819 | 137 | # AND date>=%s AND date<=%s AND amount>0", | ||
820 | 138 | # (date1, date2)) | ||
821 | 139 | # return self.cr.fetchone()[0] or 0.0 | ||
822 | 140 | # | ||
823 | 141 | # def _move_sum_credit(self, account_id, date1, date2): | ||
824 | 142 | # account_analytic_obj = self.pool.get('account.analytic.account') | ||
825 | 143 | # ids = account_analytic_obj.search(self.cr, self.uid, | ||
826 | 144 | # [('parent_id', 'child_of', [account_id])]) | ||
827 | 145 | # self.cr.execute("SELECT -sum(amount) \ | ||
828 | 146 | # FROM account_analytic_line \ | ||
829 | 147 | # WHERE account_id in ("+ ','.join(map(str, ids)) +") \ | ||
830 | 148 | # AND date>=%s AND date<=%s AND amount<0", | ||
831 | 149 | # (date1, date2)) | ||
832 | 150 | # return self.cr.fetchone()[0] or 0.0 | ||
833 | 151 | # | ||
834 | 152 | def _move_sum_balance(self, account_id, date1, date2): | 121 | def _move_sum_balance(self, account_id, date1, date2): |
835 | 153 | debit = self._move_sum(account_id, date1, date2, 'debit') | 122 | debit = self._move_sum(account_id, date1, date2, 'debit') |
836 | 154 | credit = self._move_sum(account_id, date1, date2, 'credit') | 123 | credit = self._move_sum(account_id, date1, date2, 'credit') |
837 | 155 | return (debit-credit) | 124 | return (debit-credit) |
838 | 156 | |||
839 | 157 | # def _move_sum_quantity(self, account_id, date1, date2): | ||
840 | 158 | # account_analytic_obj = self.pool.get('account.analytic.account') | ||
841 | 159 | # ids = account_analytic_obj.search(self.cr, self.uid, | ||
842 | 160 | # [('parent_id', 'child_of', [account_id])]) | ||
843 | 161 | # self.cr.execute("SELECT sum(unit_amount) \ | ||
844 | 162 | # FROM account_analytic_line \ | ||
845 | 163 | # WHERE account_id in ("+ ','.join(map(str, ids)) +") \ | ||
846 | 164 | # AND date>=%s AND date<=%s", | ||
847 | 165 | # (date1, date2)) | ||
848 | 166 | # return self.cr.fetchone()[0] or 0.0 | ||
849 | 167 | 125 | ||
850 | 168 | def _sum_all(self, accounts, date1, date2, option): | 126 | def _sum_all(self, accounts, date1, date2, option): |
851 | 169 | ids = map(lambda x: x['id'], accounts) | 127 | ids = map(lambda x: x['id'], accounts) |
852 | @@ -178,72 +136,26 @@ | |||
853 | 178 | else: | 136 | else: |
854 | 179 | ids2 = self.acc_sum_list | 137 | ids2 = self.acc_sum_list |
855 | 180 | 138 | ||
856 | 139 | query_params = (tuple(ids2), date1, date2) | ||
857 | 181 | if option == "debit" : | 140 | if option == "debit" : |
858 | 182 | self.cr.execute("SELECT sum(amount) FROM account_analytic_line \ | 141 | self.cr.execute("SELECT sum(amount) FROM account_analytic_line \ |
862 | 183 | WHERE account_id IN ("+','.join(map(str, ids2))+") \ | 142 | WHERE account_id IN %s \ |
863 | 184 | AND date>=%s AND date<=%s AND amount>0", | 143 | AND date>=%s AND date<=%s AND amount>0", query_params) |
861 | 185 | (date1, date2)) | ||
864 | 186 | elif option == "credit" : | 144 | elif option == "credit" : |
865 | 187 | self.cr.execute("SELECT -sum(amount) FROM account_analytic_line \ | 145 | self.cr.execute("SELECT -sum(amount) FROM account_analytic_line \ |
869 | 188 | WHERE account_id IN ("+','.join(map(str, ids2))+") \ | 146 | WHERE account_id IN %s \ |
870 | 189 | AND date>=%s AND date<=%s AND amount<0", | 147 | AND date>=%s AND date<=%s AND amount<0", query_params) |
868 | 190 | (date1, date2)) | ||
871 | 191 | elif option == "quantity" : | 148 | elif option == "quantity" : |
872 | 192 | self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line \ | 149 | self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line \ |
876 | 193 | WHERE account_id IN ("+','.join(map(str, ids2))+") \ | 150 | WHERE account_id IN %s \ |
877 | 194 | AND date>=%s AND date<=%s", | 151 | AND date>=%s AND date<=%s", query_params) |
875 | 195 | (date1, date2)) | ||
878 | 196 | return self.cr.fetchone()[0] or 0.0 | 152 | return self.cr.fetchone()[0] or 0.0 |
879 | 197 | 153 | ||
880 | 198 | |||
881 | 199 | # def _sum_debit(self, accounts, date1, date2): | ||
882 | 200 | # ids = map(lambda x: x['id'], accounts) | ||
883 | 201 | # if not len(ids): | ||
884 | 202 | # return 0.0 | ||
885 | 203 | # account_analytic_obj = self.pool.get('account.analytic.account') | ||
886 | 204 | # ids2 = account_analytic_obj.search(self.cr, self.uid, | ||
887 | 205 | # [('parent_id', 'child_of', ids)]) | ||
888 | 206 | # self.cr.execute("SELECT sum(amount) \ | ||
889 | 207 | # FROM account_analytic_line \ | ||
890 | 208 | # WHERE account_id IN ("+','.join(map(str, ids2))+") \ | ||
891 | 209 | # AND date>=%s AND date<=%s AND amount>0", | ||
892 | 210 | # (date1, date2)) | ||
893 | 211 | # return self.cr.fetchone()[0] or 0.0 | ||
894 | 212 | # | ||
895 | 213 | # def _sum_credit(self, accounts, date1, date2): | ||
896 | 214 | # ids = map(lambda x: x['id'], accounts) | ||
897 | 215 | # if not len(ids): | ||
898 | 216 | # return 0.0 | ||
899 | 217 | # ids = map(lambda x: x['id'], accounts) | ||
900 | 218 | # account_analytic_obj = self.pool.get('account.analytic.account') | ||
901 | 219 | # ids2 = account_analytic_obj.search(self.cr, self.uid, | ||
902 | 220 | # [('parent_id', 'child_of', ids)]) | ||
903 | 221 | # self.cr.execute("SELECT -sum(amount) \ | ||
904 | 222 | # FROM account_analytic_line \ | ||
905 | 223 | # WHERE account_id IN ("+','.join(map(str, ids2))+") \ | ||
906 | 224 | # AND date>=%s AND date<=%s AND amount<0", | ||
907 | 225 | # (date1, date2)) | ||
908 | 226 | # return self.cr.fetchone()[0] or 0.0 | ||
909 | 227 | |||
910 | 228 | def _sum_balance(self, accounts, date1, date2): | 154 | def _sum_balance(self, accounts, date1, date2): |
911 | 229 | debit = self._sum_all(accounts, date1, date2, 'debit') or 0.0 | 155 | debit = self._sum_all(accounts, date1, date2, 'debit') or 0.0 |
912 | 230 | credit = self._sum_all(accounts, date1, date2, 'credit') or 0.0 | 156 | credit = self._sum_all(accounts, date1, date2, 'credit') or 0.0 |
913 | 231 | return (debit-credit) | 157 | return (debit-credit) |
914 | 232 | 158 | ||
915 | 233 | # def _sum_quantity(self, accounts, date1, date2): | ||
916 | 234 | # ids = map(lambda x: x['id'], accounts) | ||
917 | 235 | # if not len(ids): | ||
918 | 236 | # return 0.0 | ||
919 | 237 | # account_analytic_obj = self.pool.get('account.analytic.account') | ||
920 | 238 | # ids2 = account_analytic_obj.search(self.cr, self.uid, | ||
921 | 239 | # [('parent_id', 'child_of', ids)]) | ||
922 | 240 | # self.cr.execute("SELECT sum(unit_amount) \ | ||
923 | 241 | # FROM account_analytic_line \ | ||
924 | 242 | # WHERE account_id IN ("+','.join(map(str, ids2))+") \ | ||
925 | 243 | # AND date>=%s AND date<=%s", | ||
926 | 244 | # (date1, date2)) | ||
927 | 245 | # return self.cr.fetchone()[0] or 0.0 | ||
928 | 246 | |||
929 | 247 | report_sxw.report_sxw('report.account.analytic.account.balance', | 159 | report_sxw.report_sxw('report.account.analytic.account.balance', |
930 | 248 | 'account.analytic.account', 'addons/account/project/report/analytic_balance.rml', | 160 | 'account.analytic.account', 'addons/account/project/report/analytic_balance.rml', |
931 | 249 | parser=account_analytic_balance, header=False) | 161 | parser=account_analytic_balance, header=False) |
932 | 250 | 162 | ||
933 | === modified file 'account/project/report/analytic_check.py' | |||
934 | --- account/project/report/analytic_check.py 2010-02-24 10:46:58 +0000 | |||
935 | +++ account/project/report/analytic_check.py 2010-03-17 11:50:49 +0000 | |||
936 | @@ -44,7 +44,6 @@ | |||
937 | 44 | def _lines_p(self, date1, date2): | 44 | def _lines_p(self, date1, date2): |
938 | 45 | res = [] | 45 | res = [] |
939 | 46 | acc_obj = self.pool.get('account.account') | 46 | acc_obj = self.pool.get('account.account') |
940 | 47 | # print"3333333acc_obj3333333",acc_obj.read(self.cr, self.uid, self.ids, ['name', 'code','user_type']) | ||
941 | 48 | 47 | ||
942 | 49 | for a in acc_obj.read(self.cr, self.uid, self.ids, ['name', 'code']): | 48 | for a in acc_obj.read(self.cr, self.uid, self.ids, ['name', 'code']): |
943 | 50 | self.cr.execute("SELECT sum(debit), sum(credit) \ | 49 | self.cr.execute("SELECT sum(debit), sum(credit) \ |
944 | @@ -79,41 +78,6 @@ | |||
945 | 79 | 78 | ||
946 | 80 | return res | 79 | return res |
947 | 81 | 80 | ||
948 | 82 | # def _lines_p(self, date1, date2): | ||
949 | 83 | # res = [] | ||
950 | 84 | # acc_obj = self.pool.get('account.account') | ||
951 | 85 | # for a in acc_obj.read(self.cr, self.uid, self.ids, ['name', 'code','sign']): | ||
952 | 86 | # self.cr.execute("SELECT sum(debit), sum(credit) \ | ||
953 | 87 | # FROM account_move_line \ | ||
954 | 88 | # WHERE date>=%s AND date<=%s AND state<>'draft' AND account_id = %s", (date1, date2, a['id'])) | ||
955 | 89 | # (gd, gc) = self.cr.fetchone() | ||
956 | 90 | # gd = gd or 0.0 | ||
957 | 91 | # gc = gc or 0.0 | ||
958 | 92 | # | ||
959 | 93 | # self.cr.execute("SELECT abs(sum(amount)) AS balance \ | ||
960 | 94 | # FROM account_analytic_line \ | ||
961 | 95 | # WHERE date>=%s AND date<=%s AND amount*%s>0 AND general_account_id = %s", (date1, date2, a['sign'], a['id'])) | ||
962 | 96 | # (ad,) = self.cr.fetchone() | ||
963 | 97 | # ad = ad or 0.0 | ||
964 | 98 | # self.cr.execute("SELECT abs(sum(amount)) AS balance \ | ||
965 | 99 | # FROM account_analytic_line \ | ||
966 | 100 | # WHERE date>=%s AND date<=%s AND amount*%s<0 AND general_account_id = %s", (date1, date2, a['sign'], a['id'])) | ||
967 | 101 | # (ac,) = self.cr.fetchone() | ||
968 | 102 | # ac = ac or 0.0 | ||
969 | 103 | # | ||
970 | 104 | # res.append({'code': a['code'], 'name': a['name'], | ||
971 | 105 | # 'gen_debit': gd, | ||
972 | 106 | # 'gen_credit': gc, | ||
973 | 107 | # 'ana_debit': ad, | ||
974 | 108 | # 'ana_credit': ac, | ||
975 | 109 | # 'delta_debit': gd - ad, | ||
976 | 110 | # 'delta_credit': gc - ac,}) | ||
977 | 111 | # self.sum_gen_deb += gd | ||
978 | 112 | # self.sum_gen_cred += gc | ||
979 | 113 | # self.sum_ana_deb += ad | ||
980 | 114 | # self.sum_ana_cred += ac | ||
981 | 115 | # return res | ||
982 | 116 | |||
983 | 117 | def _gen_deb(self, date1, date2): | 81 | def _gen_deb(self, date1, date2): |
984 | 118 | return self.sum_gen_deb | 82 | return self.sum_gen_deb |
985 | 119 | 83 | ||
986 | @@ -134,5 +98,4 @@ | |||
987 | 134 | 98 | ||
988 | 135 | report_sxw.report_sxw('report.account.analytic.account.analytic.check', 'account.analytic.account', 'addons/account/project/report/analytic_check.rml',parser=account_analytic_analytic_check, header=False) | 99 | report_sxw.report_sxw('report.account.analytic.account.analytic.check', 'account.analytic.account', 'addons/account/project/report/analytic_check.rml',parser=account_analytic_analytic_check, header=False) |
989 | 136 | 100 | ||
990 | 137 | |||
991 | 138 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | 101 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
992 | 139 | 102 | ||
993 | === modified file 'account/project/report/cost_ledger.py' | |||
994 | --- account/project/report/cost_ledger.py 2009-10-09 11:49:00 +0000 | |||
995 | +++ account/project/report/cost_ledger.py 2010-03-17 11:50:49 +0000 | |||
996 | @@ -94,15 +94,20 @@ | |||
997 | 94 | ids = map(lambda x: x.id, accounts) | 94 | ids = map(lambda x: x.id, accounts) |
998 | 95 | if not len(ids): | 95 | if not len(ids): |
999 | 96 | return 0.0 | 96 | return 0.0 |
1001 | 97 | self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s AND amount>0", (date1, date2)) | 97 | self.cr.execute("SELECT SUM(amount) FROM account_analytic_line " |
1002 | 98 | "WHERE account_id IN %s " | ||
1003 | 99 | "AND date>=%s AND date<=%s AND amount>0", | ||
1004 | 100 | (tuple(ids), date1, date2)) | ||
1005 | 98 | return self.cr.fetchone()[0] or 0.0 | 101 | return self.cr.fetchone()[0] or 0.0 |
1006 | 99 | 102 | ||
1007 | 100 | def _sum_credit(self, accounts, date1, date2): | 103 | def _sum_credit(self, accounts, date1, date2): |
1008 | 101 | ids = map(lambda x: x.id, accounts) | 104 | ids = map(lambda x: x.id, accounts) |
1009 | 102 | if not len(ids): | 105 | if not len(ids): |
1010 | 103 | return 0.0 | 106 | return 0.0 |
1013 | 104 | ids = map(lambda x: x.id, accounts) | 107 | self.cr.execute("SELECT -SUM(amount) FROM account_analytic_line " |
1014 | 105 | self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s AND amount<0", (date1, date2)) | 108 | "WHERE account_id IN %s " |
1015 | 109 | "AND date>=%s AND date<=%s AND amount<0", | ||
1016 | 110 | (tuple(ids), date1, date2)) | ||
1017 | 106 | return self.cr.fetchone()[0] or 0.0 | 111 | return self.cr.fetchone()[0] or 0.0 |
1018 | 107 | 112 | ||
1019 | 108 | def _sum_balance(self, accounts, date1, date2): | 113 | def _sum_balance(self, accounts, date1, date2): |
1020 | @@ -112,6 +117,5 @@ | |||
1021 | 112 | 117 | ||
1022 | 113 | report_sxw.report_sxw('report.account.analytic.account.cost_ledger', 'account.analytic.account', 'addons/account/project/report/cost_ledger.rml',parser=account_analytic_cost_ledger, header=False) | 118 | report_sxw.report_sxw('report.account.analytic.account.cost_ledger', 'account.analytic.account', 'addons/account/project/report/cost_ledger.rml',parser=account_analytic_cost_ledger, header=False) |
1023 | 114 | 119 | ||
1024 | 115 | |||
1025 | 116 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | 120 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
1026 | 117 | 121 | ||
1027 | 118 | 122 | ||
1028 | === modified file 'account/project/report/inverted_analytic_balance.py' | |||
1029 | --- account/project/report/inverted_analytic_balance.py 2009-10-09 11:49:00 +0000 | |||
1030 | +++ account/project/report/inverted_analytic_balance.py 2010-03-17 11:50:49 +0000 | |||
1031 | @@ -39,10 +39,16 @@ | |||
1032 | 39 | 39 | ||
1033 | 40 | def _lines_g(self, accounts, date1, date2): | 40 | def _lines_g(self, accounts, date1, date2): |
1034 | 41 | ids = map(lambda x: x.id, accounts) | 41 | ids = map(lambda x: x.id, accounts) |
1036 | 42 | self.cr.execute("SELECT aa.name AS name, aa.code AS code, sum(aal.amount) AS balance, sum(aal.unit_amount) AS quantity, aa.id AS id \ | 42 | self.cr.execute("SELECT aa.name AS name, aa.code AS code, " |
1037 | 43 | "sum(aal.amount) AS balance, " | ||
1038 | 44 | "sum(aal.unit_amount) AS quantity, aa.id AS id \ | ||
1039 | 43 | FROM account_analytic_line AS aal, account_account AS aa \ | 45 | FROM account_analytic_line AS aal, account_account AS aa \ |
1042 | 44 | WHERE (aal.general_account_id=aa.id) AND (aal.account_id IN ("+','.join(map(str, ids))+")) AND (date>=%s) AND (date<=%s) AND aa.active \ | 46 | WHERE (aal.general_account_id=aa.id) " |
1043 | 45 | GROUP BY aal.general_account_id, aa.name, aa.code, aal.code, aa.id ORDER BY aal.code", (date1, date2)) | 47 | "AND (aal.account_id IN %s) " |
1044 | 48 | "AND (date>=%s) AND (date<=%s) AND aa.active \ | ||
1045 | 49 | GROUP BY aal.general_account_id, aa.name, aa.code, aal.code, aa.id " | ||
1046 | 50 | "ORDER BY aal.code", | ||
1047 | 51 | (tuple(ids), date1, date2)) | ||
1048 | 46 | res = self.cr.dictfetchall() | 52 | res = self.cr.dictfetchall() |
1049 | 47 | 53 | ||
1050 | 48 | for r in res: | 54 | for r in res: |
1051 | @@ -59,10 +65,17 @@ | |||
1052 | 59 | 65 | ||
1053 | 60 | def _lines_a(self, accounts, general_account_id, date1, date2): | 66 | def _lines_a(self, accounts, general_account_id, date1, date2): |
1054 | 61 | ids = map(lambda x: x.id, accounts) | 67 | ids = map(lambda x: x.id, accounts) |
1059 | 62 | self.cr.execute("SELECT sum(aal.amount) AS balance, sum(aal.unit_amount) AS quantity, aaa.code AS code, aaa.name AS name, account_id \ | 68 | self.cr.execute("SELECT sum(aal.amount) AS balance, " |
1060 | 63 | FROM account_analytic_line AS aal, account_analytic_account AS aaa \ | 69 | "sum(aal.unit_amount) AS quantity, " |
1061 | 64 | WHERE aal.account_id=aaa.id AND aal.account_id IN ("+','.join(map(str, ids))+") AND aal.general_account_id=%s AND aal.date>=%s AND aal.date<=%s \ | 70 | "aaa.code AS code, aaa.name AS name, account_id \ |
1062 | 65 | GROUP BY aal.account_id, general_account_id, aaa.code, aaa.name ORDER BY aal.account_id", (general_account_id, date1, date2)) | 71 | FROM account_analytic_line AS aal, " |
1063 | 72 | "account_analytic_account AS aaa \ | ||
1064 | 73 | WHERE aal.account_id=aaa.id AND aal.account_id IN %s " | ||
1065 | 74 | "AND aal.general_account_id=%s AND aal.date>=%s " | ||
1066 | 75 | "AND aal.date<=%s \ | ||
1067 | 76 | GROUP BY aal.account_id, general_account_id, aaa.code, aaa.name " | ||
1068 | 77 | "ORDER BY aal.account_id", | ||
1069 | 78 | (tuple(ids), general_account_id, date1, date2)) | ||
1070 | 66 | res = self.cr.dictfetchall() | 79 | res = self.cr.dictfetchall() |
1071 | 67 | 80 | ||
1072 | 68 | aaa_obj = self.pool.get('account.analytic.account') | 81 | aaa_obj = self.pool.get('account.analytic.account') |
1073 | @@ -87,14 +100,16 @@ | |||
1074 | 87 | ids = map(lambda x: x.id, accounts) | 100 | ids = map(lambda x: x.id, accounts) |
1075 | 88 | self.cr.execute("SELECT sum(amount) \ | 101 | self.cr.execute("SELECT sum(amount) \ |
1076 | 89 | FROM account_analytic_line \ | 102 | FROM account_analytic_line \ |
1078 | 90 | WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s AND amount>0", (date1, date2)) | 103 | WHERE account_id IN %s AND date>=%s AND date<=%s AND amount>0", |
1079 | 104 | (tuple(ids), date1, date2)) | ||
1080 | 91 | return self.cr.fetchone()[0] or 0.0 | 105 | return self.cr.fetchone()[0] or 0.0 |
1081 | 92 | 106 | ||
1082 | 93 | def _sum_credit(self, accounts, date1, date2): | 107 | def _sum_credit(self, accounts, date1, date2): |
1083 | 94 | ids = map(lambda x: x.id, accounts) | 108 | ids = map(lambda x: x.id, accounts) |
1084 | 95 | self.cr.execute("SELECT -sum(amount) \ | 109 | self.cr.execute("SELECT -sum(amount) \ |
1085 | 96 | FROM account_analytic_line \ | 110 | FROM account_analytic_line \ |
1087 | 97 | WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s AND amount<0", (date1, date2)) | 111 | WHERE account_id IN %s AND date>=%s AND date<=%s AND amount<0", |
1088 | 112 | (tuple(ids), date1, date2)) | ||
1089 | 98 | return self.cr.fetchone()[0] or 0.0 | 113 | return self.cr.fetchone()[0] or 0.0 |
1090 | 99 | 114 | ||
1091 | 100 | def _sum_balance(self, accounts, date1, date2): | 115 | def _sum_balance(self, accounts, date1, date2): |
1092 | @@ -106,7 +121,8 @@ | |||
1093 | 106 | ids = map(lambda x: x.id, accounts) | 121 | ids = map(lambda x: x.id, accounts) |
1094 | 107 | self.cr.execute("SELECT sum(unit_amount) \ | 122 | self.cr.execute("SELECT sum(unit_amount) \ |
1095 | 108 | FROM account_analytic_line \ | 123 | FROM account_analytic_line \ |
1097 | 109 | WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s", (date1, date2)) | 124 | WHERE account_id IN %s AND date>=%s AND date<=%s", |
1098 | 125 | (tuple(ids), date1, date2)) | ||
1099 | 110 | return self.cr.fetchone()[0] or 0.0 | 126 | return self.cr.fetchone()[0] or 0.0 |
1100 | 111 | 127 | ||
1101 | 112 | report_sxw.report_sxw('report.account.analytic.account.inverted.balance', 'account.analytic.account', 'addons/account/project/report/inverted_analytic_balance.rml',parser=account_inverted_analytic_balance, header=False) | 128 | report_sxw.report_sxw('report.account.analytic.account.inverted.balance', 'account.analytic.account', 'addons/account/project/report/inverted_analytic_balance.rml',parser=account_inverted_analytic_balance, header=False) |
1102 | 113 | 129 | ||
1103 | === modified file 'account/project/report/quantity_cost_ledger.py' | |||
1104 | --- account/project/report/quantity_cost_ledger.py 2009-10-09 11:49:00 +0000 | |||
1105 | +++ account/project/report/quantity_cost_ledger.py 2010-03-17 11:50:49 +0000 | |||
1106 | @@ -53,10 +53,9 @@ | |||
1107 | 53 | WHERE (aal.account_id=%s) AND (aal.date>=%s) \ | 53 | WHERE (aal.account_id=%s) AND (aal.date>=%s) \ |
1108 | 54 | AND (aal.date<=%s) AND (aal.general_account_id=aa.id) \ | 54 | AND (aal.date<=%s) AND (aal.general_account_id=aa.id) \ |
1109 | 55 | AND aa.active \ | 55 | AND aa.active \ |
1112 | 56 | AND (aal.journal_id IN (" + | 56 | AND (aal.journal_id IN %s) \ |
1111 | 57 | ','.join(map(str, journal_ids)) + ")) \ | ||
1113 | 58 | GROUP BY aa.code, aa.name, aa.id ORDER BY aa.code", | 57 | GROUP BY aa.code, aa.name, aa.id ORDER BY aa.code", |
1115 | 59 | (account_id, date1, date2)) | 58 | (account_id, date1, date2, tuple(journal_ids))) |
1116 | 60 | res = self.cr.dictfetchall() | 59 | res = self.cr.dictfetchall() |
1117 | 61 | return res | 60 | return res |
1118 | 62 | 61 | ||
1119 | @@ -81,10 +80,10 @@ | |||
1120 | 81 | account_analytic_journal AS aaj \ | 80 | account_analytic_journal AS aaj \ |
1121 | 82 | WHERE (aal.general_account_id=%s) AND (aal.account_id=%s) \ | 81 | WHERE (aal.general_account_id=%s) AND (aal.account_id=%s) \ |
1122 | 83 | AND (aal.date>=%s) AND (aal.date<=%s) \ | 82 | AND (aal.date>=%s) AND (aal.date<=%s) \ |
1125 | 84 | AND (aal.journal_id=aaj.id) AND (aaj.id IN (" + | 83 | AND (aal.journal_id=aaj.id) AND (aaj.id IN %s) \ |
1124 | 85 | ','.join(map(str, journal_ids)) + ")) \ | ||
1126 | 86 | ORDER BY aal.date, aaj.code, aal.code", | 84 | ORDER BY aal.date, aaj.code, aal.code", |
1128 | 87 | (general_account_id, account_id, date1, date2)) | 85 | (general_account_id, account_id, |
1129 | 86 | date1, date2, tuple(journal_ids))) | ||
1130 | 88 | res = self.cr.dictfetchall() | 87 | res = self.cr.dictfetchall() |
1131 | 89 | return res | 88 | return res |
1132 | 90 | 89 | ||
1133 | @@ -99,9 +98,8 @@ | |||
1134 | 99 | self.cr.execute("SELECT sum(unit_amount) \ | 98 | self.cr.execute("SELECT sum(unit_amount) \ |
1135 | 100 | FROM account_analytic_line \ | 99 | FROM account_analytic_line \ |
1136 | 101 | WHERE account_id = %s AND date >= %s AND date <= %s \ | 100 | WHERE account_id = %s AND date >= %s AND date <= %s \ |
1140 | 102 | AND journal_id IN (" + | 101 | AND journal_id IN %s", |
1141 | 103 | ','.join(map(str, journal_ids)) + ")", | 102 | (account_id, date1, date2, tuple(journal_ids))) |
1139 | 104 | (account_id, date1, date2)) | ||
1142 | 105 | return self.cr.fetchone()[0] or 0.0 | 103 | return self.cr.fetchone()[0] or 0.0 |
1143 | 106 | 104 | ||
1144 | 107 | def _sum_quantity(self, accounts, date1, date2, journals): | 105 | def _sum_quantity(self, accounts, date1, date2, journals): |
1145 | @@ -111,18 +109,15 @@ | |||
1146 | 111 | if not journals or not journals[0][2]: | 109 | if not journals or not journals[0][2]: |
1147 | 112 | self.cr.execute("SELECT sum(unit_amount) \ | 110 | self.cr.execute("SELECT sum(unit_amount) \ |
1148 | 113 | FROM account_analytic_line \ | 111 | FROM account_analytic_line \ |
1152 | 114 | WHERE account_id IN (" + | 112 | WHERE account_id IN %s AND date>=%s AND date<=%s", |
1153 | 115 | ','.join(map(str, ids)) + ") AND date>=%s AND date<=%s", | 113 | (tuple(ids), date1, date2)) |
1151 | 116 | (date1, date2)) | ||
1154 | 117 | else: | 114 | else: |
1155 | 118 | journal_ids = journals[0][2] | 115 | journal_ids = journals[0][2] |
1156 | 119 | self.cr.execute("SELECT sum(unit_amount) \ | 116 | self.cr.execute("SELECT sum(unit_amount) \ |
1157 | 120 | FROM account_analytic_line \ | 117 | FROM account_analytic_line \ |
1163 | 121 | WHERE account_id IN (" + | 118 | WHERE account_id IN %s AND date >= %s AND date <= %s \ |
1164 | 122 | ','.join(map(str, ids)) + ") AND date >= %s AND date <= %s \ | 119 | AND journal_id IN %s", |
1165 | 123 | AND journal_id IN (" + | 120 | (tuple(ids), date1, date2, tuple(journal_ids))) |
1161 | 124 | ','.join(map(str, journal_ids)) + ")", | ||
1162 | 125 | (date1, date2)) | ||
1166 | 126 | return self.cr.fetchone()[0] or 0.0 | 121 | return self.cr.fetchone()[0] or 0.0 |
1167 | 127 | 122 | ||
1168 | 128 | report_sxw.report_sxw('report.account.analytic.account.quantity_cost_ledger', | 123 | report_sxw.report_sxw('report.account.analytic.account.quantity_cost_ledger', |
1169 | 129 | 124 | ||
1170 | === modified file 'account/report/account_balance.py' | |||
1171 | --- account/report/account_balance.py 2009-10-09 11:49:00 +0000 | |||
1172 | +++ account/report/account_balance.py 2010-03-17 11:50:49 +0000 | |||
1173 | @@ -104,10 +104,7 @@ | |||
1174 | 104 | ctx['periods'] = form['periods'][0][2] | 104 | ctx['periods'] = form['periods'][0][2] |
1175 | 105 | ctx['date_from'] = form['date_from'] | 105 | ctx['date_from'] = form['date_from'] |
1176 | 106 | ctx['date_to'] = form['date_to'] | 106 | ctx['date_to'] = form['date_to'] |
1181 | 107 | # accounts = self.pool.get('account.account').browse(self.cr, self.uid, ids, ctx) | 107 | |
1178 | 108 | # def cmp_code(x, y): | ||
1179 | 109 | # return cmp(x.code, y.code) | ||
1180 | 110 | # accounts.sort(cmp_code) | ||
1182 | 111 | child_ids = self.pool.get('account.account')._get_children_and_consol(self.cr, self.uid, ids, ctx) | 108 | child_ids = self.pool.get('account.account')._get_children_and_consol(self.cr, self.uid, ids, ctx) |
1183 | 112 | if child_ids: | 109 | if child_ids: |
1184 | 113 | ids = child_ids | 110 | ids = child_ids |
1185 | @@ -131,18 +128,7 @@ | |||
1186 | 131 | } | 128 | } |
1187 | 132 | self.sum_debit += account['debit'] | 129 | self.sum_debit += account['debit'] |
1188 | 133 | self.sum_credit += account['credit'] | 130 | self.sum_credit += account['credit'] |
1189 | 134 | # if account.child_id: | ||
1190 | 135 | # def _check_rec(account): | ||
1191 | 136 | # if not account.child_id: | ||
1192 | 137 | # return bool(account.credit or account.debit) | ||
1193 | 138 | # for c in account.child_id: | ||
1194 | 139 | # if not _check_rec(c) or _check_rec(c): | ||
1195 | 140 | # return True | ||
1196 | 141 | # return False | ||
1197 | 142 | # if not _check_rec(account) : | ||
1198 | 143 | # continue | ||
1199 | 144 | if account['parent_id']: | 131 | if account['parent_id']: |
1200 | 145 | # acc = self.pool.get('account.account').read(self.cr, self.uid, [ account['parent_id'][0] ] ,['name'], ctx) | ||
1201 | 146 | for r in result_acc: | 132 | for r in result_acc: |
1202 | 147 | if r['id'] == account['parent_id'][0]: | 133 | if r['id'] == account['parent_id'][0]: |
1203 | 148 | res['level'] = r['level'] + 1 | 134 | res['level'] = r['level'] + 1 |
1204 | @@ -155,16 +141,6 @@ | |||
1205 | 155 | result_acc.append(res) | 141 | result_acc.append(res) |
1206 | 156 | else: | 142 | else: |
1207 | 157 | result_acc.append(res) | 143 | result_acc.append(res) |
1208 | 158 | # if account.child_id: | ||
1209 | 159 | # acc_id = [acc.id for acc in account.child_id] | ||
1210 | 160 | # lst_string = '' | ||
1211 | 161 | # lst_string = '\'' + '\',\''.join(map(str,acc_id)) + '\'' | ||
1212 | 162 | # self.cr.execute("select code,id from account_account where id IN (%s)"%(lst_string)) | ||
1213 | 163 | # a_id = self.cr.fetchall() | ||
1214 | 164 | # a_id.sort() | ||
1215 | 165 | # ids2 = [x[1] for x in a_id] | ||
1216 | 166 | # | ||
1217 | 167 | # result_acc += self.lines(form, ids2, done, level+1) | ||
1218 | 168 | return result_acc | 144 | return result_acc |
1219 | 169 | 145 | ||
1220 | 170 | def _sum_credit(self): | 146 | def _sum_credit(self): |
1221 | 171 | 147 | ||
1222 | === modified file 'account/report/aged_trial_balance.py' | |||
1223 | --- account/report/aged_trial_balance.py 2009-10-09 11:49:00 +0000 | |||
1224 | +++ account/report/aged_trial_balance.py 2010-03-17 11:50:49 +0000 | |||
1225 | @@ -1,7 +1,7 @@ | |||
1226 | 1 | # -*- encoding: utf-8 -*- | 1 | # -*- encoding: utf-8 -*- |
1227 | 2 | ############################################################################## | 2 | ############################################################################## |
1228 | 3 | # | 3 | # |
1230 | 4 | # OpenERP, Open Source Management Solution | 4 | # OpenERP, Open Source Management Solution |
1231 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved |
1232 | 6 | # $Id$ | 6 | # $Id$ |
1233 | 7 | # | 7 | # |
1234 | @@ -21,207 +21,213 @@ | |||
1235 | 21 | ############################################################################## | 21 | ############################################################################## |
1236 | 22 | 22 | ||
1237 | 23 | import time | 23 | import time |
1238 | 24 | from operator import itemgetter | ||
1239 | 24 | import pooler | 25 | import pooler |
1240 | 25 | import rml_parse | 26 | import rml_parse |
1241 | 26 | from report import report_sxw | 27 | from report import report_sxw |
1242 | 27 | 28 | ||
1243 | 28 | class aged_trial_report(rml_parse.rml_parse): | 29 | class aged_trial_report(rml_parse.rml_parse): |
1244 | 29 | 30 | ||
1436 | 30 | def __init__(self, cr, uid, name, context): | 31 | def __init__(self, cr, uid, name, context): |
1437 | 31 | super(aged_trial_report, self).__init__(cr, uid, name, context=context) | 32 | super(aged_trial_report, self).__init__(cr, uid, name, context=context) |
1438 | 32 | self.line_query = '' | 33 | self.line_query = '' |
1439 | 33 | self.total_account = [] | 34 | self.total_account = [] |
1440 | 34 | 35 | ||
1441 | 35 | 36 | ||
1442 | 36 | self.localcontext.update({ | 37 | self.localcontext.update({ |
1443 | 37 | 'time': time, | 38 | 'time': time, |
1444 | 38 | 'get_lines': self._get_lines, | 39 | 'get_lines': self._get_lines, |
1445 | 39 | 'get_total': self._get_total, | 40 | 'get_total': self._get_total, |
1446 | 40 | 'get_direction': self._get_direction, | 41 | 'get_direction': self._get_direction, |
1447 | 41 | 'get_for_period': self._get_for_period, | 42 | 'get_for_period': self._get_for_period, |
1448 | 42 | 'get_company': self._get_company, | 43 | 'get_company': self._get_company, |
1449 | 43 | 'get_currency': self._get_currency, | 44 | 'get_currency': self._get_currency, |
1450 | 44 | 45 | ||
1451 | 45 | }) | 46 | }) |
1452 | 46 | 47 | ||
1453 | 47 | 48 | ||
1454 | 48 | def _get_lines(self, form): | 49 | def _get_lines(self, form): |
1455 | 49 | 50 | ||
1456 | 50 | if (form['result_selection'] == 'customer' ): | 51 | if (form['result_selection'] == 'customer' ): |
1457 | 51 | self.ACCOUNT_TYPE = "('receivable')" | 52 | self.ACCOUNT_TYPE = "('receivable')" |
1458 | 52 | elif (form['result_selection'] == 'supplier'): | 53 | elif (form['result_selection'] == 'supplier'): |
1459 | 53 | self.ACCOUNT_TYPE = "('payable')" | 54 | self.ACCOUNT_TYPE = "('payable')" |
1460 | 54 | else: | 55 | else: |
1461 | 55 | self.ACCOUNT_TYPE = "('payable','receivable')" | 56 | self.ACCOUNT_TYPE = "('payable','receivable')" |
1462 | 56 | 57 | ||
1463 | 57 | 58 | ||
1464 | 58 | res = [] | 59 | res = [] |
1465 | 59 | account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') | 60 | account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') |
1466 | 60 | self.line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='line', | 61 | self.line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='line', |
1467 | 61 | context={'fiscalyear': form['fiscalyear']}) | 62 | context={'fiscalyear': form['fiscalyear']}) |
1468 | 62 | self.cr.execute("""SELECT DISTINCT res_partner.id AS id, | 63 | self.cr.execute("""SELECT DISTINCT res_partner.id AS id, |
1469 | 63 | res_partner.name AS name | 64 | res_partner.name AS name |
1470 | 64 | FROM res_partner,account_move_line AS line, account_account | 65 | FROM res_partner,account_move_line AS line, account_account |
1471 | 65 | WHERE (line.account_id=account_account.id) | 66 | WHERE (line.account_id=account_account.id) |
1472 | 66 | AND ((reconcile_id IS NULL) | 67 | AND ((reconcile_id IS NULL) |
1473 | 67 | OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > '%s' ))) | 68 | OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > '%s' ))) |
1474 | 68 | AND (line.partner_id=res_partner.id) | 69 | AND (line.partner_id=res_partner.id) |
1475 | 69 | AND (account_account.company_id = %s) | 70 | AND (account_account.company_id = %s) |
1476 | 70 | ORDER BY res_partner.name""" % (form['date1'],form['company_id'])) | 71 | ORDER BY res_partner.name""" % (form['date1'],form['company_id'])) |
1477 | 71 | partners = self.cr.dictfetchall() | 72 | partners = self.cr.dictfetchall() |
1478 | 72 | ## mise a 0 du total | 73 | ## mise a 0 du total |
1479 | 73 | for i in range(7): | 74 | for i in range(7): |
1480 | 74 | self.total_account.append(0) | 75 | self.total_account.append(0) |
1481 | 75 | # | 76 | |
1482 | 76 | 77 | partner_ids = tuple(map(attrgetter('id'), partners)) | |
1483 | 77 | # Build a string like (1,2,3) for easy use in SQL query | 78 | # This dictionary will store the debit-credit for all partners, using partner_id as key. |
1484 | 78 | partner_ids = '(' + ','.join( [str(x['id']) for x in partners] ) + ')' | 79 | totals = {} |
1485 | 79 | 80 | self.cr.execute("""SELECT partner_id, SUM(debit-credit) | |
1486 | 80 | # This dictionary will store the debit-credit for all partners, using partner_id as key. | 81 | FROM account_move_line AS line, account_account |
1487 | 81 | totals = {} | 82 | WHERE (line.account_id = account_account.id) |
1488 | 82 | self.cr.execute("""SELECT partner_id, SUM(debit-credit) | 83 | AND (account_account.type IN %s) |
1489 | 83 | FROM account_move_line AS line, account_account | 84 | AND (partner_id in %s) |
1490 | 84 | WHERE (line.account_id = account_account.id) | 85 | AND ((reconcile_id IS NULL) |
1491 | 85 | AND (account_account.type IN %s) | 86 | OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s ))) |
1492 | 86 | AND (partner_id in %s) | 87 | AND (account_account.company_id = %s) |
1493 | 87 | AND ((reconcile_id IS NULL) | 88 | AND account_account.active |
1494 | 88 | OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > '%s' ))) | 89 | GROUP BY partner_id""" , ( |
1495 | 89 | AND (account_account.company_id = %s) | 90 | self.ACCOUNT_TYPE, partner_ids, |
1496 | 90 | AND account_account.active | 91 | form['date1'],form['company_id'])) |
1497 | 91 | GROUP BY partner_id""" % (self.ACCOUNT_TYPE, partner_ids,form['date1'],form['company_id'])) | 92 | t = self.cr.fetchall() |
1498 | 92 | t = self.cr.fetchall() | 93 | for i in t: |
1499 | 93 | for i in t: | 94 | totals[i[0]] = i[1] |
1500 | 94 | totals[i[0]] = i[1] | 95 | |
1501 | 95 | 96 | # This dictionary will store the future or past of all partners | |
1502 | 96 | # This dictionary will store the future or past of all partners | 97 | future_past = {} |
1503 | 97 | future_past = {} | 98 | if form['direction_selection'] == 'future': |
1504 | 98 | if form['direction_selection'] == 'future': | 99 | self.cr.execute("""SELECT partner_id, SUM(debit-credit) |
1505 | 99 | self.cr.execute("""SELECT partner_id, SUM(debit-credit) | 100 | FROM account_move_line AS line, account_account |
1506 | 100 | FROM account_move_line AS line, account_account | 101 | WHERE (line.account_id=account_account.id) |
1507 | 101 | WHERE (line.account_id=account_account.id) | 102 | AND (account_account.type IN %s) |
1508 | 102 | AND (account_account.type IN %s) | 103 | AND (COALESCE(date_maturity,date) < %s) |
1509 | 103 | AND (COALESCE(date_maturity,date) < '%s') | 104 | AND (partner_id in %s) |
1510 | 104 | AND (partner_id in %s) | 105 | AND ((reconcile_id IS NULL) |
1511 | 105 | AND ((reconcile_id IS NULL) | 106 | OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s ))) |
1512 | 106 | OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > '%s' ))) | 107 | AND (account_account.company_id = %s) |
1513 | 107 | AND (account_account.company_id = %s) | 108 | AND account_account.active |
1514 | 108 | AND account_account.active | 109 | GROUP BY partner_id""", ( |
1515 | 109 | GROUP BY partner_id"""% (self.ACCOUNT_TYPE, form['date1'], partner_ids,form['date1'], form['company_id'])) | 110 | self.ACCOUNT_TYPE, form['date1'], partner_ids, |
1516 | 110 | t = self.cr.fetchall() | 111 | form['date1'], form['company_id'])) |
1517 | 111 | for i in t: | 112 | t = self.cr.fetchall() |
1518 | 112 | future_past[i[0]] = i[1] | 113 | for i in t: |
1519 | 113 | elif form['direction_selection'] == 'past': # Using elif so people could extend without this breaking | 114 | future_past[i[0]] = i[1] |
1520 | 114 | self.cr.execute("""SELECT partner_id, SUM(debit-credit) | 115 | elif form['direction_selection'] == 'past': # Using elif so people could extend without this breaking |
1521 | 115 | FROM account_move_line AS line, account_account | 116 | self.cr.execute("""SELECT partner_id, SUM(debit-credit) |
1522 | 116 | WHERE (line.account_id=account_account.id) | 117 | FROM account_move_line AS line, account_account |
1523 | 117 | AND (account_account.type IN %s) | 118 | WHERE (line.account_id=account_account.id) |
1524 | 118 | AND (COALESCE(date_maturity,date) > '%s') | 119 | AND (account_account.type IN %s) |
1525 | 119 | AND (partner_id in %s) | 120 | AND (COALESCE(date_maturity,date) > %s) |
1526 | 120 | AND ((reconcile_id IS NULL) | 121 | AND (partner_id in %s) |
1527 | 121 | OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > '%s' ))) | 122 | AND ((reconcile_id IS NULL) |
1528 | 122 | AND (account_account.company_id = %s) | 123 | OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s ))) |
1529 | 123 | AND account_account.active | 124 | AND (account_account.company_id = %s) |
1530 | 124 | GROUP BY partner_id""" % (self.ACCOUNT_TYPE, form['date1'], partner_ids, form['date1'], form['company_id'])) | 125 | AND account_account.active |
1531 | 125 | t = self.cr.fetchall() | 126 | GROUP BY partner_id""" , ( |
1532 | 126 | for i in t: | 127 | self.ACCOUNT_TYPE, form['date1'], partner_ids, |
1533 | 127 | future_past[i[0]] = i[1] | 128 | form['date1'], form['company_id'])) |
1534 | 128 | 129 | t = self.cr.fetchall() | |
1535 | 129 | # Use one query per period and store results in history (a list variable) | 130 | for i in t: |
1536 | 130 | # Each history will contain : history[1] = {'<partner_id>': <partner_debit-credit>} | 131 | future_past[i[0]] = i[1] |
1537 | 131 | history = [] | 132 | |
1538 | 132 | for i in range(5): | 133 | # Use one query per period and store results in history (a list variable) |
1539 | 133 | self.cr.execute("""SELECT partner_id, SUM(debit-credit) | 134 | # Each history will contain : history[1] = {'<partner_id>': <partner_debit-credit>} |
1540 | 134 | FROM account_move_line AS line, account_account | 135 | history = [] |
1541 | 135 | WHERE (line.account_id=account_account.id) | 136 | for i in range(5): |
1542 | 136 | AND (account_account.type IN %s) | 137 | self.cr.execute("""SELECT partner_id, SUM(debit-credit) |
1543 | 137 | AND (COALESCE(date_maturity,date) BETWEEN '%s' AND '%s') | 138 | FROM account_move_line AS line, account_account |
1544 | 138 | AND (partner_id in %s ) | 139 | WHERE (line.account_id=account_account.id) |
1545 | 139 | AND ((reconcile_id IS NULL) | 140 | AND (account_account.type IN %s) |
1546 | 140 | OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > '%s' ))) | 141 | AND (COALESCE(date_maturity,date) BETWEEN %s AND %s) |
1547 | 141 | AND (account_account.company_id = %s) | 142 | AND (partner_id in %s ) |
1548 | 142 | AND account_account.active | 143 | AND ((reconcile_id IS NULL) |
1549 | 143 | GROUP BY partner_id""" % (self.ACCOUNT_TYPE, form[str(i)]['start'], form[str(i)]['stop'],partner_ids ,form['date1'] ,form['company_id'])) | 144 | OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s ))) |
1550 | 144 | 145 | AND (account_account.company_id = %s) | |
1551 | 145 | t = self.cr.fetchall() | 146 | AND account_account.active |
1552 | 146 | d = {} | 147 | GROUP BY partner_id""" , ( |
1553 | 147 | for i in t: | 148 | self.ACCOUNT_TYPE, form[str(i)]['start'], form[str(i)]['stop'], |
1554 | 148 | d[i[0]] = i[1] | 149 | partner_ids ,form['date1'] ,form['company_id'])) |
1555 | 149 | history.append(d) | 150 | |
1556 | 150 | 151 | t = self.cr.fetchall() | |
1557 | 151 | for partner in partners: | 152 | d = {} |
1558 | 152 | values = {} | 153 | for i in t: |
1559 | 153 | ## If choise selection is in the future | 154 | d[i[0]] = i[1] |
1560 | 154 | if form['direction_selection'] == 'future': | 155 | history.append(d) |
1561 | 155 | # Query here is replaced by one query which gets the all the partners their 'before' value | 156 | |
1562 | 156 | before = False | 157 | for partner in partners: |
1563 | 157 | if future_past.has_key(partner['id']): | 158 | values = {} |
1564 | 158 | before = [ future_past[partner['id']] ] | 159 | ## If choise selection is in the future |
1565 | 159 | 160 | if form['direction_selection'] == 'future': | |
1566 | 160 | self.total_account[6] = self.total_account[6] + (before and before[0] or 0.0) | 161 | # Query here is replaced by one query which gets the all the partners their 'before' value |
1567 | 161 | 162 | before = False | |
1568 | 162 | values['direction'] = before and before[0] or 0.0 | 163 | if future_past.has_key(partner['id']): |
1569 | 163 | elif form['direction_selection'] == 'past': # Changed this so people could in the future create new direction_selections | 164 | before = [ future_past[partner['id']] ] |
1570 | 164 | # Query here is replaced by one query which gets the all the partners their 'after' value | 165 | |
1571 | 165 | after = False | 166 | self.total_account[6] = self.total_account[6] + (before and before[0] or 0.0) |
1572 | 166 | if future_past.has_key(partner['id']): # Making sure this partner actually was found by the query | 167 | |
1573 | 167 | after = [ future_past[partner['id']] ] | 168 | values['direction'] = before and before[0] or 0.0 |
1574 | 168 | 169 | elif form['direction_selection'] == 'past': # Changed this so people could in the future create new direction_selections | |
1575 | 169 | self.total_account[6] = self.total_account[6] + (after and after[0] or 0.0) | 170 | # Query here is replaced by one query which gets the all the partners their 'after' value |
1576 | 170 | values['direction'] = after and after[0] or "" | 171 | after = False |
1577 | 171 | 172 | if future_past.has_key(partner['id']): # Making sure this partner actually was found by the query | |
1578 | 172 | for i in range(5): | 173 | after = [ future_past[partner['id']] ] |
1579 | 173 | during = False | 174 | |
1580 | 174 | if history[i].has_key(partner['id']): | 175 | self.total_account[6] = self.total_account[6] + (after and after[0] or 0.0) |
1581 | 175 | during = [ history[i][partner['id']] ] | 176 | values['direction'] = after and after[0] or "" |
1582 | 176 | # Ajout du compteur | 177 | |
1583 | 177 | self.total_account[(i)] = self.total_account[(i)] + (during and during[0] or 0) | 178 | for i in range(5): |
1584 | 178 | values[str(i)] = during and during[0] or "" | 179 | during = False |
1585 | 179 | 180 | if history[i].has_key(partner['id']): | |
1586 | 180 | total = False | 181 | during = [ history[i][partner['id']] ] |
1587 | 181 | if totals.has_key( partner['id'] ): | 182 | # Ajout du compteur |
1588 | 182 | total = [ totals[partner['id']] ] | 183 | self.total_account[(i)] = self.total_account[(i)] + (during and during[0] or 0) |
1589 | 183 | values['total'] = total and total[0] or 0.0 | 184 | values[str(i)] = during and during[0] or "" |
1590 | 184 | ## Add for total | 185 | |
1591 | 185 | self.total_account[(i+1)] = self.total_account[(i+1)] + (total and total[0] or 0.0) | 186 | total = False |
1592 | 186 | values['name'] = partner['name'] | 187 | if totals.has_key( partner['id'] ): |
1593 | 187 | #t = 0.0 | 188 | total = [ totals[partner['id']] ] |
1594 | 188 | #for i in range(5)+['direction']: | 189 | values['total'] = total and total[0] or 0.0 |
1595 | 189 | # t+= float(values.get(str(i), 0.0) or 0.0) | 190 | ## Add for total |
1596 | 190 | #values['total'] = t | 191 | self.total_account[(i+1)] = self.total_account[(i+1)] + (total and total[0] or 0.0) |
1597 | 191 | 192 | values['name'] = partner['name'] | |
1598 | 192 | if values['total']: | 193 | #t = 0.0 |
1599 | 193 | res.append(values) | 194 | #for i in range(5)+['direction']: |
1600 | 194 | 195 | # t+= float(values.get(str(i), 0.0) or 0.0) | |
1601 | 195 | total = 0.0 | 196 | #values['total'] = t |
1602 | 196 | totals = {} | 197 | |
1603 | 197 | for r in res: | 198 | if values['total']: |
1604 | 198 | total += float(r['total'] or 0.0) | 199 | res.append(values) |
1605 | 199 | for i in range(5)+['direction']: | 200 | |
1606 | 200 | totals.setdefault(str(i), 0.0) | 201 | total = 0.0 |
1607 | 201 | totals[str(i)] += float(r[str(i)] or 0.0) | 202 | totals = {} |
1608 | 202 | return res | 203 | for r in res: |
1609 | 203 | 204 | total += float(r['total'] or 0.0) | |
1610 | 204 | def _get_total(self,pos): | 205 | for i in range(5)+['direction']: |
1611 | 205 | period = self.total_account[int(pos)] | 206 | totals.setdefault(str(i), 0.0) |
1612 | 206 | return period | 207 | totals[str(i)] += float(r[str(i)] or 0.0) |
1613 | 207 | 208 | return res | |
1614 | 208 | def _get_direction(self,pos): | 209 | |
1615 | 209 | period = self.total_account[int(pos)] | 210 | def _get_total(self,pos): |
1616 | 210 | return period | 211 | period = self.total_account[int(pos)] |
1617 | 211 | 212 | return period | |
1618 | 212 | def _get_for_period(self,pos): | 213 | |
1619 | 213 | period = self.total_account[int(pos)] | 214 | def _get_direction(self,pos): |
1620 | 214 | return period | 215 | period = self.total_account[int(pos)] |
1621 | 215 | 216 | return period | |
1622 | 216 | def _get_company(self, form): | 217 | |
1623 | 217 | return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).name | 218 | def _get_for_period(self,pos): |
1624 | 218 | 219 | period = self.total_account[int(pos)] | |
1625 | 219 | def _get_currency(self, form): | 220 | return period |
1626 | 220 | return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).currency_id.name | 221 | |
1627 | 222 | def _get_company(self, form): | ||
1628 | 223 | return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).name | ||
1629 | 224 | |||
1630 | 225 | def _get_currency(self, form): | ||
1631 | 226 | return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).currency_id.name | ||
1632 | 221 | 227 | ||
1633 | 222 | 228 | ||
1634 | 223 | report_sxw.report_sxw('report.account.aged_trial_balance', 'res.partner', | 229 | report_sxw.report_sxw('report.account.aged_trial_balance', 'res.partner', |
1636 | 224 | 'addons/account/report/aged_trial_balance.rml',parser=aged_trial_report,header=False) | 230 | 'addons/account/report/aged_trial_balance.rml',parser=aged_trial_report,header=False) |
1637 | 225 | 231 | ||
1638 | 226 | 232 | ||
1639 | 227 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | 233 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
1640 | 228 | 234 | ||
1641 | === modified file 'account/report/general_journal.py' | |||
1642 | --- account/report/general_journal.py 2009-10-09 11:49:00 +0000 | |||
1643 | +++ account/report/general_journal.py 2010-03-17 11:50:49 +0000 | |||
1644 | @@ -19,7 +19,7 @@ | |||
1645 | 19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1646 | 20 | # | 20 | # |
1647 | 21 | ############################################################################## | 21 | ############################################################################## |
1649 | 22 | 22 | from operator import itemgetter | |
1650 | 23 | import pooler | 23 | import pooler |
1651 | 24 | import time | 24 | import time |
1652 | 25 | from report import report_sxw | 25 | from report import report_sxw |
1653 | @@ -42,10 +42,12 @@ | |||
1654 | 42 | 42 | ||
1655 | 43 | def set_context(self, objects, data, ids, report_type = None): | 43 | def set_context(self, objects, data, ids, report_type = None): |
1656 | 44 | super(journal_print, self).set_context(objects, data, ids, report_type) | 44 | super(journal_print, self).set_context(objects, data, ids, report_type) |
1658 | 45 | self.cr.execute('select period_id, journal_id from account_journal_period where id in (' + ','.join([str(id) for id in ids]) + ')') | 45 | self.cr.execute('SELECT period_id, journal_id ' |
1659 | 46 | 'FROM account_journal_period ' | ||
1660 | 47 | 'WHERE id IN %s', | ||
1661 | 48 | (tuple(ids),)) | ||
1662 | 46 | res = self.cr.fetchall() | 49 | res = self.cr.fetchall() |
1665 | 47 | self.period_ids = ','.join([str(x[0]) for x in res]) | 50 | self.period_ids, self.journal_ids = zip(*res) |
1664 | 48 | self.journal_ids = ','.join([str(x[1]) for x in res]) | ||
1666 | 49 | 51 | ||
1667 | 50 | # returns a list of period objs | 52 | # returns a list of period objs |
1668 | 51 | def periods(self, journal_period_objs): | 53 | def periods(self, journal_period_objs): |
1669 | @@ -75,7 +77,14 @@ | |||
1670 | 75 | periods.append(data.period_id.id) | 77 | periods.append(data.period_id.id) |
1671 | 76 | for period in periods: | 78 | for period in periods: |
1672 | 77 | period_data = self.pool.get('account.period').browse(self.cr, self.uid, period) | 79 | period_data = self.pool.get('account.period').browse(self.cr, self.uid, period) |
1674 | 78 | self.cr.execute('select j.code, j.name, sum(l.debit) as debit, sum(l.credit) as credit from account_move_line l left join account_journal j on (l.journal_id=j.id) where period_id=%s and journal_id in (' + ','.join(map(str, journal_id)) + ') and l.state<>\'draft\' group by j.id, j.code, j.name', (period,)) | 80 | self.cr.execute( |
1675 | 81 | 'SELECT j.code, j.name, ' | ||
1676 | 82 | 'SUM(l.debit) AS debit, SUM(l.credit) AS credit ' | ||
1677 | 83 | 'FROM account_move_line l ' | ||
1678 | 84 | 'LEFT JOIN account_journal j ON (l.journal_id=j.id) ' | ||
1679 | 85 | 'WHERE period_id=%s AND journal_id IN %s ' | ||
1680 | 86 | 'AND l.state<>\'draft\' ' | ||
1681 | 87 | 'GROUP BY j.id, j.code, j.name', (period, tuple(journal_id))) | ||
1682 | 79 | res = self.cr.dictfetchall() | 88 | res = self.cr.dictfetchall() |
1683 | 80 | res[0].update({'period_name':period_data.name}) | 89 | res[0].update({'period_name':period_data.name}) |
1684 | 81 | res[0].update({'pid':period}) | 90 | res[0].update({'pid':period}) |
1685 | @@ -83,45 +92,59 @@ | |||
1686 | 83 | return lines_data | 92 | return lines_data |
1687 | 84 | if not self.journal_ids: | 93 | if not self.journal_ids: |
1688 | 85 | return [] | 94 | return [] |
1690 | 86 | self.cr.execute('select j.code, j.name, sum(l.debit) as debit, sum(l.credit) as credit from account_move_line l left join account_journal j on (l.journal_id=j.id) where period_id=%s and journal_id in (' + self.journal_ids + ') and l.state<>\'draft\' group by j.id, j.code, j.name', (period_id,)) | 95 | self.cr.execute('SELECT j.code, j.name, ' |
1691 | 96 | 'SUM(l.debit) AS debit, SUM(l.credit) AS credit ' | ||
1692 | 97 | 'FROM account_move_line l ' | ||
1693 | 98 | 'LEFT JOIN account_journal j ON (l.journal_id=j.id) ' | ||
1694 | 99 | 'WHERE period_id=%s AND journal_id IN %s ' | ||
1695 | 100 | 'AND l.state<>\'draft\' ' | ||
1696 | 101 | 'GROUP BY j.id, j.code, j.name' | ||
1697 | 102 | (period_id,tuple(self.journal_ids))) | ||
1698 | 87 | res = self.cr.dictfetchall() | 103 | res = self.cr.dictfetchall() |
1699 | 88 | return res | 104 | return res |
1700 | 89 | 105 | ||
1701 | 90 | def _sum_debit_period(self, period_id,journal_id=None): | 106 | def _sum_debit_period(self, period_id,journal_id=None): |
1706 | 91 | if type(journal_id)==type([]): | 107 | journals = journal_id or self.journal_ids |
1707 | 92 | self.cr.execute('select sum(debit) from account_move_line where period_id=%s and journal_id in (' + ','.join(map(str, journal_id)) + ') and state<>\'draft\'', (period_id,)) | 108 | if not journals: |
1704 | 93 | return self.cr.fetchone()[0] or 0.0 | ||
1705 | 94 | if not self.journal_ids: | ||
1708 | 95 | return 0.0 | 109 | return 0.0 |
1711 | 96 | self.cr.execute('select sum(debit) from account_move_line where period_id=%s and journal_id in (' + self.journal_ids + ') and state<>\'draft\'', (period_id,)) | 110 | self.cr.execute('SELECT SUM(debit) FROM account_move_line ' |
1712 | 97 | 111 | 'WHERE period_id=%s AND journal_id IN %s ' | |
1713 | 112 | 'AND state<>\'draft\'', | ||
1714 | 113 | (period_id, tuple(journals))) | ||
1715 | 98 | return self.cr.fetchone()[0] or 0.0 | 114 | return self.cr.fetchone()[0] or 0.0 |
1716 | 99 | 115 | ||
1717 | 100 | def _sum_credit_period(self, period_id,journal_id=None): | 116 | def _sum_credit_period(self, period_id,journal_id=None): |
1722 | 101 | if type(journal_id)==type([]): | 117 | journals = journal_id or self.journal_ids |
1723 | 102 | self.cr.execute('select sum(credit) from account_move_line where period_id=%s and journal_id in (' + ','.join(map(str, journal_id)) + ') and state<>\'draft\'', (period_id,)) | 118 | if not journals: |
1720 | 103 | return self.cr.fetchone()[0] or 0.0 | ||
1721 | 104 | if not self.journal_ids: | ||
1724 | 105 | return 0.0 | 119 | return 0.0 |
1726 | 106 | self.cr.execute('select sum(credit) from account_move_line where period_id=%s and journal_id in (' + self.journal_ids + ') and state<>\'draft\'', (period_id,)) | 120 | self.cr.execute('SELECT SUM(credit) FROM account_move_line ' |
1727 | 121 | 'WHERE period_id=%s AND journal_id IN %s ' | ||
1728 | 122 | 'AND state<>\'draft\'', | ||
1729 | 123 | (period_id,tuple(journals))) | ||
1730 | 107 | return self.cr.fetchone()[0] or 0.0 | 124 | return self.cr.fetchone()[0] or 0.0 |
1731 | 108 | 125 | ||
1732 | 109 | def _sum_debit(self,period_id=None,journal_id=None): | 126 | def _sum_debit(self,period_id=None,journal_id=None): |
1737 | 110 | if type(period_id)==type([]): | 127 | journals = journal_id or self.journal_ids |
1738 | 111 | self.cr.execute('select sum(debit) from account_move_line where period_id in (' + ','.join(map(str, period_id)) + ') and journal_id in (' + ','.join(map(str, journal_id)) + ') and state<>\'draft\'') | 128 | periods = period_id or self.period_ids |
1739 | 112 | return self.cr.fetchone()[0] or 0.0 | 129 | if not (journals and periods): |
1736 | 113 | if not self.journal_ids or not self.period_ids: | ||
1740 | 114 | return 0.0 | 130 | return 0.0 |
1742 | 115 | self.cr.execute('select sum(debit) from account_move_line where period_id in (' + self.period_ids + ') and journal_id in (' + self.journal_ids + ') and state<>\'draft\'') | 131 | self.cr.execute('SELECT SUM(debit) FROM account_move_line ' |
1743 | 132 | 'WHERE period_id IN %s ' | ||
1744 | 133 | 'AND journal_id IN %s ' | ||
1745 | 134 | 'AND state<>\'draft\'', | ||
1746 | 135 | (tuple(periods), tuple(journals))) | ||
1747 | 116 | return self.cr.fetchone()[0] or 0.0 | 136 | return self.cr.fetchone()[0] or 0.0 |
1748 | 117 | 137 | ||
1749 | 118 | def _sum_credit(self,period_id=None,journal_id=None): | 138 | def _sum_credit(self,period_id=None,journal_id=None): |
1754 | 119 | if type(period_id)==type([]): | 139 | periods = period_id or self.period_ids |
1755 | 120 | self.cr.execute('select sum(credit) from account_move_line where period_id in (' + ','.join(map(str, period_id)) + ') and journal_id in (' + ','.join(map(str, journal_id)) + ') and state<>\'draft\'') | 140 | journals = journal_id or self.journal_ids |
1756 | 121 | return self.cr.fetchone()[0] or 0.0 | 141 | if not (periods and journals): |
1753 | 122 | if not self.journal_ids or not self.period_ids: | ||
1757 | 123 | return 0.0 | 142 | return 0.0 |
1759 | 124 | self.cr.execute('select sum(credit) from account_move_line where period_id in (' + self.period_ids + ') and journal_id in (' + self.journal_ids + ') and state<>\'draft\'') | 143 | self.cr.execute('SELECT SUM(credit) FROM account_move_line ' |
1760 | 144 | 'WHERE period_id IN %s ' | ||
1761 | 145 | 'AND journal_id IN %s ' | ||
1762 | 146 | 'AND state<>\'draft\'', | ||
1763 | 147 | (tuple(periods), tuple(journals))) | ||
1764 | 125 | return self.cr.fetchone()[0] or 0.0 | 148 | return self.cr.fetchone()[0] or 0.0 |
1765 | 126 | report_sxw.report_sxw('report.account.general.journal', 'account.journal.period', 'addons/account/report/general_journal.rml',parser=journal_print) | 149 | report_sxw.report_sxw('report.account.general.journal', 'account.journal.period', 'addons/account/report/general_journal.rml',parser=journal_print) |
1766 | 127 | report_sxw.report_sxw('report.account.general.journal.wiz', 'account.journal.period', 'addons/account/report/wizard_general_journal.rml',parser=journal_print, header=False) | 150 | report_sxw.report_sxw('report.account.general.journal.wiz', 'account.journal.period', 'addons/account/report/wizard_general_journal.rml',parser=journal_print, header=False) |
1767 | 128 | 151 | ||
1768 | === modified file 'account/report/general_ledger.py' | |||
1769 | --- account/report/general_ledger.py 2010-01-18 07:47:33 +0000 | |||
1770 | +++ account/report/general_ledger.py 2010-03-17 11:50:49 +0000 | |||
1771 | @@ -123,14 +123,15 @@ | |||
1772 | 123 | periods = form['periods'][0][2] | 123 | periods = form['periods'][0][2] |
1773 | 124 | if not periods: | 124 | if not periods: |
1774 | 125 | sql = """ | 125 | sql = """ |
1776 | 126 | Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = """ + str(form['fiscalyear']) + """ | 126 | Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = %s |
1777 | 127 | """ | 127 | """ |
1778 | 128 | sqlargs = (form['fiscalyear'],) | ||
1779 | 128 | else: | 129 | else: |
1780 | 129 | periods_id = ','.join(map(str, periods)) | ||
1781 | 130 | sql = """ | 130 | sql = """ |
1783 | 131 | Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id in ( """ + periods_id + """) | 131 | Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id in %s |
1784 | 132 | """ | 132 | """ |
1786 | 133 | self.cr.execute(sql) | 133 | sqlargs = (tuple(periods),) |
1787 | 134 | self.cr.execute(sql, sqlargs) | ||
1788 | 134 | res = self.cr.dictfetchall() | 135 | res = self.cr.dictfetchall() |
1789 | 135 | borne_min = res[0]['start_date'] | 136 | borne_min = res[0]['start_date'] |
1790 | 136 | borne_max = res[0]['stop_date'] | 137 | borne_max = res[0]['stop_date'] |
1791 | @@ -141,14 +142,21 @@ | |||
1792 | 141 | periods = form['periods'][0][2] | 142 | periods = form['periods'][0][2] |
1793 | 142 | if not periods: | 143 | if not periods: |
1794 | 143 | sql = """ | 144 | sql = """ |
1796 | 144 | Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = """ + str(form['fiscalyear']) + """ | 145 | SELECT MIN(p.date_start) AS start_date, |
1797 | 146 | MAX(p.date_stop) AS stop_date | ||
1798 | 147 | FROM account_period AS p | ||
1799 | 148 | WHERE p.fiscalyear_id = %s | ||
1800 | 145 | """ | 149 | """ |
1801 | 150 | sqlargs = (form['fiscalyear'],) | ||
1802 | 146 | else: | 151 | else: |
1803 | 147 | periods_id = ','.join(map(str, periods)) | ||
1804 | 148 | sql = """ | 152 | sql = """ |
1806 | 149 | Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id in ( """ + periods_id + """) | 153 | SELECT MIN(p.date_start) AS start_date, |
1807 | 154 | MAX(p.date_stop) AS stop_date | ||
1808 | 155 | FROM account_period AS p | ||
1809 | 156 | WHERE p.id IN %s | ||
1810 | 150 | """ | 157 | """ |
1812 | 151 | self.cr.execute(sql) | 158 | sqlargs = (tuple(periods),) |
1813 | 159 | self.cr.execute(sql, sqlargs) | ||
1814 | 152 | res = self.cr.dictfetchall() | 160 | res = self.cr.dictfetchall() |
1815 | 153 | period_min = res[0]['start_date'] | 161 | period_min = res[0]['start_date'] |
1816 | 154 | period_max = res[0]['stop_date'] | 162 | period_max = res[0]['stop_date'] |
1817 | @@ -232,8 +240,12 @@ | |||
1818 | 232 | else: | 240 | else: |
1819 | 233 | ## We will now compute solde initiaux | 241 | ## We will now compute solde initiaux |
1820 | 234 | for move in res: | 242 | for move in res: |
1823 | 235 | SOLDEINIT = "SELECT sum(l.debit) AS sum_debit, sum(l.credit) AS sum_credit FROM account_move_line l WHERE l.account_id = " + str(move.id) + " AND l.date < '" + self.borne_date['max_date'] + "'" + " AND l.date > '" + self.borne_date['min_date'] + "'" | 243 | SOLDEINIT = "SELECT SUM(l.debit) AS sum_debit,"\ |
1824 | 236 | self.cr.execute(SOLDEINIT) | 244 | " SUM(l.credit) AS sum_credit "\ |
1825 | 245 | "FROM account_move_line l "\ | ||
1826 | 246 | "WHERE l.account_id = %s "\ | ||
1827 | 247 | "AND l.date < %s AND l.date > %s" | ||
1828 | 248 | self.cr.execute(SOLDEINIT, (move.id, self.borne_date['max_date'],self.borne_date['min_date'])) | ||
1829 | 237 | resultat = self.cr.dictfetchall() | 249 | resultat = self.cr.dictfetchall() |
1830 | 238 | if resultat[0] : | 250 | if resultat[0] : |
1831 | 239 | if resultat[0]['sum_debit'] == None: | 251 | if resultat[0]['sum_debit'] == None: |
1832 | @@ -354,7 +366,8 @@ | |||
1833 | 354 | return 0.0 | 366 | return 0.0 |
1834 | 355 | self.cr.execute("SELECT sum(debit) "\ | 367 | self.cr.execute("SELECT sum(debit) "\ |
1835 | 356 | "FROM account_move_line l "\ | 368 | "FROM account_move_line l "\ |
1837 | 357 | "WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query) | 369 | "WHERE l.account_id in %s AND "+self.query, |
1838 | 370 | (tuple(self.child_ids),)) | ||
1839 | 358 | sum_debit = self.cr.fetchone()[0] or 0.0 | 371 | sum_debit = self.cr.fetchone()[0] or 0.0 |
1840 | 359 | return sum_debit | 372 | return sum_debit |
1841 | 360 | 373 | ||
1842 | @@ -363,7 +376,8 @@ | |||
1843 | 363 | return 0.0 | 376 | return 0.0 |
1844 | 364 | self.cr.execute("SELECT sum(credit) "\ | 377 | self.cr.execute("SELECT sum(credit) "\ |
1845 | 365 | "FROM account_move_line l "\ | 378 | "FROM account_move_line l "\ |
1847 | 366 | "WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query) | 379 | "WHERE l.account_id in %s AND "+self.query, |
1848 | 380 | (tuple(self.child_ids),)) | ||
1849 | 367 | ## Add solde init to the result | 381 | ## Add solde init to the result |
1850 | 368 | # | 382 | # |
1851 | 369 | sum_credit = self.cr.fetchone()[0] or 0.0 | 383 | sum_credit = self.cr.fetchone()[0] or 0.0 |
1852 | @@ -374,7 +388,8 @@ | |||
1853 | 374 | return 0.0 | 388 | return 0.0 |
1854 | 375 | self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\ | 389 | self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\ |
1855 | 376 | "FROM account_move_line l "\ | 390 | "FROM account_move_line l "\ |
1857 | 377 | "WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query) | 391 | "WHERE l.account_id in %s AND "+self.query, |
1858 | 392 | (tuple(self.child_ids),)) | ||
1859 | 378 | sum_solde = self.cr.fetchone()[0] or 0.0 | 393 | sum_solde = self.cr.fetchone()[0] or 0.0 |
1860 | 379 | return sum_solde | 394 | return sum_solde |
1861 | 380 | 395 | ||
1862 | 381 | 396 | ||
1863 | === modified file 'account/report/general_ledger_landscape.py' | |||
1864 | --- account/report/general_ledger_landscape.py 2010-01-18 07:47:33 +0000 | |||
1865 | +++ account/report/general_ledger_landscape.py 2010-03-17 11:50:49 +0000 | |||
1866 | @@ -122,14 +122,15 @@ | |||
1867 | 122 | periods = form['periods'][0][2] | 122 | periods = form['periods'][0][2] |
1868 | 123 | if not periods: | 123 | if not periods: |
1869 | 124 | sql = """ | 124 | sql = """ |
1871 | 125 | Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = """ + str(form['fiscalyear']) + """ | 125 | Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = %s |
1872 | 126 | """ | 126 | """ |
1873 | 127 | sqlargs = (form['fiscalyear'],) | ||
1874 | 127 | else: | 128 | else: |
1875 | 128 | periods_id = ','.join(map(str, periods)) | ||
1876 | 129 | sql = """ | 129 | sql = """ |
1878 | 130 | Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id in ( """ + periods_id + """) | 130 | Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id in %s |
1879 | 131 | """ | 131 | """ |
1881 | 132 | self.cr.execute(sql) | 132 | sqlargs = (tuple(periods),) |
1882 | 133 | self.cr.execute(sql, sqlargs) | ||
1883 | 133 | res = self.cr.dictfetchall() | 134 | res = self.cr.dictfetchall() |
1884 | 134 | borne_min = res[0]['start_date'] | 135 | borne_min = res[0]['start_date'] |
1885 | 135 | borne_max = res[0]['stop_date'] | 136 | borne_max = res[0]['stop_date'] |
1886 | @@ -140,14 +141,15 @@ | |||
1887 | 140 | periods = form['periods'][0][2] | 141 | periods = form['periods'][0][2] |
1888 | 141 | if not periods: | 142 | if not periods: |
1889 | 142 | sql = """ | 143 | sql = """ |
1891 | 143 | Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = """ + str(form['fiscalyear']) + """ | 144 | Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = %s |
1892 | 144 | """ | 145 | """ |
1893 | 146 | sqlargs = (form['fiscalyear'],) | ||
1894 | 145 | else: | 147 | else: |
1895 | 146 | periods_id = ','.join(map(str, periods)) | ||
1896 | 147 | sql = """ | 148 | sql = """ |
1898 | 148 | Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id in ( """ + periods_id + """) | 149 | Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id in %s |
1899 | 149 | """ | 150 | """ |
1901 | 150 | self.cr.execute(sql) | 151 | sqlargs = (tuple(periods),) |
1902 | 152 | self.cr.execute(sql, sqlargs) | ||
1903 | 151 | res = self.cr.dictfetchall() | 153 | res = self.cr.dictfetchall() |
1904 | 152 | period_min = res[0]['start_date'] | 154 | period_min = res[0]['start_date'] |
1905 | 153 | period_max = res[0]['stop_date'] | 155 | period_max = res[0]['stop_date'] |
1906 | @@ -233,8 +235,8 @@ | |||
1907 | 233 | else: | 235 | else: |
1908 | 234 | ## We will now compute solde initiaux | 236 | ## We will now compute solde initiaux |
1909 | 235 | for move in res: | 237 | for move in res: |
1912 | 236 | SOLDEINIT = "SELECT sum(l.debit) AS sum_debit, sum(l.credit) AS sum_credit FROM account_move_line l WHERE l.account_id = " + str(move.id) + " AND l.date < '" + self.borne_date['max_date'] + "'" + " AND l.date > '" + self.borne_date['min_date'] + "'" | 238 | SOLDEINIT = "SELECT sum(l.debit) AS sum_debit, sum(l.credit) AS sum_credit FROM account_move_line l WHERE l.account_id = %s AND l.date < %s AND l.date > %s" |
1913 | 237 | self.cr.execute(SOLDEINIT) | 239 | self.cr.execute(SOLDEINIT, (move.id, self.borne_date['max_date'], self.borne_date['min_date'])) |
1914 | 238 | resultat = self.cr.dictfetchall() | 240 | resultat = self.cr.dictfetchall() |
1915 | 239 | if resultat[0] : | 241 | if resultat[0] : |
1916 | 240 | if resultat[0]['sum_debit'] == None: | 242 | if resultat[0]['sum_debit'] == None: |
1917 | @@ -287,7 +289,7 @@ | |||
1918 | 287 | for l in res: | 289 | for l in res: |
1919 | 288 | line = self.pool.get('account.move.line').browse(self.cr, self.uid, l['id']) | 290 | line = self.pool.get('account.move.line').browse(self.cr, self.uid, l['id']) |
1920 | 289 | l['move'] = line.move_id.name | 291 | l['move'] = line.move_id.name |
1922 | 290 | self.cr.execute('Select id from account_invoice where move_id =%s'%(line.move_id.id)) | 292 | self.cr.execute('Select id from account_invoice where move_id =%s',(line.move_id.id,)) |
1923 | 291 | tmpres = self.cr.dictfetchall() | 293 | tmpres = self.cr.dictfetchall() |
1924 | 292 | if len(tmpres) > 0 : | 294 | if len(tmpres) > 0 : |
1925 | 293 | inv = self.pool.get('account.invoice').browse(self.cr, self.uid, tmpres[0]['id']) | 295 | inv = self.pool.get('account.invoice').browse(self.cr, self.uid, tmpres[0]['id']) |
1926 | @@ -355,7 +357,8 @@ | |||
1927 | 355 | return 0.0 | 357 | return 0.0 |
1928 | 356 | self.cr.execute("SELECT sum(debit) "\ | 358 | self.cr.execute("SELECT sum(debit) "\ |
1929 | 357 | "FROM account_move_line l "\ | 359 | "FROM account_move_line l "\ |
1931 | 358 | "WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query) | 360 | "WHERE l.account_id in %s AND "+self.query, |
1932 | 361 | (tuple(self.child_ids),)) | ||
1933 | 359 | sum_debit = self.cr.fetchone()[0] or 0.0 | 362 | sum_debit = self.cr.fetchone()[0] or 0.0 |
1934 | 360 | return sum_debit | 363 | return sum_debit |
1935 | 361 | 364 | ||
1936 | @@ -364,7 +367,8 @@ | |||
1937 | 364 | return 0.0 | 367 | return 0.0 |
1938 | 365 | self.cr.execute("SELECT sum(credit) "\ | 368 | self.cr.execute("SELECT sum(credit) "\ |
1939 | 366 | "FROM account_move_line l "\ | 369 | "FROM account_move_line l "\ |
1941 | 367 | "WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query) | 370 | "WHERE l.account_id in %s AND "+self.query, |
1942 | 371 | (tuple(self.child_ids),)) | ||
1943 | 368 | ## Add solde init to the result | 372 | ## Add solde init to the result |
1944 | 369 | # | 373 | # |
1945 | 370 | sum_credit = self.cr.fetchone()[0] or 0.0 | 374 | sum_credit = self.cr.fetchone()[0] or 0.0 |
1946 | @@ -375,7 +379,8 @@ | |||
1947 | 375 | return 0.0 | 379 | return 0.0 |
1948 | 376 | self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\ | 380 | self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\ |
1949 | 377 | "FROM account_move_line l "\ | 381 | "FROM account_move_line l "\ |
1951 | 378 | "WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query) | 382 | "WHERE l.account_id in %s AND "+self.query, |
1952 | 383 | (tuple(self.child_ids),)) | ||
1953 | 379 | sum_solde = self.cr.fetchone()[0] or 0.0 | 384 | sum_solde = self.cr.fetchone()[0] or 0.0 |
1954 | 380 | return sum_solde | 385 | return sum_solde |
1955 | 381 | 386 | ||
1956 | 382 | 387 | ||
1957 | === modified file 'account/report/partner_balance.py' | |||
1958 | --- account/report/partner_balance.py 2009-10-09 11:49:00 +0000 | |||
1959 | +++ account/report/partner_balance.py 2010-03-17 11:50:49 +0000 | |||
1960 | @@ -30,7 +30,6 @@ | |||
1961 | 30 | def __init__(self, cr, uid, name, context): | 30 | def __init__(self, cr, uid, name, context): |
1962 | 31 | super(partner_balance, self).__init__(cr, uid, name, context=context) | 31 | super(partner_balance, self).__init__(cr, uid, name, context=context) |
1963 | 32 | self.date_lst = [] | 32 | self.date_lst = [] |
1964 | 33 | self.date_lst_string = '' | ||
1965 | 34 | self.account_ids = '' | 33 | self.account_ids = '' |
1966 | 35 | self.localcontext.update( { | 34 | self.localcontext.update( { |
1967 | 36 | 'time': time, | 35 | 'time': time, |
1968 | @@ -164,29 +163,23 @@ | |||
1969 | 164 | 163 | ||
1970 | 165 | self.transform_both_into_date_array(data) | 164 | self.transform_both_into_date_array(data) |
1971 | 166 | 165 | ||
1972 | 167 | ## | ||
1973 | 168 | self.date_lst_string ='' | ||
1974 | 169 | if self.date_lst: | ||
1975 | 170 | self.date_lst_string = '\'' + '\',\''.join(map(str,self.date_lst)) + '\'' | ||
1976 | 171 | |||
1977 | 172 | |||
1978 | 173 | ## Compute Code | 166 | ## Compute Code |
1979 | 174 | account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') | 167 | account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') |
1980 | 175 | # | 168 | # |
1981 | 176 | if (data['form']['result_selection'] == 'customer' ): | 169 | if (data['form']['result_selection'] == 'customer' ): |
1983 | 177 | self.ACCOUNT_TYPE = "('receivable')" | 170 | self.ACCOUNT_TYPE = ('receivable',) |
1984 | 178 | elif (data['form']['result_selection'] == 'supplier'): | 171 | elif (data['form']['result_selection'] == 'supplier'): |
1986 | 179 | self.ACCOUNT_TYPE = "('payable')" | 172 | self.ACCOUNT_TYPE = ('payable',) |
1987 | 180 | else: | 173 | else: |
1989 | 181 | self.ACCOUNT_TYPE = "('payable','receivable')" | 174 | self.ACCOUNT_TYPE = ('payable','receivable') |
1990 | 182 | # | 175 | # |
1991 | 183 | self.cr.execute("SELECT a.id " \ | 176 | self.cr.execute("SELECT a.id " \ |
1992 | 184 | "FROM account_account a " \ | 177 | "FROM account_account a " \ |
1993 | 185 | "LEFT JOIN account_account_type t " \ | 178 | "LEFT JOIN account_account_type t " \ |
1994 | 186 | "ON (a.type = t.code) " \ | 179 | "ON (a.type = t.code) " \ |
1995 | 187 | "WHERE a.company_id = %s " \ | 180 | "WHERE a.company_id = %s " \ |
1998 | 188 | "AND a.type IN " + self.ACCOUNT_TYPE + " " \ | 181 | "AND a.type IN %s " \ |
1999 | 189 | "AND a.active", (data['form']['company_id'],)) | 182 | "AND a.active", (data['form']['company_id'],self.ACCOUNT_TYPE)) |
2000 | 190 | self.account_ids = ','.join([str(a) for (a,) in self.cr.fetchall()]) | 183 | self.account_ids = ','.join([str(a) for (a,) in self.cr.fetchall()]) |
2001 | 191 | 184 | ||
2002 | 192 | super(partner_balance, self).set_context(objects, data, ids, report_type) | 185 | super(partner_balance, self).set_context(objects, data, ids, report_type) |
2003 | @@ -196,7 +189,7 @@ | |||
2004 | 196 | account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') | 189 | account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') |
2005 | 197 | full_account = [] | 190 | full_account = [] |
2006 | 198 | result_tmp = 0.0 | 191 | result_tmp = 0.0 |
2008 | 199 | if self.date_lst_string: | 192 | if self.date_lst: |
2009 | 200 | self.cr.execute( | 193 | self.cr.execute( |
2010 | 201 | "SELECT p.ref,l.account_id,ac.name as account_name,ac.code as code ,p.name, sum(debit) as debit, sum(credit) as credit, " \ | 194 | "SELECT p.ref,l.account_id,ac.name as account_name,ac.code as code ,p.name, sum(debit) as debit, sum(credit) as credit, " \ |
2011 | 202 | "CASE WHEN sum(debit) > sum(credit) " \ | 195 | "CASE WHEN sum(debit) > sum(credit) " \ |
2012 | @@ -210,16 +203,17 @@ | |||
2013 | 210 | "(SELECT sum(debit-credit) " \ | 203 | "(SELECT sum(debit-credit) " \ |
2014 | 211 | "FROM account_move_line l " \ | 204 | "FROM account_move_line l " \ |
2015 | 212 | "WHERE partner_id = p.id " \ | 205 | "WHERE partner_id = p.id " \ |
2017 | 213 | "AND l.date IN (" + self.date_lst_string + ") " \ | 206 | "AND l.date IN %s " \ |
2018 | 214 | "AND blocked = TRUE " \ | 207 | "AND blocked = TRUE " \ |
2019 | 215 | ") AS enlitige " \ | 208 | ") AS enlitige " \ |
2020 | 216 | "FROM account_move_line l LEFT JOIN res_partner p ON (l.partner_id=p.id) " \ | 209 | "FROM account_move_line l LEFT JOIN res_partner p ON (l.partner_id=p.id) " \ |
2021 | 217 | "JOIN account_account ac ON (l.account_id = ac.id)" \ | 210 | "JOIN account_account ac ON (l.account_id = ac.id)" \ |
2025 | 218 | "WHERE ac.type IN " + self.ACCOUNT_TYPE + " " \ | 211 | "WHERE ac.type IN %s " \ |
2026 | 219 | "AND l.date IN (" + self.date_lst_string + ") " \ | 212 | "AND l.date IN %s " \ |
2027 | 220 | "AND ac.company_id = "+ str(data['form']['company_id']) +" " \ | 213 | "AND ac.company_id = %s " \ |
2028 | 221 | "GROUP BY p.id, p.ref, p.name,l.account_id,ac.name,ac.code " \ | 214 | "GROUP BY p.id, p.ref, p.name,l.account_id,ac.name,ac.code " \ |
2030 | 222 | "ORDER BY l.account_id,p.name") | 215 | "ORDER BY l.account_id,p.name", |
2031 | 216 | (tuple(self.date_lst), self.ACCOUNT_TYPE, tuple(self.date_lst), data['form']['company_id'])) | ||
2032 | 223 | res = self.cr.dictfetchall() | 217 | res = self.cr.dictfetchall() |
2033 | 224 | for r in res: | 218 | for r in res: |
2034 | 225 | full_account.append(r) | 219 | full_account.append(r) |
2035 | @@ -352,12 +346,13 @@ | |||
2036 | 352 | account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') | 346 | account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') |
2037 | 353 | result_tmp = 0.0 | 347 | result_tmp = 0.0 |
2038 | 354 | temp_res = 0.0 | 348 | temp_res = 0.0 |
2040 | 355 | if self.date_lst_string: | 349 | if self.date_lst: |
2041 | 356 | self.cr.execute( | 350 | self.cr.execute( |
2042 | 357 | "SELECT sum(debit) " \ | 351 | "SELECT sum(debit) " \ |
2043 | 358 | "FROM account_move_line AS l " \ | 352 | "FROM account_move_line AS l " \ |
2044 | 359 | "WHERE l.account_id IN (" + self.account_ids + ") " \ | 353 | "WHERE l.account_id IN (" + self.account_ids + ") " \ |
2046 | 360 | "AND l.date IN (" + self.date_lst_string + ") " ) | 354 | "AND l.date IN %s", |
2047 | 355 | (tuple(self.date_lst),)) | ||
2048 | 361 | temp_res = float(self.cr.fetchone()[0] or 0.0) | 356 | temp_res = float(self.cr.fetchone()[0] or 0.0) |
2049 | 362 | result_tmp = result_tmp + temp_res | 357 | result_tmp = result_tmp + temp_res |
2050 | 363 | 358 | ||
2051 | @@ -370,12 +365,13 @@ | |||
2052 | 370 | 365 | ||
2053 | 371 | result_tmp = 0.0 | 366 | result_tmp = 0.0 |
2054 | 372 | temp_res = 0.0 | 367 | temp_res = 0.0 |
2056 | 373 | if self.date_lst_string: | 368 | if self.date_lst: |
2057 | 374 | self.cr.execute( | 369 | self.cr.execute( |
2058 | 375 | "SELECT sum(credit) " \ | 370 | "SELECT sum(credit) " \ |
2059 | 376 | "FROM account_move_line AS l " \ | 371 | "FROM account_move_line AS l " \ |
2060 | 377 | "WHERE l.account_id IN (" + self.account_ids + ") " \ | 372 | "WHERE l.account_id IN (" + self.account_ids + ") " \ |
2062 | 378 | "AND l.date IN (" + self.date_lst_string + ") " ) | 373 | "AND l.date IN %s", |
2063 | 374 | (tuple(self.date_lst),)) | ||
2064 | 379 | temp_res = float(self.cr.fetchone()[0] or 0.0) | 375 | temp_res = float(self.cr.fetchone()[0] or 0.0) |
2065 | 380 | result_tmp = result_tmp + temp_res | 376 | result_tmp = result_tmp + temp_res |
2066 | 381 | 377 | ||
2067 | @@ -387,13 +383,14 @@ | |||
2068 | 387 | account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') | 383 | account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') |
2069 | 388 | result_tmp = 0.0 | 384 | result_tmp = 0.0 |
2070 | 389 | temp_res = 0.0 | 385 | temp_res = 0.0 |
2072 | 390 | if self.date_lst_string: | 386 | if self.date_lst: |
2073 | 391 | self.cr.execute( | 387 | self.cr.execute( |
2074 | 392 | "SELECT sum(debit-credit) " \ | 388 | "SELECT sum(debit-credit) " \ |
2075 | 393 | "FROM account_move_line AS l " \ | 389 | "FROM account_move_line AS l " \ |
2076 | 394 | "WHERE l.account_id IN (" + self.account_ids + ") " \ | 390 | "WHERE l.account_id IN (" + self.account_ids + ") " \ |
2079 | 395 | "AND l.date IN (" + self.date_lst_string + ") " \ | 391 | "AND l.date IN %s " \ |
2080 | 396 | "AND l.blocked=TRUE " ) | 392 | "AND l.blocked=TRUE ", |
2081 | 393 | (tuple(self.date_lst),)) | ||
2082 | 397 | temp_res = float(self.cr.fetchone()[0] or 0.0) | 394 | temp_res = float(self.cr.fetchone()[0] or 0.0) |
2083 | 398 | result_tmp = result_tmp + temp_res | 395 | result_tmp = result_tmp + temp_res |
2084 | 399 | 396 | ||
2085 | @@ -405,7 +402,7 @@ | |||
2086 | 405 | account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') | 402 | account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') |
2087 | 406 | result_tmp = 0.0 | 403 | result_tmp = 0.0 |
2088 | 407 | a = 0.0 | 404 | a = 0.0 |
2090 | 408 | if self.date_lst_string: | 405 | if self.date_lst: |
2091 | 409 | self.cr.execute( | 406 | self.cr.execute( |
2092 | 410 | "SELECT CASE WHEN sum(debit) > sum(credit) " \ | 407 | "SELECT CASE WHEN sum(debit) > sum(credit) " \ |
2093 | 411 | "THEN sum(debit) - sum(credit) " \ | 408 | "THEN sum(debit) - sum(credit) " \ |
2094 | @@ -413,8 +410,9 @@ | |||
2095 | 413 | "END " \ | 410 | "END " \ |
2096 | 414 | "FROM account_move_line AS l " \ | 411 | "FROM account_move_line AS l " \ |
2097 | 415 | "WHERE l.account_id IN (" + self.account_ids + ") " \ | 412 | "WHERE l.account_id IN (" + self.account_ids + ") " \ |
2100 | 416 | "AND l.date IN (" + self.date_lst_string + ") " \ | 413 | "AND l.date IN %s " \ |
2101 | 417 | "GROUP BY l.partner_id") | 414 | "GROUP BY l.partner_id", |
2102 | 415 | (tuple(self.date_lst),)) | ||
2103 | 418 | a = self.cr.fetchone()[0] | 416 | a = self.cr.fetchone()[0] |
2104 | 419 | 417 | ||
2105 | 420 | if self.cr.fetchone() != None: | 418 | if self.cr.fetchone() != None: |
2106 | @@ -432,7 +430,7 @@ | |||
2107 | 432 | 430 | ||
2108 | 433 | result_tmp = 0.0 | 431 | result_tmp = 0.0 |
2109 | 434 | a = 0.0 | 432 | a = 0.0 |
2111 | 435 | if self.date_lst_string: | 433 | if self.date_lst: |
2112 | 436 | self.cr.execute( | 434 | self.cr.execute( |
2113 | 437 | "SELECT CASE WHEN sum(debit) < sum(credit) " \ | 435 | "SELECT CASE WHEN sum(debit) < sum(credit) " \ |
2114 | 438 | "THEN sum(credit) - sum(debit) " \ | 436 | "THEN sum(credit) - sum(debit) " \ |
2115 | @@ -440,8 +438,9 @@ | |||
2116 | 440 | "END " \ | 438 | "END " \ |
2117 | 441 | "FROM account_move_line AS l " \ | 439 | "FROM account_move_line AS l " \ |
2118 | 442 | "WHERE l.account_id IN (" + self.account_ids + ") " \ | 440 | "WHERE l.account_id IN (" + self.account_ids + ") " \ |
2121 | 443 | "AND l.date IN (" + self.date_lst_string + ") " \ | 441 | "AND l.date IN %s " \ |
2122 | 444 | "GROUP BY l.partner_id") | 442 | "GROUP BY l.partner_id", |
2123 | 443 | (tuple(self.date_lst),)) | ||
2124 | 445 | a = self.cr.fetchone()[0] or 0.0 | 444 | a = self.cr.fetchone()[0] or 0.0 |
2125 | 446 | 445 | ||
2126 | 447 | if self.cr.fetchone() != None: | 446 | if self.cr.fetchone() != None: |
2127 | 448 | 447 | ||
2128 | === modified file 'account/report/tax_report.py' | |||
2129 | --- account/report/tax_report.py 2009-10-09 11:49:00 +0000 | |||
2130 | +++ account/report/tax_report.py 2010-03-17 11:50:49 +0000 | |||
2131 | @@ -90,7 +90,7 @@ | |||
2132 | 90 | 90 | ||
2133 | 91 | def _get_general(self, tax_code_id,period_list ,company_id, based_on): | 91 | def _get_general(self, tax_code_id,period_list ,company_id, based_on): |
2134 | 92 | res=[] | 92 | res=[] |
2136 | 93 | period_sql_list = ','.join(map(str, period_list[0][2])) | 93 | periods_ids = tuple(period_list[0][2]) |
2137 | 94 | if based_on == 'payments': | 94 | if based_on == 'payments': |
2138 | 95 | self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \ | 95 | self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \ |
2139 | 96 | SUM(line.debit) AS debit, \ | 96 | SUM(line.debit) AS debit, \ |
2140 | @@ -109,11 +109,11 @@ | |||
2141 | 109 | AND line.account_id = account.id \ | 109 | AND line.account_id = account.id \ |
2142 | 110 | AND account.company_id = %s \ | 110 | AND account.company_id = %s \ |
2143 | 111 | AND move.id = line.move_id \ | 111 | AND move.id = line.move_id \ |
2145 | 112 | AND line.period_id IN ('+ period_sql_list +') \ | 112 | AND line.period_id IN %s \ |
2146 | 113 | AND ((invoice.state = %s) \ | 113 | AND ((invoice.state = %s) \ |
2147 | 114 | OR (invoice.id IS NULL)) \ | 114 | OR (invoice.id IS NULL)) \ |
2150 | 115 | GROUP BY account.id,account.name,account.code', ('draft',tax_code_id, | 115 | GROUP BY account.id,account.name,account.code', |
2151 | 116 | company_id, 'paid')) | 116 | ('draft',tax_code_id,company_id,periods_ids,'paid')) |
2152 | 117 | 117 | ||
2153 | 118 | else : | 118 | else : |
2154 | 119 | self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \ | 119 | self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \ |
2155 | @@ -129,10 +129,10 @@ | |||
2156 | 129 | AND line.tax_code_id = %s \ | 129 | AND line.tax_code_id = %s \ |
2157 | 130 | AND line.account_id = account.id \ | 130 | AND line.account_id = account.id \ |
2158 | 131 | AND account.company_id = %s \ | 131 | AND account.company_id = %s \ |
2160 | 132 | AND line.period_id IN ('+ period_sql_list +') \ | 132 | AND line.period_id IN %s \ |
2161 | 133 | AND account.active \ | 133 | AND account.active \ |
2164 | 134 | GROUP BY account.id,account.name,account.code', ('draft',tax_code_id, | 134 | GROUP BY account.id,account.name,account.code', |
2165 | 135 | company_id)) | 135 | ('draft',tax_code_id,company_id,periods_ids)) |
2166 | 136 | res = self.cr.dictfetchall() | 136 | res = self.cr.dictfetchall() |
2167 | 137 | 137 | ||
2168 | 138 | #AND line.period_id IN ('+ period_sql_list +') \ | 138 | #AND line.period_id IN ('+ period_sql_list +') \ |
2169 | 139 | 139 | ||
2170 | === modified file 'account/wizard/wizard_account_balance_report.py' | |||
2171 | --- account/wizard/wizard_account_balance_report.py 2009-09-07 07:09:31 +0000 | |||
2172 | +++ account/wizard/wizard_account_balance_report.py 2010-03-17 11:50:49 +0000 | |||
2173 | @@ -112,8 +112,8 @@ | |||
2174 | 112 | 112 | ||
2175 | 113 | def _check_date(self, cr, uid, data, context): | 113 | def _check_date(self, cr, uid, data, context): |
2176 | 114 | sql = """ | 114 | sql = """ |
2179 | 115 | SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where '%s' between f.date_start and f.date_stop """%(data['form']['date_from']) | 115 | SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where %s between f.date_start and f.date_stop """ |
2180 | 116 | cr.execute(sql) | 116 | cr.execute(sql, (data['form']['date_from'],)) |
2181 | 117 | res = cr.dictfetchall() | 117 | res = cr.dictfetchall() |
2182 | 118 | if res: | 118 | if res: |
2183 | 119 | if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_to'] < res[0]['date_start']): | 119 | if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_to'] < res[0]['date_start']): |
2184 | 120 | 120 | ||
2185 | === modified file 'account/wizard/wizard_general_ledger_report.py' | |||
2186 | --- account/wizard/wizard_general_ledger_report.py 2009-09-07 07:09:31 +0000 | |||
2187 | +++ account/wizard/wizard_general_ledger_report.py 2010-03-17 11:50:49 +0000 | |||
2188 | @@ -106,8 +106,8 @@ | |||
2189 | 106 | def _check_date(self, cr, uid, data, context): | 106 | def _check_date(self, cr, uid, data, context): |
2190 | 107 | 107 | ||
2191 | 108 | sql = """ | 108 | sql = """ |
2194 | 109 | SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where '%s' between f.date_start and f.date_stop """%(data['form']['date_from']) | 109 | SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where %s between f.date_start and f.date_stop """ |
2195 | 110 | cr.execute(sql) | 110 | cr.execute(sql, (data['form']['date_from'],)) |
2196 | 111 | res = cr.dictfetchall() | 111 | res = cr.dictfetchall() |
2197 | 112 | if res: | 112 | if res: |
2198 | 113 | if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_to'] < res[0]['date_start']): | 113 | if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_to'] < res[0]['date_start']): |
2199 | 114 | 114 | ||
2200 | === modified file 'account/wizard/wizard_open_closed_fiscalyear.py' | |||
2201 | --- account/wizard/wizard_open_closed_fiscalyear.py 2009-01-27 11:15:46 +0000 | |||
2202 | +++ account/wizard/wizard_open_closed_fiscalyear.py 2010-03-17 11:50:49 +0000 | |||
2203 | @@ -43,16 +43,7 @@ | |||
2204 | 43 | period_journal = data_fyear.end_journal_period_id | 43 | period_journal = data_fyear.end_journal_period_id |
2205 | 44 | ids_move = pool.get('account.move').search(cr,uid,[('journal_id','=',period_journal.journal_id.id),('period_id','=',period_journal.period_id.id)]) | 44 | ids_move = pool.get('account.move').search(cr,uid,[('journal_id','=',period_journal.journal_id.id),('period_id','=',period_journal.period_id.id)]) |
2206 | 45 | if ids_move: | 45 | if ids_move: |
2217 | 46 | cr.execute('delete from account_move where id in ('+','.join(map(str,ids_move))+')') | 46 | cr.execute('delete from account_move where id in %s', (tuple(ids_move),)) |
2208 | 47 | #cr.execute('UPDATE account_journal_period ' \ | ||
2209 | 48 | # 'SET state = %s ' \ | ||
2210 | 49 | # 'WHERE period_id IN (SELECT id FROM account_period WHERE fiscalyear_id = %s)', | ||
2211 | 50 | # ('draft',data_fyear)) | ||
2212 | 51 | #cr.execute('UPDATE account_period SET state = %s ' \ | ||
2213 | 52 | # 'WHERE fiscalyear_id = %s', ('draft',data_fyear)) | ||
2214 | 53 | #cr.execute('UPDATE account_fiscalyear ' \ | ||
2215 | 54 | # 'SET state = %s, end_journal_period_id = null '\ | ||
2216 | 55 | # 'WHERE id = %s', ('draft',data_fyear)) | ||
2218 | 56 | return {} | 47 | return {} |
2219 | 57 | 48 | ||
2220 | 58 | class open_closed_fiscal(wizard.interface): | 49 | class open_closed_fiscal(wizard.interface): |
2221 | 59 | 50 | ||
2222 | === modified file 'account/wizard/wizard_partner_balance_report.py' | |||
2223 | --- account/wizard/wizard_partner_balance_report.py 2009-04-29 07:42:01 +0000 | |||
2224 | +++ account/wizard/wizard_partner_balance_report.py 2010-03-17 11:50:49 +0000 | |||
2225 | @@ -102,8 +102,8 @@ | |||
2226 | 102 | def _check_date(self, cr, uid, data, context): | 102 | def _check_date(self, cr, uid, data, context): |
2227 | 103 | 103 | ||
2228 | 104 | sql = """ | 104 | sql = """ |
2231 | 105 | SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where '%s' between f.date_start and f.date_stop """%(data['form']['date1']) | 105 | SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where %s between f.date_start and f.date_stop """ |
2232 | 106 | cr.execute(sql) | 106 | cr.execute(sql, (data['form']['date1'],)) |
2233 | 107 | res = cr.dictfetchall() | 107 | res = cr.dictfetchall() |
2234 | 108 | if res: | 108 | if res: |
2235 | 109 | if (data['form']['date2'] > res[0]['date_stop'] or data['form']['date2'] < res[0]['date_start']): | 109 | if (data['form']['date2'] > res[0]['date_stop'] or data['form']['date2'] < res[0]['date_start']): |
2236 | 110 | 110 | ||
2237 | === modified file 'account/wizard/wizard_third_party_ledger.py' | |||
2238 | --- account/wizard/wizard_third_party_ledger.py 2009-05-29 11:35:52 +0000 | |||
2239 | +++ account/wizard/wizard_third_party_ledger.py 2010-03-17 11:50:49 +0000 | |||
2240 | @@ -114,8 +114,8 @@ | |||
2241 | 114 | def _check_date(self, cr, uid, data, context): | 114 | def _check_date(self, cr, uid, data, context): |
2242 | 115 | 115 | ||
2243 | 116 | sql = """ | 116 | sql = """ |
2246 | 117 | SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where '%s' between f.date_start and f.date_stop """%(data['form']['date1']) | 117 | SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where %s between f.date_start and f.date_stop """ |
2247 | 118 | cr.execute(sql) | 118 | cr.execute(sql, (data['form']['date1'],)) |
2248 | 119 | res = cr.dictfetchall() | 119 | res = cr.dictfetchall() |
2249 | 120 | if res: | 120 | if res: |
2250 | 121 | if (data['form']['date2'] > res[0]['date_stop'] or data['form']['date2'] < res[0]['date_start']): | 121 | if (data['form']['date2'] > res[0]['date_stop'] or data['form']['date2'] < res[0]['date_start']): |
2251 | 122 | 122 | ||
2252 | === modified file 'account_analytic_plans/report/crossovered_analytic.py' | |||
2253 | --- account_analytic_plans/report/crossovered_analytic.py 2009-10-09 11:49:00 +0000 | |||
2254 | +++ account_analytic_plans/report/crossovered_analytic.py 2010-03-17 11:50:49 +0000 | |||
2255 | @@ -72,13 +72,19 @@ | |||
2256 | 72 | 72 | ||
2257 | 73 | self.dict_acc_ref = {} | 73 | self.dict_acc_ref = {} |
2258 | 74 | if form['journal_ids'][0][2]: | 74 | if form['journal_ids'][0][2]: |
2260 | 75 | journal = " in (" + ','.join(map(lambda x: str(x), form['journal_ids'][0][2])) + ")" | 75 | journal_filter = "in %s" |
2261 | 76 | sql_args = (tuple(form['journal_ids'][0][2]),) | ||
2262 | 76 | else: | 77 | else: |
2268 | 77 | journal = 'is not null' | 78 | journal_filter = 'is not null' |
2269 | 78 | 79 | sql_args = () | |
2270 | 79 | query_general = "select id from account_analytic_line where (journal_id " + journal +") AND date>='"+ str(form['date1']) +"'"" AND date<='" + str(form['date2']) + "'" | 80 | |
2271 | 80 | 81 | query_general = "SELECT id FROM account_analytic_line "\ | |
2272 | 81 | self.cr.execute(query_general) | 82 | "WHERE (journal_id %s) "\ |
2273 | 83 | "AND date>=%%s "\ | ||
2274 | 84 | "AND date<=%%s"%( | ||
2275 | 85 | journal_filter) | ||
2276 | 86 | |||
2277 | 87 | self.cr.execute(query_general, sql_args + (form['date1'], form['date2'])) | ||
2278 | 82 | l_ids=self.cr.fetchall() | 88 | l_ids=self.cr.fetchall() |
2279 | 83 | line_ids = [x[0] for x in l_ids] | 89 | line_ids = [x[0] for x in l_ids] |
2280 | 84 | 90 | ||
2281 | @@ -98,10 +104,16 @@ | |||
2282 | 98 | self.final_list = children_list | 104 | self.final_list = children_list |
2283 | 99 | selected_ids = line_pool.search(self.cr,self.uid,[('account_id','in',self.final_list)]) | 105 | selected_ids = line_pool.search(self.cr,self.uid,[('account_id','in',self.final_list)]) |
2284 | 100 | 106 | ||
2287 | 101 | query="SELECT sum(aal.amount) AS amt, sum(aal.unit_amount) AS qty FROM account_analytic_line AS aal, account_analytic_account AS aaa \ | 107 | query="SELECT SUM(aal.amount) AS amt, SUM(aal.unit_amount) AS qty "\ |
2288 | 102 | WHERE aal.account_id=aaa.id AND aal.id IN ("+','.join(map(str,selected_ids))+") AND (aal.journal_id " + journal +") AND aal.date>='"+ str(form['date1']) +"'"" AND aal.date<='" + str(form['date2']) + "'" | 108 | "FROM account_analytic_line AS aal, account_analytic_account AS aaa "\ |
2289 | 109 | "WHERE aal.account_id=aaa.id "\ | ||
2290 | 110 | "AND aal.id IN %%s "\ | ||
2291 | 111 | "AND (aal.journal_id %s) "\ | ||
2292 | 112 | "AND aal.date>=%%s "\ | ||
2293 | 113 | "AND aal.date<=%%s"%(journal_filter) | ||
2294 | 103 | 114 | ||
2296 | 104 | self.cr.execute(query) | 115 | self.cr.execute( |
2297 | 116 | query, (tuple(selected_ids),) + sql_args + (form['date1'],form['date2'])) | ||
2298 | 105 | info=self.cr.dictfetchall() | 117 | info=self.cr.dictfetchall() |
2299 | 106 | 118 | ||
2300 | 107 | res['ref_qty']=info[0]['qty'] | 119 | res['ref_qty']=info[0]['qty'] |
2301 | @@ -116,9 +128,11 @@ | |||
2302 | 116 | ids = self.ids | 128 | ids = self.ids |
2303 | 117 | 129 | ||
2304 | 118 | if form['journal_ids'][0][2]: | 130 | if form['journal_ids'][0][2]: |
2306 | 119 | journal=" in (" + ','.join(map(lambda x: str(x), form['journal_ids'][0][2])) + ")" | 131 | journal_filter = " in %s" |
2307 | 132 | sql_args = (tuple(form['journal_ids'][0][2]),) | ||
2308 | 120 | else: | 133 | else: |
2310 | 121 | journal= 'is not null' | 134 | journal_filter = 'is not null' |
2311 | 135 | sql_args = () | ||
2312 | 122 | 136 | ||
2313 | 123 | acc_pool = self.pool.get('account.analytic.account') | 137 | acc_pool = self.pool.get('account.analytic.account') |
2314 | 124 | line_pool=self.pool.get('account.analytic.line') | 138 | line_pool=self.pool.get('account.analytic.line') |
2315 | @@ -132,10 +146,22 @@ | |||
2316 | 132 | for acc_id in self.final_list: | 146 | for acc_id in self.final_list: |
2317 | 133 | selected_ids = line_pool.search(self.cr,self.uid,[('account_id','=',acc_id),('move_id','in',self.dict_acc_ref[form['ref']])]) | 147 | selected_ids = line_pool.search(self.cr,self.uid,[('account_id','=',acc_id),('move_id','in',self.dict_acc_ref[form['ref']])]) |
2318 | 134 | if selected_ids: | 148 | if selected_ids: |
2321 | 135 | query="SELECT aaa.code as code , sum(aal.amount) AS amt, sum(aal.unit_amount) AS qty,aaa.name as acc_name,aal.account_id as id FROM account_analytic_line AS aal, account_analytic_account AS aaa \ | 149 | query="SELECT aaa.code as code , SUM(aal.amount) AS amt, "\ |
2322 | 136 | WHERE aal.account_id=aaa.id AND aal.id IN ("+','.join(map(str,selected_ids))+") AND (aal.journal_id " + journal +") AND aal.date>='"+ str(form['date1']) +"'"" AND aal.date<='" + str(form['date2']) + "'"" GROUP BY aal.account_id,aaa.name,aaa.code ORDER BY aal.account_id" | 150 | "SUM(aal.unit_amount) AS qty, aaa.name AS acc_name, "\ |
2323 | 151 | "aal.account_id AS id "\ | ||
2324 | 152 | "FROM account_analytic_line AS aal, account_analytic_account AS aaa "\ | ||
2325 | 153 | "WHERE aal.account_id=aaa.id "\ | ||
2326 | 154 | "AND aal.id IN %%s "\ | ||
2327 | 155 | "AND (aal.journal_id %s) "\ | ||
2328 | 156 | "AND aal.date>=%%s "\ | ||
2329 | 157 | "AND aal.date<=%%s "\ | ||
2330 | 158 | "GROUP BY aal.account_id, aaa.name, aaa.code "\ | ||
2331 | 159 | "ORDER BY aal.account_id" % ( | ||
2332 | 160 | journal_filter | ||
2333 | 161 | ) | ||
2334 | 137 | 162 | ||
2336 | 138 | self.cr.execute(query) | 163 | self.cr.execute(query, (tuple(selected_ids),) + sql_args \ |
2337 | 164 | + (form['date1'], form['date2'])) | ||
2338 | 139 | res = self.cr.dictfetchall() | 165 | res = self.cr.dictfetchall() |
2339 | 140 | if res: | 166 | if res: |
2340 | 141 | for element in res: | 167 | for element in res: |
2341 | 142 | 168 | ||
2342 | === modified file 'account_payment/account_move_line.py' | |||
2343 | --- account_payment/account_move_line.py 2010-01-08 11:38:58 +0000 | |||
2344 | +++ account_payment/account_move_line.py 2010-03-17 11:50:49 +0000 | |||
2345 | @@ -19,7 +19,7 @@ | |||
2346 | 19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
2347 | 20 | # | 20 | # |
2348 | 21 | ############################################################################## | 21 | ############################################################################## |
2350 | 22 | 22 | from operator import itemgetter | |
2351 | 23 | from osv import fields, osv | 23 | from osv import fields, osv |
2352 | 24 | from tools.translate import _ | 24 | from tools.translate import _ |
2353 | 25 | 25 | ||
2354 | @@ -43,7 +43,7 @@ | |||
2355 | 43 | WHERE move_line_id = ml.id | 43 | WHERE move_line_id = ml.id |
2356 | 44 | AND po.state != 'cancel') as amount | 44 | AND po.state != 'cancel') as amount |
2357 | 45 | FROM account_move_line ml | 45 | FROM account_move_line ml |
2359 | 46 | WHERE id in (%s)""" % (",".join(map(str, ids)))) | 46 | WHERE id in %s""", (tuple(ids),)) |
2360 | 47 | r=dict(cr.fetchall()) | 47 | r=dict(cr.fetchall()) |
2361 | 48 | return r | 48 | return r |
2362 | 49 | 49 | ||
2363 | @@ -59,8 +59,10 @@ | |||
2364 | 59 | END - coalesce(sum(pl.amount_currency), 0) | 59 | END - coalesce(sum(pl.amount_currency), 0) |
2365 | 60 | FROM payment_line pl | 60 | FROM payment_line pl |
2366 | 61 | INNER JOIN payment_order po ON (pl.order_id = po.id) | 61 | INNER JOIN payment_order po ON (pl.order_id = po.id) |
2369 | 62 | WHERE move_line_id = l.id AND po.state != 'cancel')''' \ | 62 | WHERE move_line_id = l.id |
2370 | 63 | + x[1] + str(x[2])+' ',args)) | 63 | AND po.state != 'cancel' |
2371 | 64 | ) %(operator)s %%s ''' % {'operator': x[1]}, args)) | ||
2372 | 65 | sql_args = tuple(map(itemgetter(2), args)) | ||
2373 | 64 | 66 | ||
2374 | 65 | cr.execute(('''select id | 67 | cr.execute(('''select id |
2375 | 66 | from account_move_line l | 68 | from account_move_line l |
2376 | @@ -69,7 +71,7 @@ | |||
2377 | 69 | where type=%s and active) | 71 | where type=%s and active) |
2378 | 70 | and reconcile_id is null | 72 | and reconcile_id is null |
2379 | 71 | and credit > 0 | 73 | and credit > 0 |
2381 | 72 | and ''' + where + ' and ' + query), ('payable',) ) | 74 | and ''' + where + ' and ' + query), ('payable',)+sql_args ) |
2382 | 73 | 75 | ||
2383 | 74 | res = cr.fetchall() | 76 | res = cr.fetchall() |
2384 | 75 | if not len(res): | 77 | if not len(res): |
2385 | 76 | 78 | ||
2386 | === modified file 'account_payment/payment.py' | |||
2387 | --- account_payment/payment.py 2009-02-26 14:31:43 +0000 | |||
2388 | +++ account_payment/payment.py 2010-03-17 11:50:49 +0000 | |||
2389 | @@ -65,8 +65,6 @@ | |||
2390 | 65 | join payment_mode pm on (pm.type = pt.id) | 65 | join payment_mode pm on (pm.type = pt.id) |
2391 | 66 | where pm.id = %s """, [payment_code]) | 66 | where pm.id = %s """, [payment_code]) |
2392 | 67 | return [x[0] for x in cr.fetchall()] | 67 | return [x[0] for x in cr.fetchall()] |
2393 | 68 | |||
2394 | 69 | |||
2395 | 70 | payment_mode() | 68 | payment_mode() |
2396 | 71 | 69 | ||
2397 | 72 | 70 | ||
2398 | @@ -150,19 +148,8 @@ | |||
2399 | 150 | _name = 'payment.line' | 148 | _name = 'payment.line' |
2400 | 151 | _description = 'Payment Line' | 149 | _description = 'Payment Line' |
2401 | 152 | 150 | ||
2402 | 153 | #~ def partner_payable(self, cr, uid, ids, name, args, context={}): | ||
2403 | 154 | #~ if not ids: return {} | ||
2404 | 155 | #~ partners= self.read(cr, uid, ids, ['partner_id'], context) | ||
2405 | 156 | #~ partners= dict(map(lambda x: (x['id'], x['partner_id'][0]), partners)) | ||
2406 | 157 | #~ debit = self.pool.get('res.partner')._debit_get(cr, uid, | ||
2407 | 158 | #~ partners.values(), name, args, context) | ||
2408 | 159 | #~ for i in partners: | ||
2409 | 160 | #~ partners[i] = debit[partners[i]] | ||
2410 | 161 | #~ return partners | ||
2411 | 162 | |||
2412 | 163 | def translate(self, orig): | 151 | def translate(self, orig): |
2413 | 164 | return { | 152 | return { |
2414 | 165 | # "to_pay": "credit", | ||
2415 | 166 | "due_date": "date_maturity", | 153 | "due_date": "date_maturity", |
2416 | 167 | "reference": "ref"}.get(orig, orig) | 154 | "reference": "ref"}.get(orig, orig) |
2417 | 168 | 155 | ||
2418 | @@ -224,8 +211,8 @@ | |||
2419 | 224 | from account_move_line ml | 211 | from account_move_line ml |
2420 | 225 | inner join payment_line pl | 212 | inner join payment_line pl |
2421 | 226 | on (ml.id = pl.move_line_id) | 213 | on (ml.id = pl.move_line_id) |
2424 | 227 | where pl.id in (%s)"""% | 214 | where pl.id in %%s"""% self.translate(name), |
2425 | 228 | (self.translate(name), ','.join(map(str,ids))) ) | 215 | (tuple(ids),)) |
2426 | 229 | res = dict(cr.fetchall()) | 216 | res = dict(cr.fetchall()) |
2427 | 230 | 217 | ||
2428 | 231 | if name == 'partner_id': | 218 | if name == 'partner_id': |
2429 | @@ -244,61 +231,6 @@ | |||
2430 | 244 | res.setdefault(id, (False, "")) | 231 | res.setdefault(id, (False, "")) |
2431 | 245 | return res | 232 | return res |
2432 | 246 | 233 | ||
2433 | 247 | # def _currency(self, cursor, user, ids, name, args, context=None): | ||
2434 | 248 | # if not ids: | ||
2435 | 249 | # return {} | ||
2436 | 250 | # res = {} | ||
2437 | 251 | # | ||
2438 | 252 | # currency_obj = self.pool.get('res.currency') | ||
2439 | 253 | # account_obj = self.pool.get('account.account') | ||
2440 | 254 | # cursor.execute('''SELECT pl.id, ml.currency_id, ml.account_id | ||
2441 | 255 | # FROM account_move_line ml | ||
2442 | 256 | # INNER JOIN payment_line pl | ||
2443 | 257 | # ON (ml.id = pl.move_line_id) | ||
2444 | 258 | # WHERE pl.id in (''' + ','.join([str(x) for x in ids]) + ')') | ||
2445 | 259 | # | ||
2446 | 260 | # res2 = {} | ||
2447 | 261 | # account_ids = [] | ||
2448 | 262 | # for payment_line_id, currency_id, account_id in cursor.fetchall(): | ||
2449 | 263 | # res2[payment_line_id] = [currency_id, account_id] | ||
2450 | 264 | # account_ids.append(account_id) | ||
2451 | 265 | # | ||
2452 | 266 | # account2currency_id = {} | ||
2453 | 267 | # for account in account_obj.browse(cursor, user, account_ids, | ||
2454 | 268 | # context=context): | ||
2455 | 269 | # account2currency_id[account.id] = account.company_currency_id.id | ||
2456 | 270 | # | ||
2457 | 271 | # for payment_line_id in ids: | ||
2458 | 272 | # if res2[payment_line_id][0]: | ||
2459 | 273 | # res[payment_line_id] = res2[payment_line_id][0] | ||
2460 | 274 | # else: | ||
2461 | 275 | # res[payment_line_id] = \ | ||
2462 | 276 | # account2currency_id[res2[payment_line_id][1]] | ||
2463 | 277 | # | ||
2464 | 278 | # currency_names = {} | ||
2465 | 279 | # for currency_id, name in currency_obj.name_get(cursor, user, res.values(), | ||
2466 | 280 | # context=context): | ||
2467 | 281 | # currency_names[currency_id] = name | ||
2468 | 282 | # for payment_line_id in ids: | ||
2469 | 283 | # res[payment_line_id] = (res[payment_line_id], | ||
2470 | 284 | # currency_names[res[payment_line_id]]) | ||
2471 | 285 | # return res | ||
2472 | 286 | # | ||
2473 | 287 | # def _to_pay_currency(self, cursor, user, ids, name , args, context=None): | ||
2474 | 288 | # if not ids: | ||
2475 | 289 | # return {} | ||
2476 | 290 | # | ||
2477 | 291 | # cursor.execute('''SELECT pl.id, | ||
2478 | 292 | # CASE WHEN ml.amount_currency < 0 | ||
2479 | 293 | # THEN - ml.amount_currency | ||
2480 | 294 | # ELSE ml.credit | ||
2481 | 295 | # END | ||
2482 | 296 | # FROM account_move_line ml | ||
2483 | 297 | # INNER JOIN payment_line pl | ||
2484 | 298 | # ON (ml.id = pl.move_line_id) | ||
2485 | 299 | # WHERE pl.id in (''' + ','.join([str(x) for x in ids]) + ')') | ||
2486 | 300 | # return dict(cursor.fetchall()) | ||
2487 | 301 | |||
2488 | 302 | def _amount(self, cursor, user, ids, name, args, context=None): | 234 | def _amount(self, cursor, user, ids, name, args, context=None): |
2489 | 303 | if not ids: | 235 | if not ids: |
2490 | 304 | return {} | 236 | return {} |
2491 | @@ -334,15 +266,6 @@ | |||
2492 | 334 | else: | 266 | else: |
2493 | 335 | return self.pool.get('res.currency').search(cr, uid, [('rate','=',1.0)])[0] | 267 | return self.pool.get('res.currency').search(cr, uid, [('rate','=',1.0)])[0] |
2494 | 336 | 268 | ||
2495 | 337 | # def select_move_lines(*a): | ||
2496 | 338 | # print a | ||
2497 | 339 | # return [] | ||
2498 | 340 | |||
2499 | 341 | # def create(self, cr, uid, vals, context): | ||
2500 | 342 | # print "created!!!" | ||
2501 | 343 | # vals['company_currency'] = self._get_currency(cr, uid, context) | ||
2502 | 344 | # return super(payment_line, self).create(cr, uid, vals, context) | ||
2503 | 345 | |||
2504 | 346 | def _get_ml_inv_ref(self, cr, uid, ids, *a): | 269 | def _get_ml_inv_ref(self, cr, uid, ids, *a): |
2505 | 347 | res={} | 270 | res={} |
2506 | 348 | for id in self.browse(cr, uid, ids): | 271 | for id in self.browse(cr, uid, ids): |
2507 | @@ -377,11 +300,6 @@ | |||
2508 | 377 | 'move_line_id': fields.many2one('account.move.line','Entry line', domain=[('reconcile_id','=', False), ('account_id.type', '=','payable')],help='This Entry Line will be referred for the information of the ordering customer.'), | 300 | 'move_line_id': fields.many2one('account.move.line','Entry line', domain=[('reconcile_id','=', False), ('account_id.type', '=','payable')],help='This Entry Line will be referred for the information of the ordering customer.'), |
2509 | 378 | 'amount_currency': fields.float('Amount in Partner Currency', digits=(16,2), | 301 | 'amount_currency': fields.float('Amount in Partner Currency', digits=(16,2), |
2510 | 379 | required=True, help='Payment amount in the partner currency'), | 302 | required=True, help='Payment amount in the partner currency'), |
2511 | 380 | # 'to_pay_currency': fields.function(_to_pay_currency, string='To Pay', | ||
2512 | 381 | # method=True, type='float', | ||
2513 | 382 | # help='Amount to pay in the partner currency'), | ||
2514 | 383 | # 'currency': fields.function(_currency, string='Currency', | ||
2515 | 384 | # method=True, type='many2one', obj='res.currency'), | ||
2516 | 385 | 'currency': fields.many2one('res.currency','Partner Currency',required=True), | 303 | 'currency': fields.many2one('res.currency','Partner Currency',required=True), |
2517 | 386 | 'company_currency': fields.many2one('res.currency','Company Currency',readonly=True), | 304 | 'company_currency': fields.many2one('res.currency','Company Currency',readonly=True), |
2518 | 387 | 'bank_id': fields.many2one('res.partner.bank', 'Destination Bank account'), | 305 | 'bank_id': fields.many2one('res.partner.bank', 'Destination Bank account'), |
2519 | @@ -391,21 +309,12 @@ | |||
2520 | 391 | 'amount': fields.function(_amount, string='Amount in Company Currency', | 309 | 'amount': fields.function(_amount, string='Amount in Company Currency', |
2521 | 392 | method=True, type='float', | 310 | method=True, type='float', |
2522 | 393 | help='Payment amount in the company currency'), | 311 | help='Payment amount in the company currency'), |
2523 | 394 | # 'to_pay': fields.function(select_by_name, string="To Pay", method=True, | ||
2524 | 395 | # type='float', help='Amount to pay in the company currency'), | ||
2525 | 396 | # 'due_date': fields.function(select_by_name, string="Due date", | ||
2526 | 397 | # method=True, type='date'), | ||
2527 | 398 | 'ml_date_created': fields.function(_get_ml_created_date, string="Effective Date", | 312 | 'ml_date_created': fields.function(_get_ml_created_date, string="Effective Date", |
2528 | 399 | method=True, type='date',help="Invoice Effective Date"), | 313 | method=True, type='date',help="Invoice Effective Date"), |
2529 | 400 | # 'reference': fields.function(select_by_name, string="Ref", method=True, | ||
2530 | 401 | # type='char'), | ||
2531 | 402 | 'ml_maturity_date': fields.function(_get_ml_maturity_date, method=True, type='date', string='Maturity Date'), | 314 | 'ml_maturity_date': fields.function(_get_ml_maturity_date, method=True, type='date', string='Maturity Date'), |
2532 | 403 | 'ml_inv_ref': fields.function(_get_ml_inv_ref, method=True, type='many2one', relation='account.invoice', string='Invoice Ref.'), | 315 | 'ml_inv_ref': fields.function(_get_ml_inv_ref, method=True, type='many2one', relation='account.invoice', string='Invoice Ref.'), |
2533 | 404 | 'info_owner': fields.function(info_owner, string="Owner Account", method=True, type="text",help='Address of the Main Partner'), | 316 | 'info_owner': fields.function(info_owner, string="Owner Account", method=True, type="text",help='Address of the Main Partner'), |
2534 | 405 | 'info_partner': fields.function(info_partner, string="Destination Account", method=True, type="text",help='Address of the Ordering Customer.'), | 317 | 'info_partner': fields.function(info_partner, string="Destination Account", method=True, type="text",help='Address of the Ordering Customer.'), |
2535 | 406 | # 'partner_payable': fields.function(partner_payable, string="Partner payable", method=True, type='float'), | ||
2536 | 407 | # 'value_date': fields.function(_value_date, string='Value Date', | ||
2537 | 408 | # method=True, type='date'), | ||
2538 | 409 | 'date': fields.date('Payment Date',help="If no payment date is specified, the bank will treat this payment line directly"), | 318 | 'date': fields.date('Payment Date',help="If no payment date is specified, the bank will treat this payment line directly"), |
2539 | 410 | 'create_date': fields.datetime('Created' ,readonly=True), | 319 | 'create_date': fields.datetime('Created' ,readonly=True), |
2540 | 411 | 'state': fields.selection([('normal','Free'), ('structured','Structured')], 'Communication Type', required=True) | 320 | 'state': fields.selection([('normal','Free'), ('structured','Structured')], 'Communication Type', required=True) |
2541 | 412 | 321 | ||
2542 | === modified file 'account_voucher/account.py' | |||
2543 | --- account_voucher/account.py 2010-01-20 17:19:31 +0000 | |||
2544 | +++ account_voucher/account.py 2010-03-17 11:50:49 +0000 | |||
2545 | @@ -67,9 +67,11 @@ | |||
2546 | 67 | def compute_total(self, cr, uid, ids, yr_st_date, yr_end_date, st_date, end_date, field_names, context={}): | 67 | def compute_total(self, cr, uid, ids, yr_st_date, yr_end_date, st_date, end_date, field_names, context={}): |
2547 | 68 | if not (st_date >= yr_st_date and end_date <= yr_end_date): | 68 | if not (st_date >= yr_st_date and end_date <= yr_end_date): |
2548 | 69 | return {} | 69 | return {} |
2552 | 70 | query = "l.date >= '%s' AND l.date <= '%s'" (st_date, end_date) | 70 | return self.__compute( |
2553 | 71 | return self.__compute(cr, uid, ids, field_names, context=context, query=query) | 71 | cr, uid, ids, field_names, context=context, |
2554 | 72 | 72 | query="l.date >= '%s' AND l.date <= '%s'", | |
2555 | 73 | query_params=(st_date, end_date)) | ||
2556 | 74 | |||
2557 | 73 | def create(self, cr, uid, vals, context={}): | 75 | def create(self, cr, uid, vals, context={}): |
2558 | 74 | name=self.search(cr,uid,[('name','ilike',vals['name']),('company_id','=',vals['name'])]) | 76 | name=self.search(cr,uid,[('name','ilike',vals['name']),('company_id','=',vals['name'])]) |
2559 | 75 | if name: | 77 | if name: |
2560 | 76 | 78 | ||
2561 | === modified file 'account_voucher/voucher.py' | |||
2562 | --- account_voucher/voucher.py 2010-03-08 07:19:28 +0000 | |||
2563 | +++ account_voucher/voucher.py 2010-03-17 11:50:49 +0000 | |||
2564 | @@ -407,7 +407,8 @@ | |||
2565 | 407 | def action_number(self, cr, uid, ids, *args): | 407 | def action_number(self, cr, uid, ids, *args): |
2566 | 408 | cr.execute('SELECT id, type, number, move_id, reference ' \ | 408 | cr.execute('SELECT id, type, number, move_id, reference ' \ |
2567 | 409 | 'FROM account_voucher ' \ | 409 | 'FROM account_voucher ' \ |
2569 | 410 | 'WHERE id IN ('+','.join(map(str,ids))+')') | 410 | 'WHERE id IN %s', |
2570 | 411 | (tuple(ids),)) | ||
2571 | 411 | for (id, invtype, number, move_id, reference) in cr.fetchall(): | 412 | for (id, invtype, number, move_id, reference) in cr.fetchall(): |
2572 | 412 | if not number: | 413 | if not number: |
2573 | 413 | number = self.pool.get('ir.sequence').get(cr, uid, invtype) | 414 | number = self.pool.get('ir.sequence').get(cr, uid, invtype) |
2574 | 414 | 415 | ||
2575 | === modified file 'auction/auction.py' | |||
2576 | --- auction/auction.py 2009-08-24 11:51:52 +0000 | |||
2577 | +++ auction/auction.py 2010-03-17 11:50:49 +0000 | |||
2578 | @@ -95,12 +95,19 @@ | |||
2579 | 95 | RETURN: True | 95 | RETURN: True |
2580 | 96 | """ | 96 | """ |
2581 | 97 | # objects vendus mais non factures | 97 | # objects vendus mais non factures |
2583 | 98 | cr.execute('select count(*) as c from auction_lots where auction_id in ('+','.join(map(str,ids))+') and state=%s and obj_price>0', ('draft',)) | 98 | cr.execute('SELECT COUNT(*) AS c ' |
2584 | 99 | 'FROM auction_lots ' | ||
2585 | 100 | 'WHERE auction_id IN %s ' | ||
2586 | 101 | 'AND state=%s AND obj_price>0', (tuple(ids), 'draft')) | ||
2587 | 99 | nbr = cr.fetchone()[0] | 102 | nbr = cr.fetchone()[0] |
2588 | 100 | ach_uids = {} | 103 | ach_uids = {} |
2590 | 101 | cr.execute('select id from auction_lots where auction_id in ('+','.join(map(str,ids))+') and state=%s and obj_price>0', ('draft',)) | 104 | cr.execute('SELECT id FROM auction_lots ' |
2591 | 105 | 'WHERE auction_id IN %s ' | ||
2592 | 106 | 'AND state=%s AND obj_price>0', (tuple(ids), 'draft')) | ||
2593 | 102 | r=self.pool.get('auction.lots').lots_invoice(cr, uid, [x[0] for x in cr.fetchall()],{},None) | 107 | r=self.pool.get('auction.lots').lots_invoice(cr, uid, [x[0] for x in cr.fetchall()],{},None) |
2595 | 103 | cr.execute('select id from auction_lots where auction_id in ('+','.join(map(str,ids))+') and obj_price>0') | 108 | cr.execute('SELECT id FROM auction_lots ' |
2596 | 109 | 'WHERE auction_id IN %s ' | ||
2597 | 110 | 'AND obj_price>0', (tuple(ids),)) | ||
2598 | 104 | ids2 = [x[0] for x in cr.fetchall()] | 111 | ids2 = [x[0] for x in cr.fetchall()] |
2599 | 105 | # for auction in auction_ids: | 112 | # for auction in auction_ids: |
2600 | 106 | c=self.pool.get('auction.lots').seller_trans_create(cr, uid, ids2,{}) | 113 | c=self.pool.get('auction.lots').seller_trans_create(cr, uid, ids2,{}) |
2601 | @@ -113,7 +120,9 @@ | |||
2602 | 113 | # Deposits | 120 | # Deposits |
2603 | 114 | #---------------------------------------------------------- | 121 | #---------------------------------------------------------- |
2604 | 115 | def _inv_uniq(cr, ids): | 122 | def _inv_uniq(cr, ids): |
2606 | 116 | cr.execute('select name from auction_deposit where id in ('+','.join(map(lambda x: str(x), ids))+')') | 123 | cr.execute('SELECT name FROM auction_deposit ' |
2607 | 124 | 'WHERE id IN %s', | ||
2608 | 125 | (tuple(ids),)) | ||
2609 | 117 | for datas in cr.fetchall(): | 126 | for datas in cr.fetchall(): |
2610 | 118 | cr.execute('select count(*) from auction_deposit where name=%s', (datas[0],)) | 127 | cr.execute('select count(*) from auction_deposit where name=%s', (datas[0],)) |
2611 | 119 | if cr.fetchone()[0]>1: | 128 | if cr.fetchone()[0]>1: |
2612 | @@ -229,7 +238,9 @@ | |||
2613 | 229 | # Lots | 238 | # Lots |
2614 | 230 | #---------------------------------------------------------- | 239 | #---------------------------------------------------------- |
2615 | 231 | def _inv_constraint(cr, ids): | 240 | def _inv_constraint(cr, ids): |
2617 | 232 | cr.execute('select id, bord_vnd_id, lot_num from auction_lots where id in ('+','.join(map(lambda x: str(x), ids))+')') | 241 | cr.execute('SELECT id, bord_vnd_id, lot_num FROM auction_lots ' |
2618 | 242 | 'WHERE id IN %s', | ||
2619 | 243 | (tuple(ids),)) | ||
2620 | 233 | for datas in cr.fetchall(): | 244 | for datas in cr.fetchall(): |
2621 | 234 | cr.execute('select count(*) from auction_lots where bord_vnd_id=%s and lot_num=%s', (datas[1],datas[2])) | 245 | cr.execute('select count(*) from auction_lots where bord_vnd_id=%s and lot_num=%s', (datas[1],datas[2])) |
2622 | 235 | if cr.fetchone()[0]>1: | 246 | if cr.fetchone()[0]>1: |
2623 | 236 | 247 | ||
2624 | === modified file 'auction/report/auction_objects.py' | |||
2625 | --- auction/report/auction_objects.py 2009-10-09 11:49:00 +0000 | |||
2626 | +++ auction/report/auction_objects.py 2010-03-17 11:50:49 +0000 | |||
2627 | @@ -29,20 +29,7 @@ | |||
2628 | 29 | super(auction_objects, self).__init__(cr, uid, name, context=context) | 29 | super(auction_objects, self).__init__(cr, uid, name, context=context) |
2629 | 30 | self.localcontext.update({ | 30 | self.localcontext.update({ |
2630 | 31 | 'time': time, | 31 | 'time': time, |
2631 | 32 | #'lines': self.lines | ||
2632 | 33 | #'get_data' : self.get_data | ||
2633 | 34 | }) | 32 | }) |
2634 | 35 | |||
2635 | 36 | # def lines(self, auction_id): | ||
2636 | 37 | # | ||
2637 | 38 | # cr.execute('select ad.name from auction_dates ad, a1uction_lots al where ad.id=al.%d group by ad.name',(auction_id)) | ||
2638 | 39 | # return self.cr.fetchone()[0] | ||
2639 | 40 | # def get_data(self, auction_id): | ||
2640 | 41 | # res = self.pool.get('auction.bid.lines').read(self.cr,self.uid,[lot_id]) | ||
2641 | 42 | # return True | ||
2642 | 43 | |||
2643 | 44 | |||
2644 | 45 | |||
2645 | 46 | report_sxw.report_sxw('report.auction.objects', 'auction.lots', 'addons/auction/report/auction_objects.rml', parser=auction_objects) | 33 | report_sxw.report_sxw('report.auction.objects', 'auction.lots', 'addons/auction/report/auction_objects.rml', parser=auction_objects) |
2646 | 47 | 34 | ||
2647 | 48 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | 35 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
2648 | 49 | 36 | ||
2649 | === modified file 'auction/report/auction_total_rml.py' | |||
2650 | --- auction/report/auction_total_rml.py 2009-10-09 11:49:00 +0000 | |||
2651 | +++ auction/report/auction_total_rml.py 2010-03-17 11:50:49 +0000 | |||
2652 | @@ -55,7 +55,10 @@ | |||
2653 | 55 | for lot_id in objects: | 55 | for lot_id in objects: |
2654 | 56 | auc_lot_ids.append(lot_id.id) | 56 | auc_lot_ids.append(lot_id.id) |
2655 | 57 | self.total_obj=auc_lot_ids | 57 | self.total_obj=auc_lot_ids |
2657 | 58 | self.cr.execute('select auction_id from auction_lots where id in ('+','.join(map(str,auc_lot_ids))+') group by auction_id') | 58 | self.cr.execute('SELECT auction_id FROM auction_lots ' |
2658 | 59 | 'WHERE id IN %s ' | ||
2659 | 60 | 'GROUP BY auction_id', | ||
2660 | 61 | (tuple(auc_lot_ids),)) | ||
2661 | 59 | auc_date_ids = self.cr.fetchall() | 62 | auc_date_ids = self.cr.fetchall() |
2662 | 60 | auct_dat=[] | 63 | auct_dat=[] |
2663 | 61 | for ad_id in auc_date_ids: | 64 | for ad_id in auc_date_ids: |
2664 | 62 | 65 | ||
2665 | === modified file 'auction/report/buyer_list.py' | |||
2666 | --- auction/report/buyer_list.py 2009-10-09 11:49:00 +0000 | |||
2667 | +++ auction/report/buyer_list.py 2010-03-17 11:50:49 +0000 | |||
2668 | @@ -51,7 +51,8 @@ | |||
2669 | 51 | for lot_id in objects: | 51 | for lot_id in objects: |
2670 | 52 | auc_lot_ids.append(lot_id.id) | 52 | auc_lot_ids.append(lot_id.id) |
2671 | 53 | self.auc_lot_ids=auc_lot_ids | 53 | self.auc_lot_ids=auc_lot_ids |
2673 | 54 | self.cr.execute('select auction_id from auction_lots where id in ('+','.join(map(str,auc_lot_ids))+') group by auction_id') | 54 | self.cr.execute('SELECT auction_id FROM auction_lots WHERE id IN %s GROUP BY auction_id', |
2674 | 55 | (tuple(auc_lot_ids),)) | ||
2675 | 55 | auc_date_ids = self.cr.fetchall() | 56 | auc_date_ids = self.cr.fetchall() |
2676 | 56 | auct_dat=[] | 57 | auct_dat=[] |
2677 | 57 | for ad_id in auc_date_ids: | 58 | for ad_id in auc_date_ids: |
2678 | @@ -71,13 +72,16 @@ | |||
2679 | 71 | 72 | ||
2680 | 72 | auc_date_ids = self.pool.get('auction.dates').search(self.cr,self.uid,([('name','like',obj['name'])])) | 73 | auc_date_ids = self.pool.get('auction.dates').search(self.cr,self.uid,([('name','like',obj['name'])])) |
2681 | 73 | 74 | ||
2684 | 74 | # self.cr.execute('select ach_uid,count(1) as no_lot, sum(obj_price) as adj_price, sum(buyer_price)-sum(obj_price) as buyer_cost ,sum(buyer_price) as to_pay from auction_lots where id in ('+','.join(map(str,self.auc_lot_ids))+') and auction_id=%s and ach_uid is not null group by ach_uid ', (auc_date_ids[0],)) | 75 | self.cr.execute('SELECT ach_login AS ach_uid, COUNT(1) AS no_lot, '\ |
2685 | 75 | self.cr.execute('select ach_login as ach_uid,count(1) as no_lot, sum(obj_price) as adj_price, sum(buyer_price)-sum(obj_price) as buyer_cost ,sum(buyer_price) as to_pay from auction_lots where id in ('+','.join(map(str,self.auc_lot_ids))+') and auction_id=%s and ach_login is not null group by ach_login order by ach_login', (auc_date_ids[0],)) | 76 | 'SUM(obj_price) AS adj_price, '\ |
2686 | 77 | 'SUM(buyer_price)-SUM(obj_price) AS buyer_cost, '\ | ||
2687 | 78 | 'SUM(buyer_price) AS to_pay '\ | ||
2688 | 79 | 'FROM auction_lots WHERE id IN %s '\ | ||
2689 | 80 | 'AND auction_id=%s AND ach_login IS NOT NULL '\ | ||
2690 | 81 | 'GROUP BY ach_login ORDER BY ach_login', | ||
2691 | 82 | (tuple(self.auc_lot_ids), auc_date_ids[0],)) | ||
2692 | 76 | res = self.cr.dictfetchall() | 83 | res = self.cr.dictfetchall() |
2693 | 77 | for r in res: | 84 | for r in res: |
2694 | 78 | # if r['ach_uid']: | ||
2695 | 79 | # tnm=self.pool.get('res.partner').read(self.cr,self.uid,[r['ach_uid']],['name'])# | ||
2696 | 80 | # r.__setitem__('ach_uid',tnm[0]['name']) | ||
2697 | 81 | self.sum_adj_price_val = self.sum_adj_price_val + r['adj_price'] | 85 | self.sum_adj_price_val = self.sum_adj_price_val + r['adj_price'] |
2698 | 82 | self.sum_buyer_obj_price_val = self.sum_buyer_obj_price_val + r['buyer_cost'] | 86 | self.sum_buyer_obj_price_val = self.sum_buyer_obj_price_val + r['buyer_cost'] |
2699 | 83 | self.sum_buyer_price_val = self.sum_buyer_price_val + r['to_pay'] | 87 | self.sum_buyer_price_val = self.sum_buyer_price_val + r['to_pay'] |
2700 | 84 | 88 | ||
2701 | === modified file 'base_module_quality/speed_test/speed_test.py' | |||
2702 | --- base_module_quality/speed_test/speed_test.py 2010-02-18 15:23:03 +0000 | |||
2703 | +++ base_module_quality/speed_test/speed_test.py 2010-03-17 11:50:49 +0000 | |||
2704 | @@ -62,7 +62,9 @@ | |||
2705 | 62 | 62 | ||
2706 | 63 | # remove osv_memory class becaz it does not have demo data | 63 | # remove osv_memory class becaz it does not have demo data |
2707 | 64 | if obj_list: | 64 | if obj_list: |
2709 | 65 | cr.execute("select w.res_model from ir_actions_todo as t left join ir_act_window as w on t.action_id=w.id where w.res_model in ('%s')"% ("','".join(obj_list))) | 65 | cr.execute("SELECT w.res_model FROM ir_actions_todo AS t "\ |
2710 | 66 | "LEFT JOIN ir_act_window AS w ON t.action_id=w.id "\ | ||
2711 | 67 | "WHERE w.res_model IN %s", (tuple(obj_list),)) | ||
2712 | 66 | res = cr.fetchall() | 68 | res = cr.fetchall() |
2713 | 67 | for remove_obj in res: | 69 | for remove_obj in res: |
2714 | 68 | if remove_obj and (remove_obj[0] in obj_list): | 70 | if remove_obj and (remove_obj[0] in obj_list): |
2715 | 69 | 71 | ||
2716 | === modified file 'crm/crm.py' | |||
2717 | --- crm/crm.py 2009-08-10 06:20:35 +0000 | |||
2718 | +++ crm/crm.py 2010-03-17 11:50:49 +0000 | |||
2719 | @@ -75,7 +75,9 @@ | |||
2720 | 75 | def _check_recursion(self, cr, uid, ids): | 75 | def _check_recursion(self, cr, uid, ids): |
2721 | 76 | level = 100 | 76 | level = 100 |
2722 | 77 | while len(ids): | 77 | while len(ids): |
2724 | 78 | cr.execute('select distinct parent_id from crm_case_section where id in ('+','.join(map(str,ids))+')') | 78 | cr.execute('SELECT DISTINCT parent_id FROM crm_case_section '\ |
2725 | 79 | 'WHERE id IN %s', | ||
2726 | 80 | (tuple(ids),)) | ||
2727 | 79 | ids = filter(None, map(lambda x:x[0], cr.fetchall())) | 81 | ids = filter(None, map(lambda x:x[0], cr.fetchall())) |
2728 | 80 | if not level: | 82 | if not level: |
2729 | 81 | return False | 83 | return False |
2730 | 82 | 84 | ||
2731 | === modified file 'crm/report/report_businessopp.py' | |||
2732 | --- crm/report/report_businessopp.py 2010-02-17 10:53:29 +0000 | |||
2733 | +++ crm/report/report_businessopp.py 2010-03-17 11:50:49 +0000 | |||
2734 | @@ -56,7 +56,13 @@ | |||
2735 | 56 | minbenef = 999999999999999999999 | 56 | minbenef = 999999999999999999999 |
2736 | 57 | maxbenef = 0 | 57 | maxbenef = 0 |
2737 | 58 | 58 | ||
2739 | 59 | cr.execute('select probability, planned_revenue, planned_cost, user_id, res_users.name as name from crm_case left join res_users on (crm_case.user_id=res_users.id) where crm_case.id in ('+','.join(map(str,ids))+') order by user_id') | 59 | cr.execute('SELECT probability, planned_revenue, planned_cost, '\ |
2740 | 60 | 'user_id, res_users.name AS name '\ | ||
2741 | 61 | 'FROM crm_case '\ | ||
2742 | 62 | 'LEFT JOIN res_users ON (crm_case.user_id=res_users.id) '\ | ||
2743 | 63 | 'WHERE crm_case.id IN %s '\ | ||
2744 | 64 | 'ORDER BY user_id', | ||
2745 | 65 | (tuple(ids),)) | ||
2746 | 60 | res = cr.dictfetchall() | 66 | res = cr.dictfetchall() |
2747 | 61 | 67 | ||
2748 | 62 | for row in res: | 68 | for row in res: |
2749 | 63 | 69 | ||
2750 | === modified file 'crm_profiling/crm_profiling.py' | |||
2751 | --- crm_profiling/crm_profiling.py 2009-01-27 11:15:46 +0000 | |||
2752 | +++ crm_profiling/crm_profiling.py 2010-03-17 11:50:49 +0000 | |||
2753 | @@ -28,17 +28,17 @@ | |||
2754 | 28 | query = """ | 28 | query = """ |
2755 | 29 | select distinct(answer) | 29 | select distinct(answer) |
2756 | 30 | from profile_question_yes_rel | 30 | from profile_question_yes_rel |
2758 | 31 | where profile in (%s)"""% ','.join([str(i) for i in ids ]) | 31 | where profile in %s""" |
2759 | 32 | 32 | ||
2761 | 33 | cr.execute(query) | 33 | cr.execute(query, (tuple(ids),)) |
2762 | 34 | ans_yes = [x[0] for x in cr.fetchall()] | 34 | ans_yes = [x[0] for x in cr.fetchall()] |
2763 | 35 | 35 | ||
2764 | 36 | query = """ | 36 | query = """ |
2765 | 37 | select distinct(answer) | 37 | select distinct(answer) |
2766 | 38 | from profile_question_no_rel | 38 | from profile_question_no_rel |
2768 | 39 | where profile in (%s)"""% ','.join([str(i) for i in ids ]) | 39 | where profile in %s""" |
2769 | 40 | 40 | ||
2771 | 41 | cr.execute(query) | 41 | cr.execute(query, (tuple(ids),)) |
2772 | 42 | ans_no = [x[0] for x in cr.fetchall()] | 42 | ans_no = [x[0] for x in cr.fetchall()] |
2773 | 43 | 43 | ||
2774 | 44 | return [ans_yes, ans_no] | 44 | return [ans_yes, ans_no] |
2775 | @@ -50,7 +50,8 @@ | |||
2776 | 50 | select distinct(parent_id) | 50 | select distinct(parent_id) |
2777 | 51 | from crm_segmentation | 51 | from crm_segmentation |
2778 | 52 | where parent_id is not null | 52 | where parent_id is not null |
2780 | 53 | and id in (%s)""" % ','.join([str(i) for i in ids ])) | 53 | and id in %s""", |
2781 | 54 | (tuple(ids),)) | ||
2782 | 54 | 55 | ||
2783 | 55 | parent_ids = [x[0] for x in cr.fetchall()] | 56 | parent_ids = [x[0] for x in cr.fetchall()] |
2784 | 56 | 57 | ||
2785 | @@ -86,30 +87,31 @@ | |||
2786 | 86 | 87 | ||
2787 | 87 | 88 | ||
2788 | 88 | def _recompute_categ(self, cr, uid, pid, answers_ids): | 89 | def _recompute_categ(self, cr, uid, pid, answers_ids): |
2789 | 89 | ok = [] | ||
2790 | 90 | cr.execute(''' | 90 | cr.execute(''' |
2792 | 91 | select r.category_id | 91 | select r.category_id |
2793 | 92 | from res_partner_category_rel r left join crm_segmentation s on (r.category_id = s.categ_id) | 92 | from res_partner_category_rel r left join crm_segmentation s on (r.category_id = s.categ_id) |
2794 | 93 | where r.partner_id = %s and (s.exclusif = false or s.exclusif is null) | 93 | where r.partner_id = %s and (s.exclusif = false or s.exclusif is null) |
2795 | 94 | ''', (pid,)) | 94 | ''', (pid,)) |
2798 | 95 | for x in cr.fetchall(): | 95 | categories = [x[0] for x in cr.fetchall()] |
2797 | 96 | ok.append(x[0]) | ||
2799 | 97 | 96 | ||
2800 | 98 | query = ''' | 97 | query = ''' |
2807 | 99 | select id, categ_id | 98 | select id, categ_id |
2808 | 100 | from crm_segmentation | 99 | from crm_segmentation |
2809 | 101 | where profiling_active = true''' | 100 | where profiling_active = true''' |
2810 | 102 | if ok != []: | 101 | if not categories: |
2811 | 103 | query = query +''' and categ_id not in(%s)'''% ','.join([str(i) for i in ok ]) | 102 | query_params = () |
2812 | 104 | query = query + ''' order by id ''' | 103 | else: |
2813 | 104 | query += ' and categ_id not in %s' | ||
2814 | 105 | query_params = (tuple(categories),) | ||
2815 | 106 | query += ' order by id ' | ||
2816 | 105 | 107 | ||
2818 | 106 | cr.execute(query) | 108 | cr.execute(query, query_params) |
2819 | 107 | segm_cat_ids = cr.fetchall() | 109 | segm_cat_ids = cr.fetchall() |
2820 | 108 | 110 | ||
2821 | 109 | for (segm_id, cat_id) in segm_cat_ids: | 111 | for (segm_id, cat_id) in segm_cat_ids: |
2822 | 110 | if test_prof(cr, uid, segm_id, pid, answers_ids): | 112 | if test_prof(cr, uid, segm_id, pid, answers_ids): |
2825 | 111 | ok.append(cat_id) | 113 | categories.append(cat_id) |
2826 | 112 | return ok | 114 | return categories |
2827 | 113 | 115 | ||
2828 | 114 | 116 | ||
2829 | 115 | class question(osv.osv): | 117 | class question(osv.osv): |
2830 | 116 | 118 | ||
2831 | === modified file 'document/document.py' | |||
2832 | --- document/document.py 2010-01-08 11:38:58 +0000 | |||
2833 | +++ document/document.py 2010-03-17 11:50:49 +0000 | |||
2834 | @@ -302,7 +302,8 @@ | |||
2835 | 302 | def _check_recursion(self, cr, uid, ids): | 302 | def _check_recursion(self, cr, uid, ids): |
2836 | 303 | level = 100 | 303 | level = 100 |
2837 | 304 | while len(ids): | 304 | while len(ids): |
2839 | 305 | cr.execute('select distinct parent_id from document_directory where id in ('+','.join(map(str,ids))+')') | 305 | cr.execute('SELECT DISTINCT parent_id FROM document_directory '\ |
2840 | 306 | 'WHERE id in %s', (tuple(ids),)) | ||
2841 | 306 | ids = filter(None, map(lambda x:x[0], cr.fetchall())) | 307 | ids = filter(None, map(lambda x:x[0], cr.fetchall())) |
2842 | 307 | if not level: | 308 | if not level: |
2843 | 308 | return False | 309 | return False |
2844 | @@ -524,7 +525,8 @@ | |||
2845 | 524 | 525 | ||
2846 | 525 | def _data_get(self, cr, uid, ids, name, arg, context): | 526 | def _data_get(self, cr, uid, ids, name, arg, context): |
2847 | 526 | result = {} | 527 | result = {} |
2849 | 527 | cr.execute('select id,store_fname,link from ir_attachment where id in ('+','.join(map(str,ids))+')') | 528 | cr.execute('SELECT id, store_fname, link FROM ir_attachment '\ |
2850 | 529 | 'WHERE id IN %s', (tuple(ids),)) | ||
2851 | 528 | for id,r,l in cr.fetchall(): | 530 | for id,r,l in cr.fetchall(): |
2852 | 529 | try: | 531 | try: |
2853 | 530 | value = file(os.path.join(self._get_filestore(cr), r), 'rb').read() | 532 | value = file(os.path.join(self._get_filestore(cr), r), 'rb').read() |
2854 | 531 | 533 | ||
2855 | === modified file 'event/event.py' | |||
2856 | --- event/event.py 2009-04-09 10:02:19 +0000 | |||
2857 | +++ event/event.py 2010-03-17 11:50:49 +0000 | |||
2858 | @@ -77,8 +77,8 @@ | |||
2859 | 77 | def _get_register(self, cr, uid, ids, name, args, context=None): | 77 | def _get_register(self, cr, uid, ids, name, args, context=None): |
2860 | 78 | res={} | 78 | res={} |
2861 | 79 | for event in self.browse(cr, uid, ids, context): | 79 | for event in self.browse(cr, uid, ids, context): |
2864 | 80 | query = """select sum(nb_register) from crm_case c left join crm_case_section s on (c.section_id=s.id) right join event_event e on (e.section_id=s.id) right join event_registration r on (r.case_id=c.id) where e.section_id = %s and c.state in ('open','done')""" % event.section_id.id | 80 | query = """select sum(nb_register) from crm_case c left join crm_case_section s on (c.section_id=s.id) right join event_event e on (e.section_id=s.id) right join event_registration r on (r.case_id=c.id) where e.section_id = %s and c.state in ('open','done')""" |
2865 | 81 | cr.execute(query) | 81 | cr.execute(query,(event.section_id.id,)) |
2866 | 82 | res2 = cr.fetchone() | 82 | res2 = cr.fetchone() |
2867 | 83 | if res2 and res2[0]: | 83 | if res2 and res2[0]: |
2868 | 84 | res[event.id] = res2[0] | 84 | res[event.id] = res2[0] |
2869 | @@ -89,8 +89,8 @@ | |||
2870 | 89 | def _get_prospect(self, cr, uid, ids, name, args, context=None): | 89 | def _get_prospect(self, cr, uid, ids, name, args, context=None): |
2871 | 90 | res={} | 90 | res={} |
2872 | 91 | for event in self.browse(cr, uid, ids, context): | 91 | for event in self.browse(cr, uid, ids, context): |
2875 | 92 | query = """select sum(nb_register) from crm_case c left join crm_case_section s on (c.section_id=s.id) right join event_event e on (e.section_id=s.id) right join event_registration r on (r.case_id=c.id) where e.section_id = %s and c.state = 'draft'""" % event.section_id.id | 92 | query = """select sum(nb_register) from crm_case c left join crm_case_section s on (c.section_id=s.id) right join event_event e on (e.section_id=s.id) right join event_registration r on (r.case_id=c.id) where e.section_id = %s and c.state = 'draft'""" |
2876 | 93 | cr.execute(query) | 93 | cr.execute(query, (event.section_id.id,)) |
2877 | 94 | res2 = cr.fetchone() | 94 | res2 = cr.fetchone() |
2878 | 95 | if res2 and res2[0]: | 95 | if res2 and res2[0]: |
2879 | 96 | res[event.id] = res2[0] | 96 | res[event.id] = res2[0] |
2880 | 97 | 97 | ||
2881 | === modified file 'event_project/event.py' | |||
2882 | --- event_project/event.py 2009-01-04 22:12:50 +0000 | |||
2883 | +++ event_project/event.py 2010-03-17 11:50:49 +0000 | |||
2884 | @@ -37,8 +37,8 @@ | |||
2885 | 37 | for id in ids: | 37 | for id in ids: |
2886 | 38 | res[id] = [] | 38 | res[id] = [] |
2887 | 39 | for id in ids: | 39 | for id in ids: |
2890 | 40 | query = "select project_id from event_event where id = %i" %id | 40 | query = "select project_id from event_event where id = %s" |
2891 | 41 | cr.execute(query) | 41 | cr.execute(query, (id,)) |
2892 | 42 | project_ids = [ x[0] for x in cr.fetchall()] | 42 | project_ids = [ x[0] for x in cr.fetchall()] |
2893 | 43 | ids2 = obj.pool.get(self._obj).search(cr, user, [(self._fields_id,'in',project_ids),('state','<>','done')], limit=self._limit) | 43 | ids2 = obj.pool.get(self._obj).search(cr, user, [(self._fields_id,'in',project_ids),('state','<>','done')], limit=self._limit) |
2894 | 44 | for r in obj.pool.get(self._obj)._read_flat(cr, user, ids2, [self._fields_id], context=context, load='_classic_write'): | 44 | for r in obj.pool.get(self._obj)._read_flat(cr, user, ids2, [self._fields_id], context=context, load='_classic_write'): |
2895 | 45 | 45 | ||
2896 | === modified file 'hr/hr.py' | |||
2897 | --- hr/hr.py 2009-06-04 06:58:39 +0000 | |||
2898 | +++ hr/hr.py 2010-03-17 11:50:49 +0000 | |||
2899 | @@ -102,7 +102,8 @@ | |||
2900 | 102 | def _check_recursion(self, cr, uid, ids): | 102 | def _check_recursion(self, cr, uid, ids): |
2901 | 103 | level = 100 | 103 | level = 100 |
2902 | 104 | while len(ids): | 104 | while len(ids): |
2904 | 105 | cr.execute('select distinct parent_id from hr_employee_category where id in ('+','.join(map(str,ids))+')') | 105 | cr.execute('SELECT DISTINCT parent_id FROM hr_employee_category '\ |
2905 | 106 | 'WHERE id IN %s', (tuple(ids),)) | ||
2906 | 106 | ids = filter(None, map(lambda x:x[0], cr.fetchall())) | 107 | ids = filter(None, map(lambda x:x[0], cr.fetchall())) |
2907 | 107 | if not level: | 108 | if not level: |
2908 | 108 | return False | 109 | return False |
2909 | @@ -151,7 +152,8 @@ | |||
2910 | 151 | def _check_recursion(self, cr, uid, ids): | 152 | def _check_recursion(self, cr, uid, ids): |
2911 | 152 | level = 100 | 153 | level = 100 |
2912 | 153 | while len(ids): | 154 | while len(ids): |
2914 | 154 | cr.execute('select distinct parent_id from hr_employee where id in ('+','.join(map(str,ids))+')') | 155 | cr.execute('SELECT DISTINCT parent_id FROM hr_employee '\ |
2915 | 156 | 'WHERE id IN %s', (tuple(ids),)) | ||
2916 | 155 | ids = filter(None, map(lambda x:x[0], cr.fetchall())) | 157 | ids = filter(None, map(lambda x:x[0], cr.fetchall())) |
2917 | 156 | if not level: | 158 | if not level: |
2918 | 157 | return False | 159 | return False |
2919 | 158 | 160 | ||
2920 | === modified file 'hr/hr_department.py' | |||
2921 | --- hr/hr_department.py 2010-01-08 11:38:58 +0000 | |||
2922 | +++ hr/hr_department.py 2010-03-17 11:50:49 +0000 | |||
2923 | @@ -44,7 +44,8 @@ | |||
2924 | 44 | def _check_recursion(self, cr, uid, ids): | 44 | def _check_recursion(self, cr, uid, ids): |
2925 | 45 | level = 100 | 45 | level = 100 |
2926 | 46 | while len(ids): | 46 | while len(ids): |
2928 | 47 | cr.execute('select distinct parent_id from hr_department where id in ('+','.join(map(str,ids))+')') | 47 | cr.execute('SELECT DISTINCT parent_id FROM hr_department '\ |
2929 | 48 | 'WHERE id IN %s', (tuple(ids),)) | ||
2930 | 48 | ids = filter(None, map(lambda x:x[0], cr.fetchall())) | 49 | ids = filter(None, map(lambda x:x[0], cr.fetchall())) |
2931 | 49 | if not level: | 50 | if not level: |
2932 | 50 | return False | 51 | return False |
2933 | @@ -128,4 +129,4 @@ | |||
2934 | 128 | 129 | ||
2935 | 129 | res_users() | 130 | res_users() |
2936 | 130 | 131 | ||
2937 | 131 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
2938 | 132 | \ No newline at end of file | 132 | \ No newline at end of file |
2939 | 133 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
2940 | 133 | 134 | ||
2941 | === modified file 'hr_attendance/hr_attendance.py' | |||
2942 | --- hr_attendance/hr_attendance.py 2009-01-04 22:12:50 +0000 | |||
2943 | +++ hr_attendance/hr_attendance.py 2010-03-17 11:50:49 +0000 | |||
2944 | @@ -68,8 +68,8 @@ | |||
2945 | 68 | and name <= (select name from hr_attendance where id=%s) | 68 | and name <= (select name from hr_attendance where id=%s) |
2946 | 69 | order by name desc | 69 | order by name desc |
2947 | 70 | limit 2 | 70 | limit 2 |
2950 | 71 | ''' % (id, id) | 71 | ''' |
2951 | 72 | cr.execute(sql) | 72 | cr.execute(sql, (id, id)) |
2952 | 73 | atts = cr.fetchall() | 73 | atts = cr.fetchall() |
2953 | 74 | if not ((len(atts)==1 and atts[0][0] == 'sign_in') or (atts[0][0] != atts[1][0] and atts[0][1] != atts[1][1])): | 74 | if not ((len(atts)==1 and atts[0][0] == 'sign_in') or (atts[0][0] != atts[1][0] and atts[0][1] != atts[1][1])): |
2954 | 75 | return False | 75 | return False |
2955 | @@ -98,7 +98,7 @@ | |||
2956 | 98 | ON (hr_attendance.employee_id = foo.employee_id \ | 98 | ON (hr_attendance.employee_id = foo.employee_id \ |
2957 | 99 | AND hr_attendance.name = foo.name) \ | 99 | AND hr_attendance.name = foo.name) \ |
2958 | 100 | WHERE hr_attendance.employee_id \ | 100 | WHERE hr_attendance.employee_id \ |
2960 | 101 | in (' + ','.join([str(x) for x in ids]) + ')') | 101 | in %s', (tuple(ids),)) |
2961 | 102 | for res in cr.fetchall(): | 102 | for res in cr.fetchall(): |
2962 | 103 | result[res[1]] = res[0] == 'sign_in' and 'present' or 'absent' | 103 | result[res[1]] = res[0] == 'sign_in' and 'present' or 'absent' |
2963 | 104 | return result | 104 | return result |
2964 | 105 | 105 | ||
2965 | === modified file 'hr_attendance/wizard/print_attendance_error.py' | |||
2966 | --- hr_attendance/wizard/print_attendance_error.py 2010-01-21 11:52:07 +0000 | |||
2967 | +++ hr_attendance/wizard/print_attendance_error.py 2010-03-17 11:50:49 +0000 | |||
2968 | @@ -43,9 +43,12 @@ | |||
2969 | 43 | def _check_data(self, cr, uid, data, *args): | 43 | def _check_data(self, cr, uid, data, *args): |
2970 | 44 | date_from = data['form']['init_date'] | 44 | date_from = data['form']['init_date'] |
2971 | 45 | date_to = data['form']['end_date'] | 45 | date_to = data['form']['end_date'] |
2975 | 46 | emp_ids = (','.join([str(x) for x in data['ids']])) | 46 | cr.execute("SELECT id FROM hr_attendance "\ |
2976 | 47 | 47 | "WHERE employee_id IN %s "\ | |
2977 | 48 | cr.execute("select id from hr_attendance where employee_id in (%s) and to_char(name,'YYYY-mm-dd')<='%s' and to_char(name,'YYYY-mm-dd')>='%s' and action in ('%s','%s') order by name" %(emp_ids, date_to, date_from, 'sign_in', 'sign_out')) | 48 | "AND to_char(name,'YYYY-mm-dd')<=%s "\ |
2978 | 49 | "and to_char(name,'YYYY-mm-dd')>=%s "\ | ||
2979 | 50 | "and action in (%s, %s) order by name", | ||
2980 | 51 | (tuple(data['ids']), date_to, date_from, 'sign_in', 'sign_out')) | ||
2981 | 49 | attendance_ids = [x[0] for x in cr.fetchall()] | 52 | attendance_ids = [x[0] for x in cr.fetchall()] |
2982 | 50 | if not attendance_ids: | 53 | if not attendance_ids: |
2983 | 51 | raise wizard.except_wizard(_('No Data Available'), _('No records found for your selection!')) | 54 | raise wizard.except_wizard(_('No Data Available'), _('No records found for your selection!')) |
2984 | 52 | 55 | ||
2985 | === modified file 'hr_expense/hr_expense.py' | |||
2986 | --- hr_expense/hr_expense.py 2009-10-13 14:50:16 +0000 | |||
2987 | +++ hr_expense/hr_expense.py 2010-03-17 11:50:49 +0000 | |||
2988 | @@ -39,10 +39,13 @@ | |||
2989 | 39 | return super(hr_expense_expense, self).copy(cr, uid, id, default, context) | 39 | return super(hr_expense_expense, self).copy(cr, uid, id, default, context) |
2990 | 40 | 40 | ||
2991 | 41 | def _amount(self, cr, uid, ids, field_name, arg, context): | 41 | def _amount(self, cr, uid, ids, field_name, arg, context): |
2996 | 42 | id_set = ",".join(map(str, ids)) | 42 | cr.execute("SELECT s.id, "\ |
2997 | 43 | cr.execute("SELECT s.id,COALESCE(SUM(l.unit_amount*l.unit_quantity),0) AS amount FROM hr_expense_expense s LEFT OUTER JOIN hr_expense_line l ON (s.id=l.expense_id) WHERE s.id IN ("+id_set+") GROUP BY s.id ") | 43 | "COALESCE(SUM(l.unit_amount*l.unit_quantity),0) AS amount "\ |
2998 | 44 | res = dict(cr.fetchall()) | 44 | "FROM hr_expense_expense s "\ |
2999 | 45 | return res | 45 | "LEFT OUTER JOIN hr_expense_line l ON (s.id=l.expense_id) "\ |
3000 | 46 | "WHERE s.id IN %s GROUP BY s.id ", | ||
3001 | 47 | (tuple(ids),)) | ||
3002 | 48 | return dict(cr.fetchall()) | ||
3003 | 46 | 49 | ||
3004 | 47 | def _get_currency(self, cr, uid, context): | 50 | def _get_currency(self, cr, uid, context): |
3005 | 48 | user = self.pool.get('res.users').browse(cr, uid, [uid])[0] | 51 | user = self.pool.get('res.users').browse(cr, uid, [uid])[0] |
3006 | @@ -188,10 +191,11 @@ | |||
3007 | 188 | def _amount(self, cr, uid, ids, field_name, arg, context): | 191 | def _amount(self, cr, uid, ids, field_name, arg, context): |
3008 | 189 | if not len(ids): | 192 | if not len(ids): |
3009 | 190 | return {} | 193 | return {} |
3014 | 191 | id_set = ",".join(map(str, ids)) | 194 | cr.execute("SELECT l.id, "\ |
3015 | 192 | cr.execute("SELECT l.id,COALESCE(SUM(l.unit_amount*l.unit_quantity),0) AS amount FROM hr_expense_line l WHERE id IN ("+id_set+") GROUP BY l.id ") | 195 | "COALESCE(SUM(l.unit_amount*l.unit_quantity),0) AS amount "\ |
3016 | 193 | res = dict(cr.fetchall()) | 196 | "FROM hr_expense_line l WHERE id IN %s "\ |
3017 | 194 | return res | 197 | "GROUP BY l.id", (tuple(ids),)) |
3018 | 198 | return dict(cr.fetchall()) | ||
3019 | 195 | 199 | ||
3020 | 196 | _columns = { | 200 | _columns = { |
3021 | 197 | 'name': fields.char('Short Description', size=128, required=True), | 201 | 'name': fields.char('Short Description', size=128, required=True), |
3022 | 198 | 202 | ||
3023 | === modified file 'hr_holidays/hr.py' | |||
3024 | --- hr_holidays/hr.py 2010-01-05 08:07:22 +0000 | |||
3025 | +++ hr_holidays/hr.py 2010-03-17 11:50:49 +0000 | |||
3026 | @@ -146,7 +146,7 @@ | |||
3027 | 146 | 146 | ||
3028 | 147 | def _check_date(self, cr, uid, ids): | 147 | def _check_date(self, cr, uid, ids): |
3029 | 148 | if ids: | 148 | if ids: |
3031 | 149 | cr.execute('select number_of_days from hr_holidays where id in ('+','.join(map(str, ids))+')') | 149 | cr.execute('select number_of_days from hr_holidays where id in %s', (tuple(ids),)) |
3032 | 150 | res = cr.fetchall() | 150 | res = cr.fetchall() |
3033 | 151 | if res and res[0][0] < 0: | 151 | if res and res[0][0] < 0: |
3034 | 152 | return False | 152 | return False |
3035 | 153 | 153 | ||
3036 | === modified file 'hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py' | |||
3037 | --- hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py 2009-12-10 09:40:49 +0000 | |||
3038 | +++ hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py 2010-03-17 11:50:49 +0000 | |||
3039 | @@ -43,7 +43,7 @@ | |||
3040 | 43 | if obj_acc.invoice_id and obj_acc.invoice_id.state !='cancel': | 43 | if obj_acc.invoice_id and obj_acc.invoice_id.state !='cancel': |
3041 | 44 | raise wizard.except_wizard(_('Warning'),_('The analytic entry "%s" is already invoiced!')%(obj_acc.name,)) | 44 | raise wizard.except_wizard(_('Warning'),_('The analytic entry "%s" is already invoiced!')%(obj_acc.name,)) |
3042 | 45 | 45 | ||
3044 | 46 | cr.execute("SELECT distinct(account_id) from account_analytic_line where id IN (%s)"% (','.join(map(str,data['ids'])),)) | 46 | cr.execute("SELECT distinct(account_id) from account_analytic_line where id IN %s", (tuple(data['ids']),)) |
3045 | 47 | account_ids = cr.fetchall() | 47 | account_ids = cr.fetchall() |
3046 | 48 | return {'accounts': [x[0] for x in account_ids]} | 48 | return {'accounts': [x[0] for x in account_ids]} |
3047 | 49 | 49 | ||
3048 | @@ -96,9 +96,10 @@ | |||
3049 | 96 | cr.execute("SELECT product_id, to_invoice, sum(unit_amount) " \ | 96 | cr.execute("SELECT product_id, to_invoice, sum(unit_amount) " \ |
3050 | 97 | "FROM account_analytic_line as line " \ | 97 | "FROM account_analytic_line as line " \ |
3051 | 98 | "WHERE account_id = %s " \ | 98 | "WHERE account_id = %s " \ |
3053 | 99 | "AND id IN (" + ','.join([str(x) for x in data['ids']]) + ") " \ | 99 | "AND id IN %s " \ |
3054 | 100 | "AND to_invoice IS NOT NULL " \ | 100 | "AND to_invoice IS NOT NULL " \ |
3056 | 101 | "GROUP BY product_id,to_invoice", (account.id,)) | 101 | "GROUP BY product_id,to_invoice", |
3057 | 102 | (account.id, tuple(data['ids']))) | ||
3058 | 102 | 103 | ||
3059 | 103 | for product_id,factor_id,qty in cr.fetchall(): | 104 | for product_id,factor_id,qty in cr.fetchall(): |
3060 | 104 | product = pool.get('product.product').browse(cr, uid, product_id, context2) | 105 | product = pool.get('product.product').browse(cr, uid, product_id, context2) |
3061 | @@ -144,11 +145,11 @@ | |||
3062 | 144 | # | 145 | # |
3063 | 145 | cr.execute("SELECT * " # TODO optimize this | 146 | cr.execute("SELECT * " # TODO optimize this |
3064 | 146 | " FROM account_analytic_line" | 147 | " FROM account_analytic_line" |
3070 | 147 | " WHERE account_id=%%s" | 148 | " WHERE account_id=%s" |
3071 | 148 | " AND id IN (%s)" | 149 | " AND id IN %s" |
3072 | 149 | " AND product_id=%%s" | 150 | " AND product_id=%s" |
3073 | 150 | " AND to_invoice=%%s" % ','.join(['%s']*len(data['ids'])), | 151 | " AND to_invoice=%s", |
3074 | 151 | tuple([account.id]+ data['ids']+[ product_id, factor_id])) | 152 | (account.id, tuple(data['ids']), product_id, factor_id)) |
3075 | 152 | line_ids = cr.dictfetchall() | 153 | line_ids = cr.dictfetchall() |
3076 | 153 | note = [] | 154 | note = [] |
3077 | 154 | for line in line_ids: | 155 | for line in line_ids: |
3078 | @@ -169,8 +170,9 @@ | |||
3079 | 169 | 170 | ||
3080 | 170 | curr_line['note'] = "\n".join(map(lambda x: x or '',note)) | 171 | curr_line['note'] = "\n".join(map(lambda x: x or '',note)) |
3081 | 171 | pool.get('account.invoice.line').create(cr, uid, curr_line) | 172 | pool.get('account.invoice.line').create(cr, uid, curr_line) |
3084 | 172 | strids = ','.join(map(str, data['ids'])) | 173 | cr.execute("UPDATE account_analytic_line SET invoice_id=%s "\ |
3085 | 173 | cr.execute("update account_analytic_line set invoice_id=%%s WHERE account_id = %%s and id IN (%s)" % strids, (last_invoice,account.id,)) | 174 | "WHERE account_id = %s AND id IN %s", |
3086 | 175 | (last_invoice,account.id, tuple(data['ids']))) | ||
3087 | 174 | 176 | ||
3088 | 175 | pool.get('account.invoice').button_reset_taxes(cr, uid, [last_invoice], context) | 177 | pool.get('account.invoice').button_reset_taxes(cr, uid, [last_invoice], context) |
3089 | 176 | 178 | ||
3090 | 177 | 179 | ||
3091 | === modified file 'hr_timesheet_sheet/hr_timesheet_sheet.py' | |||
3092 | --- hr_timesheet_sheet/hr_timesheet_sheet.py 2010-03-11 15:43:08 +0000 | |||
3093 | +++ hr_timesheet_sheet/hr_timesheet_sheet.py 2010-03-17 11:50:49 +0000 | |||
3094 | @@ -104,7 +104,7 @@ | |||
3095 | 104 | LEFT JOIN hr_timesheet_sheet_sheet_day AS day \ | 104 | LEFT JOIN hr_timesheet_sheet_sheet_day AS day \ |
3096 | 105 | ON (sheet.id = day.sheet_id \ | 105 | ON (sheet.id = day.sheet_id \ |
3097 | 106 | AND day.name = sheet.date_current) \ | 106 | AND day.name = sheet.date_current) \ |
3099 | 107 | WHERE sheet.id in (' + ','.join([str(x) for x in ids]) + ')') | 107 | WHERE sheet.id in %s', (tuple(ids),)) |
3100 | 108 | return dict(cr.fetchall()) | 108 | return dict(cr.fetchall()) |
3101 | 109 | 109 | ||
3102 | 110 | def _total(self, cr, uid, ids, name, args, context): | 110 | def _total(self, cr, uid, ids, name, args, context): |
3103 | @@ -112,8 +112,8 @@ | |||
3104 | 112 | FROM hr_timesheet_sheet_sheet s \ | 112 | FROM hr_timesheet_sheet_sheet s \ |
3105 | 113 | LEFT JOIN hr_timesheet_sheet_sheet_day d \ | 113 | LEFT JOIN hr_timesheet_sheet_sheet_day d \ |
3106 | 114 | ON (s.id = d.sheet_id) \ | 114 | ON (s.id = d.sheet_id) \ |
3109 | 115 | WHERE s.id in ('+ ','.join(map(str, ids)) + ') \ | 115 | WHERE s.id in %s \ |
3110 | 116 | GROUP BY s.id') | 116 | GROUP BY s.id', (tuple(ids),)) |
3111 | 117 | return dict(cr.fetchall()) | 117 | return dict(cr.fetchall()) |
3112 | 118 | 118 | ||
3113 | 119 | def _state_attendance(self, cr, uid, ids, name, args, context): | 119 | def _state_attendance(self, cr, uid, ids, name, args, context): |
3114 | @@ -330,8 +330,8 @@ | |||
3115 | 330 | ON (s.date_to >= al.date \ | 330 | ON (s.date_to >= al.date \ |
3116 | 331 | AND s.date_from <= al.date \ | 331 | AND s.date_from <= al.date \ |
3117 | 332 | AND s.user_id = al.user_id) \ | 332 | AND s.user_id = al.user_id) \ |
3120 | 333 | WHERE l.id in (' + ','.join([str(x) for x in ids]) + ') \ | 333 | WHERE l.id in %s \ |
3121 | 334 | GROUP BY l.id') | 334 | GROUP BY l.id', (tuple(ids),)) |
3122 | 335 | res = dict(cursor.fetchall()) | 335 | res = dict(cursor.fetchall()) |
3123 | 336 | sheet_names = {} | 336 | sheet_names = {} |
3124 | 337 | for sheet_id, name in sheet_obj.name_get(cursor, user, res.values(), | 337 | for sheet_id, name in sheet_obj.name_get(cursor, user, res.values(), |
3125 | @@ -448,8 +448,8 @@ | |||
3126 | 448 | ON (s.date_to >= to_date(to_char(a.name, 'YYYY-MM-dd'),'YYYY-MM-dd') \ | 448 | ON (s.date_to >= to_date(to_char(a.name, 'YYYY-MM-dd'),'YYYY-MM-dd') \ |
3127 | 449 | AND s.date_from <= to_date(to_char(a.name, 'YYYY-MM-dd'),'YYYY-MM-dd') \ | 449 | AND s.date_from <= to_date(to_char(a.name, 'YYYY-MM-dd'),'YYYY-MM-dd') \ |
3128 | 450 | AND s.user_id = e.user_id) \ | 450 | AND s.user_id = e.user_id) \ |
3131 | 451 | WHERE a.id in (" + ",".join([str(x) for x in ids]) + ") \ | 451 | WHERE a.id in %s \ |
3132 | 452 | GROUP BY a.id") | 452 | GROUP BY a.id", (tuple(ids),)) |
3133 | 453 | res = dict(cursor.fetchall()) | 453 | res = dict(cursor.fetchall()) |
3134 | 454 | sheet_names = {} | 454 | sheet_names = {} |
3135 | 455 | for sheet_id, name in sheet_obj.name_get(cursor, user, res.values(), | 455 | for sheet_id, name in sheet_obj.name_get(cursor, user, res.values(), |
3136 | 456 | 456 | ||
3137 | === modified file 'idea/idea.py' | |||
3138 | --- idea/idea.py 2009-01-04 22:12:50 +0000 | |||
3139 | +++ idea/idea.py 2010-03-17 11:50:49 +0000 | |||
3140 | @@ -48,40 +48,40 @@ | |||
3141 | 48 | if not len(ids): | 48 | if not len(ids): |
3142 | 49 | return {} | 49 | return {} |
3143 | 50 | 50 | ||
3145 | 51 | sql = """select i.id, avg(v.score::integer) | 51 | sql = """select i.id, avg(v.score::integer) |
3146 | 52 | from idea_idea i left outer join idea_vote v on i.id = v.idea_id | 52 | from idea_idea i left outer join idea_vote v on i.id = v.idea_id |
3148 | 53 | where i.id in (%s) | 53 | where i.id in %s |
3149 | 54 | group by i.id | 54 | group by i.id |
3151 | 55 | """ % ','.join(['%d']*len(ids)) | 55 | """ |
3152 | 56 | 56 | ||
3154 | 57 | cr.execute(sql, ids) | 57 | cr.execute(sql, (tuple(ids),)) |
3155 | 58 | return dict(cr.fetchall()) | 58 | return dict(cr.fetchall()) |
3156 | 59 | 59 | ||
3157 | 60 | def _vote_count(self,cr,uid,ids,name,arg,context=None): | 60 | def _vote_count(self,cr,uid,ids,name,arg,context=None): |
3158 | 61 | if not len(ids): | 61 | if not len(ids): |
3159 | 62 | return {} | 62 | return {} |
3160 | 63 | 63 | ||
3162 | 64 | sql = """select i.id, count(1) | 64 | sql = """select i.id, count(1) |
3163 | 65 | from idea_idea i left outer join idea_vote v on i.id = v.idea_id | 65 | from idea_idea i left outer join idea_vote v on i.id = v.idea_id |
3165 | 66 | where i.id in (%s) | 66 | where i.id in %s |
3166 | 67 | group by i.id | 67 | group by i.id |
3168 | 68 | """ % ','.join(['%d']*len(ids)) | 68 | """ |
3169 | 69 | 69 | ||
3171 | 70 | cr.execute(sql, ids) | 70 | cr.execute(sql, (tuple(ids),)) |
3172 | 71 | return dict(cr.fetchall()) | 71 | return dict(cr.fetchall()) |
3173 | 72 | 72 | ||
3174 | 73 | def _comment_count(self,cr,uid,ids,name,arg,context=None): | 73 | def _comment_count(self,cr,uid,ids,name,arg,context=None): |
3175 | 74 | if not len(ids): | 74 | if not len(ids): |
3176 | 75 | return {} | 75 | return {} |
3177 | 76 | 76 | ||
3179 | 77 | sql = """select i.id, count(1) | 77 | sql = """select i.id, count(1) |
3180 | 78 | from idea_idea i left outer join idea_comment c on i.id = c.idea_id | 78 | from idea_idea i left outer join idea_comment c on i.id = c.idea_id |
3182 | 79 | where i.id in (%s) | 79 | where i.id in %s |
3183 | 80 | group by i.id | 80 | group by i.id |
3188 | 81 | """ % ','.join(['%d']*len(ids)) | 81 | """ |
3189 | 82 | 82 | ||
3190 | 83 | 83 | ||
3191 | 84 | cr.execute(sql,ids) | 84 | cr.execute(sql, (tuple(ids),)) |
3192 | 85 | return dict(cr.fetchall()) | 85 | return dict(cr.fetchall()) |
3193 | 86 | 86 | ||
3194 | 87 | def _vote_read(self, cr, uid, ids, name, arg, context = None): | 87 | def _vote_read(self, cr, uid, ids, name, arg, context = None): |
3195 | 88 | 88 | ||
3196 | === modified file 'l10n_be/wizard/wizard_vat_intra.py' | |||
3197 | --- l10n_be/wizard/wizard_vat_intra.py 2009-03-24 11:01:43 +0000 | |||
3198 | +++ l10n_be/wizard/wizard_vat_intra.py 2010-03-17 11:50:49 +0000 | |||
3199 | @@ -169,11 +169,9 @@ | |||
3200 | 169 | start_date = fiscal_periods[3].date_start | 169 | start_date = fiscal_periods[3].date_start |
3201 | 170 | end_date = fiscal_periods[3].date_stop | 170 | end_date = fiscal_periods[3].date_stop |
3202 | 171 | 171 | ||
3203 | 172 | period = "to_date('" + str(start_date) + "','yyyy-mm-dd') and to_date('" + str(end_date) +"','yyyy-mm-dd')" | ||
3204 | 173 | record = {} | 172 | record = {} |
3205 | 174 | 173 | ||
3206 | 175 | for p_id in p_id_list: | 174 | for p_id in p_id_list: |
3207 | 176 | list_partner = [] | ||
3208 | 177 | partner = pool.get('res.partner').browse(cr, uid, p_id) | 175 | partner = pool.get('res.partner').browse(cr, uid, p_id) |
3209 | 178 | go_ahead = False | 176 | go_ahead = False |
3210 | 179 | country_code = '' | 177 | country_code = '' |
3211 | @@ -185,27 +183,22 @@ | |||
3212 | 185 | if not go_ahead: | 183 | if not go_ahead: |
3213 | 186 | continue | 184 | continue |
3214 | 187 | 185 | ||
3216 | 188 | cr.execute('select sum(debit)-sum(credit) as amount from account_move_line l left join account_account a on (l.account_id=a.id) where a.type in ('"'receivable'"') and l.partner_id=%%s and l.date between %s' % (period,), (p_id,)) | 186 | cr.execute('SELECT SUM(debit)-SUM(credit) AS amount '\ |
3217 | 187 | 'FROM account_move_line l '\ | ||
3218 | 188 | 'LEFT JOIN account_account a ON (l.account_id=a.id) '\ | ||
3219 | 189 | 'WHERE a.type IN ('"'receivable'"') '\ | ||
3220 | 190 | 'AND l.partner_id=%s '\ | ||
3221 | 191 | 'AND l.date BETWEEN to_date(%s, \'yyyy-mm-dd\') '\ | ||
3222 | 192 | ' AND to_date(%s, \'yyyy-mm-dd\')', | ||
3223 | 193 | (p_id, start_date, end_date)) | ||
3224 | 189 | res = cr.dictfetchall() | 194 | res = cr.dictfetchall() |
3244 | 190 | list_partner.append(res[0]['amount']) | 195 | |
3245 | 191 | list_partner.append('T') #partner.ref ...should be check | 196 | record[p_id] = ( |
3246 | 192 | list_partner.append(partner.vat) | 197 | res[0]['amount'], |
3247 | 193 | list_partner.append(country_code) | 198 | 'T', #partner.ref ...should be check |
3248 | 194 | #...deprecated... | 199 | partner.vat, |
3249 | 195 | # addr = pool.get('res.partner').address_get(cr, uid, [partner.id], ['invoice']) | 200 | country_code |
3250 | 196 | # if addr.get('invoice',False): | 201 | ) |
3232 | 197 | # ads = pool.get('res.partner.address').browse(cr,uid,[addr['invoice']])[0] | ||
3233 | 198 | # | ||
3234 | 199 | # if ads.country_id: | ||
3235 | 200 | # code_country = ads.country_id.code | ||
3236 | 201 | # list_partner.append(code_country) | ||
3237 | 202 | # else: | ||
3238 | 203 | # error_message.append('Data Insufficient! : '+ 'The Partner "'+partner.name + '"'' has no country associated with its Invoice address!') | ||
3239 | 204 | # if len(list_partner)<4: | ||
3240 | 205 | # list_partner.append('') | ||
3241 | 206 | # error_message.append('Data Insufficient! : '+ 'The Partner "'+partner.name + '"'' has no Invoice address!') | ||
3242 | 207 | # list_partner.append(code_country or 'not avail') | ||
3243 | 208 | record[p_id] = list_partner | ||
3251 | 209 | 202 | ||
3252 | 210 | if len(error_message): | 203 | if len(error_message): |
3253 | 211 | data['form']['msg'] = 'Exception : \n' +'-'*50+'\n'+ '\n'.join(error_message) | 204 | data['form']['msg'] = 'Exception : \n' +'-'*50+'\n'+ '\n'.join(error_message) |
3254 | @@ -235,4 +228,4 @@ | |||
3255 | 235 | 'result': {'type':'form', 'arch':msg_form, 'fields':msg_fields, 'state':[('end','Ok')]}, | 228 | 'result': {'type':'form', 'arch':msg_form, 'fields':msg_fields, 'state':[('end','Ok')]}, |
3256 | 236 | } | 229 | } |
3257 | 237 | } | 230 | } |
3258 | 238 | parter_vat_intra('vat.intra.xml') | ||
3259 | 239 | \ No newline at end of file | 231 | \ No newline at end of file |
3260 | 232 | parter_vat_intra('vat.intra.xml') | ||
3261 | 240 | 233 | ||
3262 | === modified file 'membership/membership.py' | |||
3263 | --- membership/membership.py 2010-02-26 13:36:01 +0000 | |||
3264 | +++ membership/membership.py 2010-03-17 11:50:49 +0000 | |||
3265 | @@ -148,8 +148,8 @@ | |||
3266 | 148 | ) | 148 | ) |
3267 | 149 | JOIN account_invoice ai ON ( | 149 | JOIN account_invoice ai ON ( |
3268 | 150 | ai.id = ail.invoice_id) | 150 | ai.id = ail.invoice_id) |
3271 | 151 | WHERE ml.id in (%s) | 151 | WHERE ml.id in %s |
3272 | 152 | ''' % ','.join([str(id) for id in ids])) | 152 | ''', (tuple(ids),)) |
3273 | 153 | 153 | ||
3274 | 154 | res = cr.fetchall() | 154 | res = cr.fetchall() |
3275 | 155 | for r in res: | 155 | for r in res: |
3276 | @@ -414,7 +414,7 @@ | |||
3277 | 414 | def _check_recursion(self, cr, uid, ids): | 414 | def _check_recursion(self, cr, uid, ids): |
3278 | 415 | level = 100 | 415 | level = 100 |
3279 | 416 | while len(ids): | 416 | while len(ids): |
3281 | 417 | cr.execute('select distinct associate_member from res_partner where id in ('+','.join(map(str,ids))+')') | 417 | cr.execute('select distinct associate_member from res_partner where id in %s', (tuple(ids),)) |
3282 | 418 | ids = filter(None, map(lambda x:x[0], cr.fetchall())) | 418 | ids = filter(None, map(lambda x:x[0], cr.fetchall())) |
3283 | 419 | if not level: | 419 | if not level: |
3284 | 420 | return False | 420 | return False |
3285 | 421 | 421 | ||
3286 | === modified file 'membership/wizard/invoice_membership.py' | |||
3287 | --- membership/wizard/invoice_membership.py 2009-11-13 06:33:46 +0000 | |||
3288 | +++ membership/wizard/invoice_membership.py 2010-03-17 11:50:49 +0000 | |||
3289 | @@ -32,9 +32,8 @@ | |||
3290 | 32 | cr.execute(''' | 32 | cr.execute(''' |
3291 | 33 | SELECT partner_id, id, type | 33 | SELECT partner_id, id, type |
3292 | 34 | FROM res_partner_address | 34 | FROM res_partner_address |
3296 | 35 | WHERE partner_id IN (%s) | 35 | WHERE partner_id IN %s |
3297 | 36 | ''' % ','.join([str(id) for id in partner_ids]) | 36 | ''', (tuple(partner_ids),)) |
3295 | 37 | ) | ||
3298 | 38 | fetchal = cr.fetchall() | 37 | fetchal = cr.fetchall() |
3299 | 39 | if not fetchal: | 38 | if not fetchal: |
3300 | 40 | raise wizard.except_wizard(_('Error !'), _('No Address defined for this partner')) | 39 | raise wizard.except_wizard(_('Error !'), _('No Address defined for this partner')) |
3301 | 41 | 40 | ||
3302 | === modified file 'mrp/mrp.py' | |||
3303 | --- mrp/mrp.py 2010-03-10 08:51:21 +0000 | |||
3304 | +++ mrp/mrp.py 2010-03-17 11:50:49 +0000 | |||
3305 | @@ -216,7 +216,7 @@ | |||
3306 | 216 | def _check_recursion(self, cr, uid, ids): | 216 | def _check_recursion(self, cr, uid, ids): |
3307 | 217 | level = 500 | 217 | level = 500 |
3308 | 218 | while len(ids): | 218 | while len(ids): |
3310 | 219 | cr.execute('select distinct bom_id from mrp_bom where id in ('+','.join(map(str,ids))+')') | 219 | cr.execute('select distinct bom_id from mrp_bom where id in %s', (tuple(ids),)) |
3311 | 220 | ids = filter(None, map(lambda x:x[0], cr.fetchall())) | 220 | ids = filter(None, map(lambda x:x[0], cr.fetchall())) |
3312 | 221 | if not level: | 221 | if not level: |
3313 | 222 | return False | 222 | return False |
3314 | 223 | 223 | ||
3315 | === modified file 'mrp/report/workcenter_load.py' | |||
3316 | --- mrp/report/workcenter_load.py 2009-09-28 14:26:44 +0000 | |||
3317 | +++ mrp/report/workcenter_load.py 2010-03-17 11:50:49 +0000 | |||
3318 | @@ -99,14 +99,13 @@ | |||
3319 | 99 | def create(self, cr, uid, ids, datas, context={}): | 99 | def create(self, cr, uid, ids, datas, context={}): |
3320 | 100 | assert len(ids), 'You should provide some ids!' | 100 | assert len(ids), 'You should provide some ids!' |
3321 | 101 | colors = choice_colors(len(ids)) | 101 | colors = choice_colors(len(ids)) |
3322 | 102 | ids_str = ','.join(map(str, ids)) | ||
3323 | 103 | cr.execute( | 102 | cr.execute( |
3324 | 104 | "SELECT MAX(mrp_production.date_planned) AS stop,MIN(mrp_production.date_planned) AS start "\ | 103 | "SELECT MAX(mrp_production.date_planned) AS stop,MIN(mrp_production.date_planned) AS start "\ |
3325 | 105 | "FROM mrp_workcenter, mrp_production, mrp_production_workcenter_line "\ | 104 | "FROM mrp_workcenter, mrp_production, mrp_production_workcenter_line "\ |
3326 | 106 | "WHERE mrp_production_workcenter_line.production_id=mrp_production.id "\ | 105 | "WHERE mrp_production_workcenter_line.production_id=mrp_production.id "\ |
3327 | 107 | "AND mrp_production_workcenter_line.workcenter_id=mrp_workcenter.id "\ | 106 | "AND mrp_production_workcenter_line.workcenter_id=mrp_workcenter.id "\ |
3328 | 108 | "AND mrp_production.state NOT IN ('cancel','done') "\ | 107 | "AND mrp_production.state NOT IN ('cancel','done') "\ |
3330 | 109 | "AND mrp_workcenter.id IN (%s)" % ids_str) | 108 | "AND mrp_workcenter.id IN %s", (tuple(ids),)) |
3331 | 110 | res = cr.dictfetchone() | 109 | res = cr.dictfetchone() |
3332 | 111 | if not res['stop']: | 110 | if not res['stop']: |
3333 | 112 | res['stop'] = time.strftime('%Y-%m-%d %H:%M:%S') | 111 | res['stop'] = time.strftime('%Y-%m-%d %H:%M:%S') |
3334 | @@ -137,8 +136,8 @@ | |||
3335 | 137 | # select workcenters | 136 | # select workcenters |
3336 | 138 | cr.execute( | 137 | cr.execute( |
3337 | 139 | "SELECT id, name FROM mrp_workcenter " \ | 138 | "SELECT id, name FROM mrp_workcenter " \ |
3340 | 140 | "WHERE id in (%s) "\ | 139 | "WHERE id in %s "\ |
3341 | 141 | "ORDER BY mrp_workcenter.id" % ids_str) | 140 | "ORDER BY mrp_workcenter.id", (tuple(ids),)) |
3342 | 142 | workcenters = cr.dictfetchall() | 141 | workcenters = cr.dictfetchall() |
3343 | 143 | 142 | ||
3344 | 144 | data = [] | 143 | data = [] |
3345 | 145 | 144 | ||
3346 | === modified file 'point_of_sale/pos.py' | |||
3347 | --- point_of_sale/pos.py 2010-02-03 05:47:12 +0000 | |||
3348 | +++ point_of_sale/pos.py 2010-03-17 11:50:49 +0000 | |||
3349 | @@ -60,7 +60,6 @@ | |||
3350 | 60 | return {'value': {'pricelist_id': pricelist}} | 60 | return {'value': {'pricelist_id': pricelist}} |
3351 | 61 | 61 | ||
3352 | 62 | def _amount_total(self, cr, uid, ids, field_name, arg, context): | 62 | def _amount_total(self, cr, uid, ids, field_name, arg, context): |
3353 | 63 | id_set = ",".join(map(str, ids)) | ||
3354 | 64 | cr.execute(""" | 63 | cr.execute(""" |
3355 | 65 | SELECT | 64 | SELECT |
3356 | 66 | p.id, | 65 | p.id, |
3357 | @@ -69,7 +68,7 @@ | |||
3358 | 69 | ) AS amount | 68 | ) AS amount |
3359 | 70 | FROM pos_order p | 69 | FROM pos_order p |
3360 | 71 | LEFT OUTER JOIN pos_order_line l ON (p.id=l.order_id) | 70 | LEFT OUTER JOIN pos_order_line l ON (p.id=l.order_id) |
3362 | 72 | WHERE p.id IN (""" + id_set +""") GROUP BY p.id """) | 71 | WHERE p.id IN %s GROUP BY p.id """, (tuple(ids),)) |
3363 | 73 | res = dict(cr.fetchall()) | 72 | res = dict(cr.fetchall()) |
3364 | 74 | 73 | ||
3365 | 75 | for rec in self.browse(cr, uid, ids, context): | 74 | for rec in self.browse(cr, uid, ids, context): |
3366 | @@ -113,8 +112,8 @@ | |||
3367 | 113 | return res | 112 | return res |
3368 | 114 | 113 | ||
3369 | 115 | def payment_get(self, cr, uid, ids, context=None): | 114 | def payment_get(self, cr, uid, ids, context=None): |
3372 | 116 | cr.execute("select id from pos_payment where order_id in (%s)" % \ | 115 | cr.execute("select id from pos_payment where order_id in %s", |
3373 | 117 | ','.join([str(i) for i in ids])) | 116 | (tuple(ids),)) |
3374 | 118 | return [i[0] for i in cr.fetchall()] | 117 | return [i[0] for i in cr.fetchall()] |
3375 | 119 | 118 | ||
3376 | 120 | def _sale_journal_get(self, cr, uid, context): | 119 | def _sale_journal_get(self, cr, uid, context): |
3377 | 121 | 120 | ||
3378 | === modified file 'product/pricelist.py' | |||
3379 | --- product/pricelist.py 2010-02-04 07:12:40 +0000 | |||
3380 | +++ product/pricelist.py 2010-03-17 11:50:49 +0000 | |||
3381 | @@ -22,7 +22,6 @@ | |||
3382 | 22 | 22 | ||
3383 | 23 | from osv import fields, osv | 23 | from osv import fields, osv |
3384 | 24 | 24 | ||
3385 | 25 | #from tools.misc import currency | ||
3386 | 26 | from _common import rounding | 25 | from _common import rounding |
3387 | 27 | import time | 26 | import time |
3388 | 28 | from tools import config | 27 | from tools import config |
3389 | @@ -91,8 +90,6 @@ | |||
3390 | 91 | res.append((type['key'],type['name'])) | 90 | res.append((type['key'],type['name'])) |
3391 | 92 | 91 | ||
3392 | 93 | return res | 92 | return res |
3393 | 94 | # cr.execute('select key,name from product_pricelist_type order by name') | ||
3394 | 95 | # return cr.fetchall() | ||
3395 | 96 | _name = "product.pricelist" | 93 | _name = "product.pricelist" |
3396 | 97 | _description = "Pricelist" | 94 | _description = "Pricelist" |
3397 | 98 | _columns = { | 95 | _columns = { |
3398 | @@ -179,9 +176,11 @@ | |||
3399 | 179 | 'you have defined cyclic categories ' \ | 176 | 'you have defined cyclic categories ' \ |
3400 | 180 | 'of products!')) | 177 | 'of products!')) |
3401 | 181 | if categ_ids: | 178 | if categ_ids: |
3403 | 182 | categ_where = '(categ_id IN (' + ','.join(categ_ids) + '))' | 179 | categ_where = '(categ_id IN %s)' |
3404 | 180 | sqlargs = (tuple(categ_ids),) | ||
3405 | 183 | else: | 181 | else: |
3406 | 184 | categ_where = '(categ_id IS NULL)' | 182 | categ_where = '(categ_id IS NULL)' |
3407 | 183 | sqlargs = () | ||
3408 | 185 | 184 | ||
3409 | 186 | cr.execute( | 185 | cr.execute( |
3410 | 187 | 'SELECT i.*, pl.currency_id ' | 186 | 'SELECT i.*, pl.currency_id ' |
3411 | @@ -194,7 +193,7 @@ | |||
3412 | 194 | 'AND (min_quantity IS NULL OR min_quantity <= %s) ' | 193 | 'AND (min_quantity IS NULL OR min_quantity <= %s) ' |
3413 | 195 | 'AND i.price_version_id = v.id AND v.pricelist_id = pl.id ' | 194 | 'AND i.price_version_id = v.id AND v.pricelist_id = pl.id ' |
3414 | 196 | 'ORDER BY sequence LIMIT 1', | 195 | 'ORDER BY sequence LIMIT 1', |
3416 | 197 | (tmpl_id, prod_id, plversion['id'], qty)) | 196 | (tmpl_id, prod_id) + sqlargs + ( plversion['id'], qty)) |
3417 | 198 | res = cr.dictfetchone() | 197 | res = cr.dictfetchone() |
3418 | 199 | if res: | 198 | if res: |
3419 | 200 | if res['base'] == -1: | 199 | if res['base'] == -1: |
3420 | @@ -218,10 +217,10 @@ | |||
3421 | 218 | if sinfo: | 217 | if sinfo: |
3422 | 219 | cr.execute('SELECT * ' \ | 218 | cr.execute('SELECT * ' \ |
3423 | 220 | 'FROM pricelist_partnerinfo ' \ | 219 | 'FROM pricelist_partnerinfo ' \ |
3426 | 221 | 'WHERE suppinfo_id IN (' + \ | 220 | 'WHERE suppinfo_id IN %s ' \ |
3425 | 222 | ','.join(map(str, sinfo)) + ') ' \ | ||
3427 | 223 | 'AND min_quantity <= %s ' \ | 221 | 'AND min_quantity <= %s ' \ |
3429 | 224 | 'ORDER BY min_quantity DESC LIMIT 1', (qty,)) | 222 | 'ORDER BY min_quantity DESC LIMIT 1', |
3430 | 223 | (tuple(sinfo), qty)) | ||
3431 | 225 | res2 = cr.dictfetchone() | 224 | res2 = cr.dictfetchone() |
3432 | 226 | if res2: | 225 | if res2: |
3433 | 227 | price = res2['price'] | 226 | price = res2['price'] |
3434 | @@ -382,7 +381,4 @@ | |||
3435 | 382 | return {} | 381 | return {} |
3436 | 383 | product_pricelist_item() | 382 | product_pricelist_item() |
3437 | 384 | 383 | ||
3438 | 385 | |||
3439 | 386 | |||
3440 | 387 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | 384 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
3441 | 388 | |||
3442 | 389 | 385 | ||
3443 | === modified file 'product/product.py' | |||
3444 | --- product/product.py 2010-03-15 11:10:51 +0000 | |||
3445 | +++ product/product.py 2010-03-17 11:50:49 +0000 | |||
3446 | @@ -206,7 +206,7 @@ | |||
3447 | 206 | def _check_recursion(self, cr, uid, ids): | 206 | def _check_recursion(self, cr, uid, ids): |
3448 | 207 | level = 100 | 207 | level = 100 |
3449 | 208 | while len(ids): | 208 | while len(ids): |
3451 | 209 | cr.execute('select distinct parent_id from product_category where id in ('+','.join(map(str,ids))+')') | 209 | cr.execute('select distinct parent_id from product_category where id in %s', (tuple(ids),)) |
3452 | 210 | ids = filter(None, map(lambda x:x[0], cr.fetchall())) | 210 | ids = filter(None, map(lambda x:x[0], cr.fetchall())) |
3453 | 211 | if not level: | 211 | if not level: |
3454 | 212 | return False | 212 | return False |
3455 | 213 | 213 | ||
3456 | === modified file 'product_margin/product_margin.py' | |||
3457 | --- product_margin/product_margin.py 2009-01-04 22:12:50 +0000 | |||
3458 | +++ product_margin/product_margin.py 2010-03-17 11:50:49 +0000 | |||
3459 | @@ -1,7 +1,7 @@ | |||
3460 | 1 | # -*- encoding: utf-8 -*- | 1 | # -*- encoding: utf-8 -*- |
3461 | 2 | ############################################################################## | 2 | ############################################################################## |
3462 | 3 | # | 3 | # |
3464 | 4 | # OpenERP, Open Source Management Solution | 4 | # OpenERP, Open Source Management Solution |
3465 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved |
3466 | 6 | # $Id$ | 6 | # $Id$ |
3467 | 7 | # | 7 | # |
3468 | @@ -25,53 +25,52 @@ | |||
3469 | 25 | from tools import config | 25 | from tools import config |
3470 | 26 | import time | 26 | import time |
3471 | 27 | 27 | ||
3472 | 28 | states = { | ||
3473 | 29 | 'paid': ('paid',), | ||
3474 | 30 | 'open_paid': ('open','paid'), | ||
3475 | 31 | 'draft_open_paid': ('draft','open','paid') | ||
3476 | 32 | } | ||
3477 | 33 | |||
3478 | 28 | class product_product(osv.osv): | 34 | class product_product(osv.osv): |
3482 | 29 | _inherit = "product.product" | 35 | _inherit = "product.product" |
3483 | 30 | 36 | ||
3484 | 31 | 37 | ||
3485 | 32 | def _product_margin(self, cr, uid, ids, field_names, arg, context): | 38 | def _product_margin(self, cr, uid, ids, field_names, arg, context): |
3487 | 33 | res = {} | 39 | res = {} |
3488 | 34 | for val in self.browse(cr, uid, ids,context=context): | 40 | for val in self.browse(cr, uid, ids,context=context): |
3489 | 35 | res[val.id] = {} | 41 | res[val.id] = {} |
3493 | 36 | date_from=context.get('date_from', time.strftime('%Y-01-01')) | 42 | date_from=context.get('date_from', time.strftime('%Y-01-01')) |
3494 | 37 | date_to=context.get('date_to', time.strftime('%Y-12-31')) | 43 | date_to=context.get('date_to', time.strftime('%Y-12-31')) |
3495 | 38 | invoice_state=context.get('invoice_state', 'open_paid') | 44 | invoice_state=context.get('invoice_state', 'open_paid') |
3496 | 39 | if 'date_from' in field_names: | 45 | if 'date_from' in field_names: |
3498 | 40 | res[val.id]['date_from']=date_from | 46 | res[val.id]['date_from']=date_from |
3499 | 41 | if 'date_to' in field_names: | 47 | if 'date_to' in field_names: |
3500 | 42 | res[val.id]['date_to']=date_to | 48 | res[val.id]['date_to']=date_to |
3501 | 43 | if 'invoice_state' in field_names: | 49 | if 'invoice_state' in field_names: |
3503 | 44 | res[val.id]['invoice_state']=invoice_state | 50 | res[val.id]['invoice_state']=invoice_state |
3504 | 45 | 51 | ||
3515 | 46 | 52 | invoice_types=() | |
3506 | 47 | invoice_types=[] | ||
3507 | 48 | states=[] | ||
3508 | 49 | if invoice_state=='paid': | ||
3509 | 50 | states=['paid'] | ||
3510 | 51 | elif invoice_state=='open_paid': | ||
3511 | 52 | states=['open','paid'] | ||
3512 | 53 | elif invoice_state=='draft_open_paid': | ||
3513 | 54 | states=['draft','open','paid'] | ||
3514 | 55 | |||
3516 | 56 | if 'sale_avg_price' in field_names or 'sale_num_invoiced' in field_names or 'turnover' in field_names or 'sale_expected' in field_names: | 53 | if 'sale_avg_price' in field_names or 'sale_num_invoiced' in field_names or 'turnover' in field_names or 'sale_expected' in field_names: |
3518 | 57 | invoice_types=['out_invoice','in_refund'] | 54 | invoice_types=('out_invoice','in_refund') |
3519 | 58 | if 'purchase_avg_price' in field_names or 'purchase_num_invoiced' in field_names or 'total_cost' in field_names or 'normal_cost' in field_names: | 55 | if 'purchase_avg_price' in field_names or 'purchase_num_invoiced' in field_names or 'total_cost' in field_names or 'normal_cost' in field_names: |
3522 | 59 | invoice_types=['in_invoice','out_refund'] | 56 | invoice_types=('in_invoice','out_refund') |
3523 | 60 | if len(invoice_types): | 57 | |
3524 | 58 | if invoice_types: | ||
3525 | 61 | sql=""" | 59 | sql=""" |
3532 | 62 | select | 60 | select |
3533 | 63 | avg(l.price_unit) as avg_unit_price, | 61 | avg(l.price_unit) as avg_unit_price, |
3534 | 64 | sum(l.quantity) as num_qty, | 62 | sum(l.quantity) as num_qty, |
3535 | 65 | sum(l.quantity * l.price_unit) as total, | 63 | sum(l.quantity * l.price_unit) as total, |
3536 | 66 | sum(l.quantity * product.list_price) as sale_expected, | 64 | sum(l.quantity * product.list_price) as sale_expected, |
3537 | 67 | sum(l.quantity * product.standard_price) as normal_cost | 65 | sum(l.quantity * product.standard_price) as normal_cost |
3538 | 68 | from account_invoice_line l | 66 | from account_invoice_line l |
3539 | 69 | left join account_invoice i on (l.invoice_id = i.id) | 67 | left join account_invoice i on (l.invoice_id = i.id) |
3545 | 70 | left join product_template product on (product.id=l.product_id) | 68 | left join product_template product on (product.id=l.product_id) |
3546 | 71 | where l.product_id = %s and i.state in ('%s') and i.type in ('%s') and i.date_invoice>='%s' and i.date_invoice<='%s' | 69 | where l.product_id = %s and i.state in %s and i.type in %s and i.date_invoice>=%s and i.date_invoice<=%s |
3547 | 72 | """%(val.id,"','".join(states),"','".join(invoice_types),date_from,date_to) | 70 | """ |
3548 | 73 | cr.execute(sql) | 71 | cr.execute(sql, (val.id, states[invoice_state], |
3549 | 74 | result=cr.fetchall()[0] | 72 | invoice_types, date_from, date_to)) |
3550 | 73 | result=cr.fetchall()[0] | ||
3551 | 75 | if 'sale_avg_price' in field_names or 'sale_num_invoiced' in field_names or 'turnover' in field_names or 'sale_expected' in field_names: | 74 | if 'sale_avg_price' in field_names or 'sale_num_invoiced' in field_names or 'turnover' in field_names or 'sale_expected' in field_names: |
3552 | 76 | res[val.id]['sale_avg_price']=result[0] and result[0] or 0.0 | 75 | res[val.id]['sale_avg_price']=result[0] and result[0] or 0.0 |
3553 | 77 | res[val.id]['sale_num_invoiced']=result[1] and result[1] or 0.0 | 76 | res[val.id]['sale_num_invoiced']=result[1] and result[1] or 0.0 |
3554 | @@ -83,8 +82,8 @@ | |||
3555 | 83 | res[val.id]['purchase_num_invoiced']=result[1] and result[1] or 0.0 | 82 | res[val.id]['purchase_num_invoiced']=result[1] and result[1] or 0.0 |
3556 | 84 | res[val.id]['total_cost']=result[2] and result[2] or 0.0 | 83 | res[val.id]['total_cost']=result[2] and result[2] or 0.0 |
3557 | 85 | res[val.id]['normal_cost']=result[4] and result[4] or 0.0 | 84 | res[val.id]['normal_cost']=result[4] and result[4] or 0.0 |
3560 | 86 | res[val.id]['purchase_gap']=res[val.id]['normal_cost']-res[val.id]['total_cost'] | 85 | res[val.id]['purchase_gap']=res[val.id]['normal_cost']-res[val.id]['total_cost'] |
3561 | 87 | 86 | ||
3562 | 88 | if 'total_margin' in field_names: | 87 | if 'total_margin' in field_names: |
3563 | 89 | res[val.id]['total_margin']=val.turnover-val.total_cost | 88 | res[val.id]['total_margin']=val.turnover-val.total_cost |
3564 | 90 | if 'expected_margin' in field_names: | 89 | if 'expected_margin' in field_names: |
3565 | @@ -92,15 +91,15 @@ | |||
3566 | 92 | if 'total_margin_rate' in field_names: | 91 | if 'total_margin_rate' in field_names: |
3567 | 93 | res[val.id]['total_margin_rate']=val.turnover and val.total_margin * 100 / val.turnover or 0.0 | 92 | res[val.id]['total_margin_rate']=val.turnover and val.total_margin * 100 / val.turnover or 0.0 |
3568 | 94 | if 'expected_margin_rate' in field_names: | 93 | if 'expected_margin_rate' in field_names: |
3570 | 95 | res[val.id]['expected_margin_rate']=val.sale_expected and val.expected_margin * 100 / val.sale_expected or 0.0 | 94 | res[val.id]['expected_margin_rate']=val.sale_expected and val.expected_margin * 100 / val.sale_expected or 0.0 |
3571 | 96 | return res | 95 | return res |
3573 | 97 | 96 | ||
3574 | 98 | _columns = { | 97 | _columns = { |
3575 | 99 | 'date_from': fields.function(_product_margin, method=True, type='date', string='From Date', multi=True), | 98 | 'date_from': fields.function(_product_margin, method=True, type='date', string='From Date', multi=True), |
3576 | 100 | 'date_to': fields.function(_product_margin, method=True, type='date', string='To Date', multi=True), | 99 | 'date_to': fields.function(_product_margin, method=True, type='date', string='To Date', multi=True), |
3577 | 101 | 'invoice_state': fields.function(_product_margin, method=True, type='selection', selection=[ | 100 | 'invoice_state': fields.function(_product_margin, method=True, type='selection', selection=[ |
3580 | 102 | ('paid','Paid'),('open_paid','Open and Paid'),('draft_open_paid','Draft, Open and Paid') | 101 | ('paid','Paid'),('open_paid','Open and Paid'),('draft_open_paid','Draft, Open and Paid') |
3581 | 103 | ], string='Invoice State',multi=True, readonly=True), | 102 | ], string='Invoice State',multi=True, readonly=True), |
3582 | 104 | 'sale_avg_price' : fields.function(_product_margin, method=True, type='float', string='Avg. Unit Price', multi='sale',help="Avg. Price in Customer Invoices)"), | 103 | 'sale_avg_price' : fields.function(_product_margin, method=True, type='float', string='Avg. Unit Price', multi='sale',help="Avg. Price in Customer Invoices)"), |
3583 | 105 | 'purchase_avg_price' : fields.function(_product_margin, method=True, type='float', string='Avg. Unit Price', multi='purchase',help="Avg. Price in Supplier Invoices "), | 104 | 'purchase_avg_price' : fields.function(_product_margin, method=True, type='float', string='Avg. Unit Price', multi='purchase',help="Avg. Price in Supplier Invoices "), |
3584 | 106 | 'sale_num_invoiced' : fields.function(_product_margin, method=True, type='float', string='# Invoiced', multi='sale',help="Sum of Quantity in Customer Invoices"), | 105 | 'sale_num_invoiced' : fields.function(_product_margin, method=True, type='float', string='# Invoiced', multi='sale',help="Sum of Quantity in Customer Invoices"), |
3585 | 107 | 106 | ||
3586 | === modified file 'project/project.py' | |||
3587 | --- project/project.py 2009-11-17 07:10:35 +0000 | |||
3588 | +++ project/project.py 2010-03-17 11:50:49 +0000 | |||
3589 | @@ -64,10 +64,11 @@ | |||
3590 | 64 | FROM | 64 | FROM |
3591 | 65 | project_task | 65 | project_task |
3592 | 66 | WHERE | 66 | WHERE |
3594 | 67 | project_id in ('''+','.join(map(str,ids2))+''') AND | 67 | project_id in %s AND |
3595 | 68 | state<>'cancelled' | 68 | state<>'cancelled' |
3596 | 69 | GROUP BY | 69 | GROUP BY |
3598 | 70 | project_id''') | 70 | project_id''', |
3599 | 71 | (tuple(ids2),)) | ||
3600 | 71 | progress = dict(map(lambda x: (x[0], (x[1],x[2],x[3])), cr.fetchall())) | 72 | progress = dict(map(lambda x: (x[0], (x[1],x[2],x[3])), cr.fetchall())) |
3601 | 72 | for project in self.browse(cr, uid, ids, context=context): | 73 | for project in self.browse(cr, uid, ids, context=context): |
3602 | 73 | s = [0.0,0.0,0.0] | 74 | s = [0.0,0.0,0.0] |
3603 | @@ -166,7 +167,7 @@ | |||
3604 | 166 | default['name'] = proj.name+_(' (copy)') | 167 | default['name'] = proj.name+_(' (copy)') |
3605 | 167 | res = super(project, self).copy(cr, uid, id, default, context) | 168 | res = super(project, self).copy(cr, uid, id, default, context) |
3606 | 168 | ids = self.search(cr, uid, [('parent_id','child_of', [res])]) | 169 | ids = self.search(cr, uid, [('parent_id','child_of', [res])]) |
3608 | 169 | cr.execute('update project_task set active=True where project_id in ('+','.join(map(str,ids))+')') | 170 | cr.execute('update project_task set active=True where project_id in %s', (tuple(ids,))) |
3609 | 170 | return res | 171 | return res |
3610 | 171 | 172 | ||
3611 | 172 | def duplicate_template(self, cr, uid, ids,context={}): | 173 | def duplicate_template(self, cr, uid, ids,context={}): |
3612 | @@ -228,8 +229,7 @@ | |||
3613 | 228 | 229 | ||
3614 | 229 | # Compute: effective_hours, total_hours, progress | 230 | # Compute: effective_hours, total_hours, progress |
3615 | 230 | def _hours_get(self, cr, uid, ids, field_names, args, context): | 231 | def _hours_get(self, cr, uid, ids, field_names, args, context): |
3618 | 231 | task_set = ','.join(map(str, ids)) | 232 | cr.execute("SELECT task_id, COALESCE(SUM(hours),0) FROM project_task_work WHERE task_id in %s GROUP BY task_id", (tuple(ids),)) |
3617 | 232 | cr.execute(("SELECT task_id, COALESCE(SUM(hours),0) FROM project_task_work WHERE task_id in (%s) GROUP BY task_id") % (task_set,)) | ||
3619 | 233 | hours = dict(cr.fetchall()) | 233 | hours = dict(cr.fetchall()) |
3620 | 234 | res = {} | 234 | res = {} |
3621 | 235 | for task in self.browse(cr, uid, ids, context=context): | 235 | for task in self.browse(cr, uid, ids, context=context): |
3622 | 236 | 236 | ||
3623 | === modified file 'purchase/purchase.py' | |||
3624 | --- purchase/purchase.py 2010-03-10 09:01:40 +0000 | |||
3625 | +++ purchase/purchase.py 2010-03-17 11:50:49 +0000 | |||
3626 | @@ -112,8 +112,9 @@ | |||
3627 | 112 | LEFT JOIN | 112 | LEFT JOIN |
3628 | 113 | stock_picking p on (p.id=m.picking_id) | 113 | stock_picking p on (p.id=m.picking_id) |
3629 | 114 | WHERE | 114 | WHERE |
3632 | 115 | p.purchase_id in ('''+','.join(map(str,ids))+''') | 115 | p.purchase_id in %s |
3633 | 116 | GROUP BY m.state, p.purchase_id''') | 116 | GROUP BY m.state, p.purchase_id''', |
3634 | 117 | (tuple(ids),)) | ||
3635 | 117 | for oid,nbr,state in cr.fetchall(): | 118 | for oid,nbr,state in cr.fetchall(): |
3636 | 118 | if state=='cancel': | 119 | if state=='cancel': |
3637 | 119 | continue | 120 | continue |
3638 | 120 | 121 | ||
3639 | === modified file 'report_account/report_receivable.py' | |||
3640 | --- report_account/report_receivable.py 2009-04-15 04:56:13 +0000 | |||
3641 | +++ report_account/report_receivable.py 2010-03-17 11:50:49 +0000 | |||
3642 | @@ -105,9 +105,9 @@ | |||
3643 | 105 | date1,date2 = period['name'].split(' to ') | 105 | date1,date2 = period['name'].split(' to ') |
3644 | 106 | query = "SELECT SUM(credit-debit) FROM account_move_line AS line, account_account as ac \ | 106 | query = "SELECT SUM(credit-debit) FROM account_move_line AS line, account_account as ac \ |
3645 | 107 | WHERE (line.account_id=ac.id) AND ac.type='receivable' \ | 107 | WHERE (line.account_id=ac.id) AND ac.type='receivable' \ |
3649 | 108 | AND (COALESCE(line.date,date) BETWEEN '%s' AND '%s') \ | 108 | AND (COALESCE(line.date,date) BETWEEN %s AND %s) \ |
3650 | 109 | AND (reconcile_id IS NULL) AND ac.active"%(str(date2),str(date1)) | 109 | AND (reconcile_id IS NULL) AND ac.active" |
3651 | 110 | cr.execute(query) | 110 | cr.execute(query, (date2, date1)) |
3652 | 111 | amount = cr.fetchone() | 111 | amount = cr.fetchone() |
3653 | 112 | amount = amount[0] or 0.00 | 112 | amount = amount[0] or 0.00 |
3654 | 113 | res[period['id']] = amount | 113 | res[period['id']] = amount |
3655 | 114 | 114 | ||
3656 | === modified file 'report_analytic_planning/report_analytic_planning.py' | |||
3657 | --- report_analytic_planning/report_analytic_planning.py 2009-01-04 22:12:50 +0000 | |||
3658 | +++ report_analytic_planning/report_analytic_planning.py 2010-03-17 11:50:49 +0000 | |||
3659 | @@ -119,8 +119,10 @@ | |||
3660 | 119 | result = {} | 119 | result = {} |
3661 | 120 | for line in self.browse(cr, uid, ids, context): | 120 | for line in self.browse(cr, uid, ids, context): |
3662 | 121 | where = '' | 121 | where = '' |
3663 | 122 | sqlarg = () | ||
3664 | 122 | if line.user_id: | 123 | if line.user_id: |
3666 | 123 | where='user_id='+str(line.user_id.id)+' and ' | 124 | where='user_id=%s and ' |
3667 | 125 | sqlarg = (line.user_id.id) | ||
3668 | 124 | cr.execute('''select | 126 | cr.execute('''select |
3669 | 125 | sum(planned_hours) | 127 | sum(planned_hours) |
3670 | 126 | from | 128 | from |
3671 | @@ -129,11 +131,11 @@ | |||
3672 | 129 | '''+where+''' | 131 | '''+where+''' |
3673 | 130 | project_id in (select id from project_project where category_id=%s) and | 132 | project_id in (select id from project_project where category_id=%s) and |
3674 | 131 | date_close>=%s and | 133 | date_close>=%s and |
3680 | 132 | date_close<=%s''', ( | 134 | date_close<=%s''', |
3681 | 133 | line.account_id.id, | 135 | sqlarg + ( |
3682 | 134 | line.planning_id.date_from, | 136 | line.account_id.id, |
3683 | 135 | line.planning_id.date_to) | 137 | line.planning_id.date_from, |
3684 | 136 | ) | 138 | line.planning_id.date_to)) |
3685 | 137 | result[line.id] = cr.fetchone()[0] | 139 | result[line.id] = cr.fetchone()[0] |
3686 | 138 | return result | 140 | return result |
3687 | 139 | _columns = { | 141 | _columns = { |
3688 | 140 | 142 | ||
3689 | === modified file 'report_crm/report_crm.py' | |||
3690 | --- report_crm/report_crm.py 2009-03-20 11:28:18 +0000 | |||
3691 | +++ report_crm/report_crm.py 2010-03-17 11:50:49 +0000 | |||
3692 | @@ -1,7 +1,7 @@ | |||
3693 | 1 | # -*- encoding: utf-8 -*- | 1 | # -*- encoding: utf-8 -*- |
3694 | 2 | ############################################################################## | 2 | ############################################################################## |
3695 | 3 | # | 3 | # |
3697 | 4 | # OpenERP, Open Source Management Solution | 4 | # OpenERP, Open Source Management Solution |
3698 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved |
3699 | 6 | # $Id$ | 6 | # $Id$ |
3700 | 7 | # | 7 | # |
3701 | @@ -111,29 +111,29 @@ | |||
3702 | 111 | _name = "report.crm.case.section" | 111 | _name = "report.crm.case.section" |
3703 | 112 | _description = "Cases by Section" | 112 | _description = "Cases by Section" |
3704 | 113 | _auto = False | 113 | _auto = False |
3706 | 114 | 114 | ||
3707 | 115 | def _get_data(self, cr, uid, ids, field_name, arg, context={}): | 115 | def _get_data(self, cr, uid, ids, field_name, arg, context={}): |
3708 | 116 | res = {} | 116 | res = {} |
3709 | 117 | state_perc = 0.0 | 117 | state_perc = 0.0 |
3710 | 118 | avg_ans = 0.0 | 118 | avg_ans = 0.0 |
3712 | 119 | 119 | ||
3713 | 120 | for case in self.browse(cr, uid, ids, context): | 120 | for case in self.browse(cr, uid, ids, context): |
3714 | 121 | if field_name != 'avg_answers': | 121 | if field_name != 'avg_answers': |
3715 | 122 | state = field_name[5:] | 122 | state = field_name[5:] |
3717 | 123 | cr.execute("select count(*) from crm_case where section_id =%s and state='%s'"%(case.section_id.id,state)) | 123 | cr.execute("select count(*) from crm_case where section_id =%s and state=%s", (case.section_id.id,state)) |
3718 | 124 | state_cases = cr.fetchone()[0] | 124 | state_cases = cr.fetchone()[0] |
3719 | 125 | perc_state = (state_cases / float(case.nbr_cases) ) * 100 | 125 | perc_state = (state_cases / float(case.nbr_cases) ) * 100 |
3721 | 126 | 126 | ||
3722 | 127 | res[case.id] = perc_state | 127 | res[case.id] = perc_state |
3723 | 128 | else: | 128 | else: |
3725 | 129 | cr.execute('select count(*) from crm_case_log l where l.section_id=%s'%(case.section_id.id)) | 129 | cr.execute('select count(*) from crm_case_log l where l.section_id=%s', (case.section_id.id,)) |
3726 | 130 | logs = cr.fetchone()[0] | 130 | logs = cr.fetchone()[0] |
3728 | 131 | 131 | ||
3729 | 132 | avg_ans = logs / case.nbr_cases | 132 | avg_ans = logs / case.nbr_cases |
3732 | 133 | res[case.id] = avg_ans | 133 | res[case.id] = avg_ans |
3733 | 134 | 134 | ||
3734 | 135 | return res | 135 | return res |
3736 | 136 | 136 | ||
3737 | 137 | _columns = { | 137 | _columns = { |
3738 | 138 | 'name': fields.date('Month', readonly=True), | 138 | 'name': fields.date('Month', readonly=True), |
3739 | 139 | # 'user_id':fields.many2one('res.users', 'User', readonly=True), | 139 | # 'user_id':fields.many2one('res.users', 'User', readonly=True), |
3740 | @@ -181,7 +181,7 @@ | |||
3741 | 181 | 'create_date' : fields.datetime('Create Date', readonly=True) | 181 | 'create_date' : fields.datetime('Create Date', readonly=True) |
3742 | 182 | } | 182 | } |
3743 | 183 | _order = 'date_closed, create_date' | 183 | _order = 'date_closed, create_date' |
3745 | 184 | 184 | ||
3746 | 185 | def init(self, cr): | 185 | def init(self, cr): |
3747 | 186 | cr.execute("""create or replace view report_crm_case_service_dashboard as ( | 186 | cr.execute("""create or replace view report_crm_case_service_dashboard as ( |
3748 | 187 | select | 187 | select |
3749 | @@ -195,12 +195,12 @@ | |||
3750 | 195 | where | 195 | where |
3751 | 196 | ((to_date(to_char(cse.date_closed, 'YYYY-MM-dd'),'YYYY-MM-dd') <= CURRENT_DATE) | 196 | ((to_date(to_char(cse.date_closed, 'YYYY-MM-dd'),'YYYY-MM-dd') <= CURRENT_DATE) |
3752 | 197 | AND | 197 | AND |
3754 | 198 | (to_date(to_char(cse.date_closed, 'YYYY-MM-dd'),'YYYY-MM-dd') > (CURRENT_DATE-15)) | 198 | (to_date(to_char(cse.date_closed, 'YYYY-MM-dd'),'YYYY-MM-dd') > (CURRENT_DATE-15)) |
3755 | 199 | AND | 199 | AND |
3756 | 200 | cse.state='done') | 200 | cse.state='done') |
3758 | 201 | 201 | ||
3759 | 202 | OR | 202 | OR |
3761 | 203 | 203 | ||
3762 | 204 | ((to_date(to_char(cse.create_date, 'YYYY-MM-dd'),'YYYY-MM-dd') <= CURRENT_DATE) | 204 | ((to_date(to_char(cse.create_date, 'YYYY-MM-dd'),'YYYY-MM-dd') <= CURRENT_DATE) |
3763 | 205 | AND | 205 | AND |
3764 | 206 | (to_date(to_char(cse.create_date, 'YYYY-MM-dd'),'YYYY-MM-dd') > (CURRENT_DATE-15)) | 206 | (to_date(to_char(cse.create_date, 'YYYY-MM-dd'),'YYYY-MM-dd') > (CURRENT_DATE-15)) |
3765 | @@ -211,4 +211,3 @@ | |||
3766 | 211 | 211 | ||
3767 | 212 | 212 | ||
3768 | 213 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | 213 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
3769 | 214 | |||
3770 | 215 | 214 | ||
3771 | === modified file 'report_timesheet/report_timesheet.py' | |||
3772 | --- report_timesheet/report_timesheet.py 2009-06-09 23:35:34 +0000 | |||
3773 | +++ report_timesheet/report_timesheet.py 2010-03-17 11:50:49 +0000 | |||
3774 | @@ -194,11 +194,11 @@ | |||
3775 | 194 | account_analytic_line line, hr_department dept,hr_department_user_rel dept_user | 194 | account_analytic_line line, hr_department dept,hr_department_user_rel dept_user |
3776 | 195 | where | 195 | where |
3777 | 196 | (dept.id = dept_user.department_id AND dept_user.user_id=line.user_id AND line.user_id is not null) | 196 | (dept.id = dept_user.department_id AND dept_user.user_id=line.user_id AND line.user_id is not null) |
3779 | 197 | AND (dept.manager_id = """ + str(uid) + """ ) | 197 | AND (dept.manager_id = %s) |
3780 | 198 | AND (line.date <= CURRENT_DATE AND line.date > (CURRENT_DATE-3)) | 198 | AND (line.date <= CURRENT_DATE AND line.date > (CURRENT_DATE-3)) |
3781 | 199 | LIMIT 10 | 199 | LIMIT 10 |
3782 | 200 | ) | 200 | ) |
3784 | 201 | """ ) | 201 | """, (uid,)) |
3785 | 202 | 202 | ||
3786 | 203 | report_random_timsheet() | 203 | report_random_timsheet() |
3787 | 204 | 204 | ||
3788 | 205 | 205 | ||
3789 | === modified file 'sale/sale.py' | |||
3790 | --- sale/sale.py 2010-03-02 11:50:52 +0000 | |||
3791 | +++ sale/sale.py 2010-03-17 11:50:49 +0000 | |||
3792 | @@ -101,8 +101,8 @@ | |||
3793 | 101 | LEFT JOIN | 101 | LEFT JOIN |
3794 | 102 | stock_picking p on (p.id=m.picking_id) | 102 | stock_picking p on (p.id=m.picking_id) |
3795 | 103 | WHERE | 103 | WHERE |
3798 | 104 | p.sale_id in ('''+','.join(map(str, ids))+''') | 104 | p.sale_id in %s |
3799 | 105 | GROUP BY m.state, p.sale_id''') | 105 | GROUP BY m.state, p.sale_id''', (tuple(ids),)) |
3800 | 106 | for oid, nbr, state in cr.fetchall(): | 106 | for oid, nbr, state in cr.fetchall(): |
3801 | 107 | if state == 'cancel': | 107 | if state == 'cancel': |
3802 | 108 | continue | 108 | continue |
3803 | @@ -297,7 +297,7 @@ | |||
3804 | 297 | def action_cancel_draft(self, cr, uid, ids, *args): | 297 | def action_cancel_draft(self, cr, uid, ids, *args): |
3805 | 298 | if not len(ids): | 298 | if not len(ids): |
3806 | 299 | return False | 299 | return False |
3808 | 300 | cr.execute('select id from sale_order_line where order_id in ('+','.join(map(str, ids))+')', ('draft',)) | 300 | cr.execute('select id from sale_order_line where order_id in %s', (tuple(ids),)) |
3809 | 301 | line_ids = map(lambda x: x[0], cr.fetchall()) | 301 | line_ids = map(lambda x: x[0], cr.fetchall()) |
3810 | 302 | self.write(cr, uid, ids, {'state': 'draft', 'invoice_ids': [], 'shipped': 0}) | 302 | self.write(cr, uid, ids, {'state': 'draft', 'invoice_ids': [], 'shipped': 0}) |
3811 | 303 | self.pool.get('sale.order.line').write(cr, uid, line_ids, {'invoiced': False, 'state': 'draft', 'invoice_lines': [(6, 0, [])]}) | 303 | self.pool.get('sale.order.line').write(cr, uid, line_ids, {'invoiced': False, 'state': 'draft', 'invoice_lines': [(6, 0, [])]}) |
3812 | 304 | 304 | ||
3813 | === modified file 'scrum/report/_burndown.py' | |||
3814 | --- scrum/report/_burndown.py 2009-01-04 22:12:50 +0000 | |||
3815 | +++ scrum/report/_burndown.py 2010-03-17 11:50:49 +0000 | |||
3816 | @@ -26,15 +26,15 @@ | |||
3817 | 26 | 26 | ||
3818 | 27 | def compute_burndown(cr, uid, tasks_id, date_start, date_stop): | 27 | def compute_burndown(cr, uid, tasks_id, date_start, date_stop): |
3819 | 28 | latest = False | 28 | latest = False |
3822 | 29 | if len(tasks_id): | 29 | if tasks_id: |
3823 | 30 | cr.execute('select id,create_date,state,planned_hours from project_task where id in ('+','.join(map(str,tasks_id))+') order by create_date') | 30 | cr.execute('select id,create_date,state,planned_hours from project_task where id in %s order by create_date', (tuple(tasks_id),)) |
3824 | 31 | tasks = cr.fetchall() | 31 | tasks = cr.fetchall() |
3825 | 32 | 32 | ||
3827 | 33 | cr.execute('select w.date,w.hours from project_task_work w left join project_task t on (t.id=w.task_id) where t.id in ('+','.join(map(str,tasks_id))+') and t.state in (\'open\',\'progress\') order by date') | 33 | cr.execute('select w.date,w.hours from project_task_work w left join project_task t on (t.id=w.task_id) where t.id in %s and t.state in (\'open\',\'progress\') order by date', (tuple(tasks_id),)) |
3828 | 34 | 34 | ||
3829 | 35 | tasks2 = cr.fetchall() | 35 | tasks2 = cr.fetchall() |
3830 | 36 | 36 | ||
3832 | 37 | cr.execute('select date_close,planned_hours from project_task where id in ('+','.join(map(str,tasks_id))+') and state in (\'cancelled\',\'done\') order by date_close') | 37 | cr.execute('select date_close,planned_hours from project_task where id in %s and state in (\'cancelled\',\'done\') order by date_close', (tuple(tasks_id),)) |
3833 | 38 | tasks2 += cr.fetchall() | 38 | tasks2 += cr.fetchall() |
3834 | 39 | tasks2.sort() | 39 | tasks2.sort() |
3835 | 40 | else: | 40 | else: |
3836 | @@ -63,7 +63,4 @@ | |||
3837 | 63 | result.append( (int(time.mktime(time.strptime(date_stop,'%Y-%m-%d'))), 0) ) | 63 | result.append( (int(time.mktime(time.strptime(date_stop,'%Y-%m-%d'))), 0) ) |
3838 | 64 | return result | 64 | return result |
3839 | 65 | 65 | ||
3840 | 66 | |||
3841 | 67 | |||
3842 | 68 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | 66 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
3843 | 69 | |||
3844 | 70 | 67 | ||
3845 | === modified file 'scrum/report/task_burndown.py' | |||
3846 | --- scrum/report/task_burndown.py 2009-01-04 22:12:50 +0000 | |||
3847 | +++ scrum/report/task_burndown.py 2010-03-17 11:50:49 +0000 | |||
3848 | @@ -43,9 +43,9 @@ | |||
3849 | 43 | 43 | ||
3850 | 44 | def burndown_chart(cr, uid, tasks_id, date_start, date_stop): | 44 | def burndown_chart(cr, uid, tasks_id, date_start, date_stop): |
3851 | 45 | latest = False | 45 | latest = False |
3853 | 46 | cr.execute('select id,date_start,state,planned_hours from project_task where id in ('+','.join(map(str,tasks_id))+') order by date_start') | 46 | cr.execute('select id,date_start,state,planned_hours from project_task where id in %s order by date_start', (tuple(tasks_id),)) |
3854 | 47 | tasks = cr.fetchall() | 47 | tasks = cr.fetchall() |
3856 | 48 | cr.execute('select id,date_close,state,planned_hours*progress/100 from project_task where id in ('+','.join(map(str,tasks_id))+') and state in (%s,%s) order by date_close', ('progress','done')) | 48 | cr.execute('select id,date_close,state,planned_hours*progress/100 from project_task where id in %s and state in (%s,%s) order by date_close', (tuple(tasks_id), 'progress','done')) |
3857 | 49 | tasks2 = cr.fetchall() | 49 | tasks2 = cr.fetchall() |
3858 | 50 | current_date = date_start | 50 | current_date = date_start |
3859 | 51 | total = 0 | 51 | total = 0 |
3860 | @@ -72,14 +72,14 @@ | |||
3861 | 72 | io = StringIO.StringIO() | 72 | io = StringIO.StringIO() |
3862 | 73 | 73 | ||
3863 | 74 | if 'date_start' not in datas: | 74 | if 'date_start' not in datas: |
3865 | 75 | cr.execute('select min(date_start) from project_task where id in ('+','.join(map(str,ids))+')') | 75 | cr.execute('select min(date_start) from project_task where id in %s', (tuple(ids),)) |
3866 | 76 | dt = cr.fetchone()[0] | 76 | dt = cr.fetchone()[0] |
3867 | 77 | if dt: | 77 | if dt: |
3868 | 78 | datas['date_start'] = dt[:10] | 78 | datas['date_start'] = dt[:10] |
3869 | 79 | else: | 79 | else: |
3870 | 80 | datas['date_start'] = time.strftime('%Y-%m-%d') | 80 | datas['date_start'] = time.strftime('%Y-%m-%d') |
3871 | 81 | if 'date_stop' not in datas: | 81 | if 'date_stop' not in datas: |
3873 | 82 | cr.execute('select max(date_start),max(date_close) from project_task where id in ('+','.join(map(str,ids))+')') | 82 | cr.execute('select max(date_start),max(date_close) from project_task where id in %s', (tuple(ids),)) |
3874 | 83 | res = cr.fetchone() | 83 | res = cr.fetchone() |
3875 | 84 | datas['date_stop'] = (res[0] and res[0][:10]) or time.strftime('%Y-%m-%d') | 84 | datas['date_stop'] = (res[0] and res[0][:10]) or time.strftime('%Y-%m-%d') |
3876 | 85 | if res[1] and datas['date_stop']<res[1]: | 85 | if res[1] and datas['date_stop']<res[1]: |
3877 | 86 | 86 | ||
3878 | === modified file 'stock/product.py' | |||
3879 | --- stock/product.py 2010-02-22 13:58:43 +0000 | |||
3880 | +++ stock/product.py 2010-03-17 11:50:49 +0000 | |||
3881 | @@ -89,37 +89,43 @@ | |||
3882 | 89 | 89 | ||
3883 | 90 | from_date=context.get('from_date',False) | 90 | from_date=context.get('from_date',False) |
3884 | 91 | to_date=context.get('to_date',False) | 91 | to_date=context.get('to_date',False) |
3886 | 92 | date_str=False | 92 | date_str = '' |
3887 | 93 | date_args = () | ||
3888 | 93 | if from_date and to_date: | 94 | if from_date and to_date: |
3890 | 94 | date_str="date_planned>='%s' and date_planned<='%s'"%(from_date,to_date) | 95 | date_str = "and date_planned>=%s and date_planned<=%s" |
3891 | 96 | date_args = (from_date, to_date) | ||
3892 | 95 | elif from_date: | 97 | elif from_date: |
3894 | 96 | date_str="date_planned>='%s'"%(from_date) | 98 | date_str = "and date_planned>=%s" |
3895 | 99 | date_args = (from_date,) | ||
3896 | 97 | elif to_date: | 100 | elif to_date: |
3898 | 98 | date_str="date_planned<='%s'"%(to_date) | 101 | date_str = "and date_planned<=%s" |
3899 | 102 | date_args = (to_date,) | ||
3900 | 99 | 103 | ||
3901 | 100 | if 'in' in what: | 104 | if 'in' in what: |
3902 | 101 | # all moves from a location out of the set to a location in the set | 105 | # all moves from a location out of the set to a location in the set |
3903 | 102 | cr.execute( | 106 | cr.execute( |
3904 | 103 | 'select sum(product_qty), product_id, product_uom '\ | 107 | 'select sum(product_qty), product_id, product_uom '\ |
3905 | 104 | 'from stock_move '\ | 108 | 'from stock_move '\ |
3912 | 105 | 'where location_id not in ('+location_ids_str+') '\ | 109 | 'where location_id not in %s '\ |
3913 | 106 | 'and location_dest_id in ('+location_ids_str+') '\ | 110 | 'and location_dest_id in %s '\ |
3914 | 107 | 'and product_id in ('+prod_ids_str+') '\ | 111 | 'and product_id in %s '\ |
3915 | 108 | 'and state in ('+states_str+') '+ (date_str and 'and '+date_str+' ' or '') +''\ | 112 | 'and state in %s '+ date_str + ' '\ |
3916 | 109 | 'group by product_id,product_uom' | 113 | 'group by product_id,product_uom', |
3917 | 110 | ) | 114 | (tuple(location_ids), tuple(location_ids), tuple(ids), |
3918 | 115 | tuple(states)) + date_args) | ||
3919 | 111 | results = cr.fetchall() | 116 | results = cr.fetchall() |
3920 | 112 | if 'out' in what: | 117 | if 'out' in what: |
3921 | 113 | # all moves from a location in the set to a location out of the set | 118 | # all moves from a location in the set to a location out of the set |
3922 | 114 | cr.execute( | 119 | cr.execute( |
3923 | 115 | 'select sum(product_qty), product_id, product_uom '\ | 120 | 'select sum(product_qty), product_id, product_uom '\ |
3924 | 116 | 'from stock_move '\ | 121 | 'from stock_move '\ |
3931 | 117 | 'where location_id in ('+location_ids_str+') '\ | 122 | 'where location_id in %s '\ |
3932 | 118 | 'and location_dest_id not in ('+location_ids_str+') '\ | 123 | 'and location_dest_id not in %s '\ |
3933 | 119 | 'and product_id in ('+prod_ids_str+') '\ | 124 | 'and product_id in %s '\ |
3934 | 120 | 'and state in ('+states_str+') '+ (date_str and 'and '+date_str+' ' or '') + ''\ | 125 | 'and state in %s '+ date_str + ' '\ |
3935 | 121 | 'group by product_id,product_uom' | 126 | 'group by product_id,product_uom', |
3936 | 122 | ) | 127 | (tuple(location_ids), tuple(location_ids), tuple(ids), |
3937 | 128 | tuple(states)) + date_args) | ||
3938 | 123 | results2 = cr.fetchall() | 129 | results2 = cr.fetchall() |
3939 | 124 | uom_obj = self.pool.get('product.uom') | 130 | uom_obj = self.pool.get('product.uom') |
3940 | 125 | uoms = map(lambda x: x[2], results) + map(lambda x: x[2], results2) | 131 | uoms = map(lambda x: x[2], results) + map(lambda x: x[2], results2) |
3941 | 126 | 132 | ||
3942 | === modified file 'stock/stock.py' | |||
3943 | --- stock/stock.py 2010-03-12 11:08:43 +0000 | |||
3944 | +++ stock/stock.py 2010-03-17 11:50:49 +0000 | |||
3945 | @@ -368,13 +368,15 @@ | |||
3946 | 368 | ids = [ids] | 368 | ids = [ids] |
3947 | 369 | for pick in self.browse(cr, uid, ids, context): | 369 | for pick in self.browse(cr, uid, ids, context): |
3948 | 370 | sql_str = """update stock_move set | 370 | sql_str = """update stock_move set |
3950 | 371 | date_planned='%s' | 371 | date_planned=%s |
3951 | 372 | where | 372 | where |
3953 | 373 | picking_id=%d """ % (value, pick.id) | 373 | picking_id=%s """ |
3954 | 374 | sqlargs = (value, pick.id) | ||
3955 | 374 | 375 | ||
3956 | 375 | if pick.max_date: | 376 | if pick.max_date: |
3959 | 376 | sql_str += " and (date_planned='" + pick.max_date + "' or date_planned>'" + value + "')" | 377 | sql_str += " and (date_planned=%s or date_planned>%s)" |
3960 | 377 | cr.execute(sql_str) | 378 | sqlargs += (pick.max_date, value) |
3961 | 379 | cr.execute(sql_str, sqlargs) | ||
3962 | 378 | return True | 380 | return True |
3963 | 379 | 381 | ||
3964 | 380 | def _set_minimum_date(self, cr, uid, ids, name, value, arg, context): | 382 | def _set_minimum_date(self, cr, uid, ids, name, value, arg, context): |
3965 | @@ -384,12 +386,14 @@ | |||
3966 | 384 | ids = [ids] | 386 | ids = [ids] |
3967 | 385 | for pick in self.browse(cr, uid, ids, context): | 387 | for pick in self.browse(cr, uid, ids, context): |
3968 | 386 | sql_str = """update stock_move set | 388 | sql_str = """update stock_move set |
3970 | 387 | date_planned='%s' | 389 | date_planned=%s |
3971 | 388 | where | 390 | where |
3973 | 389 | picking_id=%s """ % (value, pick.id) | 391 | picking_id=%s """ |
3974 | 392 | sqlargs = (value, pick.id) | ||
3975 | 390 | if pick.min_date: | 393 | if pick.min_date: |
3978 | 391 | sql_str += " and (date_planned='" + pick.min_date + "' or date_planned<'" + value + "')" | 394 | sql_str += " and (date_planned=%s or date_planned<%s)" |
3979 | 392 | cr.execute(sql_str) | 395 | sqlargs += (pick.min_date, value) |
3980 | 396 | cr.execute(sql_str, sqlargs) | ||
3981 | 393 | return True | 397 | return True |
3982 | 394 | 398 | ||
3983 | 395 | def get_min_max_date(self, cr, uid, ids, field_name, arg, context={}): | 399 | def get_min_max_date(self, cr, uid, ids, field_name, arg, context={}): |
3984 | @@ -405,9 +409,9 @@ | |||
3985 | 405 | from | 409 | from |
3986 | 406 | stock_move | 410 | stock_move |
3987 | 407 | where | 411 | where |
3989 | 408 | picking_id in (""" + ','.join(map(str, ids)) + """) | 412 | picking_id in %s |
3990 | 409 | group by | 413 | group by |
3992 | 410 | picking_id""") | 414 | picking_id""", (tuple(ids),)) |
3993 | 411 | for pick, dt1, dt2 in cr.fetchall(): | 415 | for pick, dt1, dt2 in cr.fetchall(): |
3994 | 412 | res[pick]['min_date'] = dt1 | 416 | res[pick]['min_date'] = dt1 |
3995 | 413 | res[pick]['max_date'] = dt2 | 417 | res[pick]['max_date'] = dt2 |
3996 | @@ -841,11 +845,11 @@ | |||
3997 | 841 | from | 845 | from |
3998 | 842 | stock_report_prodlots | 846 | stock_report_prodlots |
3999 | 843 | where | 847 | where |
4002 | 844 | location_id in ('''+','.join(map(str, locations))+''') and | 848 | location_id in %s and |
4003 | 845 | prodlot_id in ('''+','.join(map(str, ids))+''') | 849 | prodlot_id in %s |
4004 | 846 | group by | 850 | group by |
4005 | 847 | prodlot_id | 851 | prodlot_id |
4007 | 848 | ''') | 852 | ''', (tuple(locations), tuple(ids))) |
4008 | 849 | res.update(dict(cr.fetchall())) | 853 | res.update(dict(cr.fetchall())) |
4009 | 850 | return res | 854 | return res |
4010 | 851 | 855 | ||
4011 | @@ -857,11 +861,11 @@ | |||
4012 | 857 | from | 861 | from |
4013 | 858 | stock_report_prodlots | 862 | stock_report_prodlots |
4014 | 859 | where | 863 | where |
4016 | 860 | location_id in ('''+','.join(map(str, locations)) + ''') | 864 | location_id in %s |
4017 | 861 | group by | 865 | group by |
4018 | 862 | prodlot_id | 866 | prodlot_id |
4021 | 863 | having sum(name) ''' + str(args[0][1]) + ''' ''' + str(args[0][2]) | 867 | having sum(name) ''' + str(args[0][1]) + ' %s', |
4022 | 864 | ) | 868 | (tuple(locations), args[0][2])) |
4023 | 865 | res = cr.fetchall() | 869 | res = cr.fetchall() |
4024 | 866 | ids = [('id', 'in', map(lambda x: x[0], res))] | 870 | ids = [('id', 'in', map(lambda x: x[0], res))] |
4025 | 867 | return ids | 871 | return ids |
4026 | @@ -1204,7 +1208,6 @@ | |||
4027 | 1204 | r = res.pop(0) | 1208 | r = res.pop(0) |
4028 | 1205 | move_id = self.copy(cr, uid, move.id, {'product_qty': r[0], 'location_id': r[1]}) | 1209 | move_id = self.copy(cr, uid, move.id, {'product_qty': r[0], 'location_id': r[1]}) |
4029 | 1206 | done.append(move_id) | 1210 | done.append(move_id) |
4030 | 1207 | #cr.execute('insert into stock_move_history_ids values (%s,%s)', (move.id,move_id)) | ||
4031 | 1208 | if done: | 1211 | if done: |
4032 | 1209 | count += len(done) | 1212 | count += len(done) |
4033 | 1210 | self.write(cr, uid, done, {'state': 'assigned'}) | 1213 | self.write(cr, uid, done, {'state': 'assigned'}) |
4034 | @@ -1547,4 +1550,3 @@ | |||
4035 | 1547 | )""") | 1550 | )""") |
4036 | 1548 | 1551 | ||
4037 | 1549 | report_stock_lines_date() | 1552 | report_stock_lines_date() |
4038 | 1550 | |||
4039 | 1551 | 1553 | ||
4040 | === modified file 'stock/wizard/inventory_merge_zero.py' | |||
4041 | --- stock/wizard/inventory_merge_zero.py 2009-04-09 10:02:19 +0000 | |||
4042 | +++ stock/wizard/inventory_merge_zero.py 2010-03-17 11:50:49 +0000 | |||
4043 | @@ -53,11 +53,11 @@ | |||
4044 | 53 | raise wizard.except_wizard(_('Warning'), | 53 | raise wizard.except_wizard(_('Warning'), |
4045 | 54 | _('Please select one and only one inventory !')) | 54 | _('Please select one and only one inventory !')) |
4046 | 55 | 55 | ||
4048 | 56 | loc = str(data['form']['location_id']) | 56 | loc = data['form']['location_id'] |
4049 | 57 | 57 | ||
4050 | 58 | cr.execute('select distinct location_id,product_id from stock_inventory_line where inventory_id=%s', (data['ids'][0],)) | 58 | cr.execute('select distinct location_id,product_id from stock_inventory_line where inventory_id=%s', (data['ids'][0],)) |
4051 | 59 | inv = cr.fetchall() | 59 | inv = cr.fetchall() |
4053 | 60 | cr.execute('select distinct product_id from stock_move where (location_dest_id='+loc+') or (location_id='+loc+')') | 60 | cr.execute('select distinct product_id from stock_move where (location_dest_id=%(location_id)s) or (location_id=%(location_id)s)', data['form']) |
4054 | 61 | stock = cr.fetchall() | 61 | stock = cr.fetchall() |
4055 | 62 | for s in stock: | 62 | for s in stock: |
4056 | 63 | if (loc,s[0]) not in inv: | 63 | if (loc,s[0]) not in inv: |
4057 | 64 | 64 | ||
4058 | === modified file 'wiki/wizard/make_index.py' | |||
4059 | --- wiki/wizard/make_index.py 2009-04-09 10:02:19 +0000 | |||
4060 | +++ wiki/wizard/make_index.py 2010-03-17 11:50:49 +0000 | |||
4061 | @@ -35,10 +35,9 @@ | |||
4062 | 35 | ids = data['ids'] | 35 | ids = data['ids'] |
4063 | 36 | pool = pooler.get_pool(cr.dbname) | 36 | pool = pooler.get_pool(cr.dbname) |
4064 | 37 | wiki_pool = pool.get('wiki.wiki') | 37 | wiki_pool = pool.get('wiki.wiki') |
4069 | 38 | 38 | ||
4070 | 39 | iid = ','.join([str(x) for x in ids]) | 39 | sSQL = "Select id, section from wiki_wiki where id in %s order by section " |
4071 | 40 | sSQL = "Select id, section from wiki_wiki where id in (%s) order by section " % (iid) | 40 | cr.execute(sSQL, (tuple(ids),)) |
4068 | 41 | cr.execute(sSQL) | ||
4072 | 42 | lst0 = cr.fetchall() | 41 | lst0 = cr.fetchall() |
4073 | 43 | lst = [] | 42 | lst = [] |
4074 | 44 | ids = {} | 43 | ids = {} |
In order to be consistent with the rest of stable branch, can you please use netsvc. notifyChannel instead of logging?
(For trunk it is ok)