OLD | NEW |
1 #This file is part of Tryton. The COPYRIGHT file at the top level of | 1 #This file is part of Tryton. The COPYRIGHT file at the top level of |
2 #this repository contains the full copyright notices and license terms. | 2 #this repository contains the full copyright notices and license terms. |
3 from trytond.model import ModelView, ModelSQL, fields | 3 from trytond.model import ModelView, ModelSQL, fields |
4 from trytond.wizard import Wizard | 4 from trytond.wizard import Wizard |
5 import datetime | 5 import datetime |
6 | 6 |
7 | 7 |
8 class Template(ModelSQL, ModelView): | 8 class Template(ModelSQL, ModelView): |
9 _name = "product.template" | 9 _name = "product.template" |
10 | 10 |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 ') '\ | 218 ') '\ |
219 'OR '\ | 219 'OR '\ |
220 '(effective_date <= %s)'\ | 220 '(effective_date <= %s)'\ |
221 ')'\ | 221 ')'\ |
222 ')' | 222 ')' |
223 state_date_vals = ["done", | 223 state_date_vals = ["done", |
224 context.get('stock_assign') and 'assigned' or 'done', | 224 context.get('stock_assign') and 'assigned' or 'done', |
225 context['stock_date_end'], | 225 context['stock_date_end'], |
226 context['stock_date_end'], | 226 context['stock_date_end'], |
227 ] | 227 ] |
228 # infinite date end: take all states for the moves | |
229 elif context['stock_date_end'] == datetime.date.max: | |
230 state_date_clause = 'state in (%s, %s, %s)' | |
231 state_date_vals = ['done', 'assigned', 'draft'] | |
232 # future date end: filter move on state done and date | 228 # future date end: filter move on state done and date |
233 # before today, or on all state and date between today and | 229 # before today, or on all state and date between today and |
234 # date_end. | 230 # date_end. |
235 else: | 231 else: |
236 state_date_clause = \ | 232 state_date_clause = \ |
237 '(' \ | 233 '(' \ |
238 '('\ | 234 '('\ |
239 '(state in (%s, %s)) '\ | 235 '(state in (%s, %s)) '\ |
240 'AND '\ | 236 'AND '\ |
241 '('\ | 237 '('\ |
(...skipping 22 matching lines...) Expand all Loading... |
264 '(' \ | 260 '(' \ |
265 '(effective_date <= %s) '\ | 261 '(effective_date <= %s) '\ |
266 'AND '\ | 262 'AND '\ |
267 '(effective_date >= %s)'\ | 263 '(effective_date >= %s)'\ |
268 ')'\ | 264 ')'\ |
269 ')'\ | 265 ')'\ |
270 ')'\ | 266 ')'\ |
271 ')' | 267 ')' |
272 | 268 |
273 state_date_vals = [ | 269 state_date_vals = [ |
274 'done', 'assigned', today, today, | 270 'done', context.get('stock_assign') and 'assigned' or 'done', |
| 271 today, today, |
275 'done', 'assigned', 'draft', | 272 'done', 'assigned', 'draft', |
276 context['stock_date_end'], today, | 273 context['stock_date_end'], today, |
277 context['stock_date_end'], today, | 274 context['stock_date_end'], today, |
278 ] | 275 ] |
279 | 276 |
280 if context.get('stock_date_start'): | 277 if context.get('stock_date_start'): |
281 if context['stock_date_start'] > today: | 278 if context['stock_date_start'] > today: |
282 state_date_clause += 'AND '\ | 279 state_date_clause += 'AND '\ |
283 '('\ | 280 '('\ |
284 '(state in (%s, %s, %s)) '\ | 281 '(state in (%s, %s, %s)) '\ |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 ctx['product'] = data['id'] | 576 ctx['product'] = data['id'] |
580 if data['form']['forecast_date']: | 577 if data['form']['forecast_date']: |
581 ctx['stock_date_end'] = data['form']['forecast_date'] | 578 ctx['stock_date_end'] = data['form']['forecast_date'] |
582 else: | 579 else: |
583 ctx['stock_date_end'] = datetime.date.max | 580 ctx['stock_date_end'] = datetime.date.max |
584 res['context'] = str(ctx) | 581 res['context'] = str(ctx) |
585 | 582 |
586 return res | 583 return res |
587 | 584 |
588 OpenLocation() | 585 OpenLocation() |
OLD | NEW |