From 4bdf51feca2e67846479f015243f35d4fd8e48d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 20 Jan 2010 11:05:35 +0100 Subject: [PATCH] Use PySON --- line.py | 21 ++++++++++++--------- work.py | 5 +++-- work.xml | 2 +- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/line.py b/line.py index 7862f3a358..1e4ce6a56b 100644 --- a/line.py +++ b/line.py @@ -1,9 +1,10 @@ -#This file is part of Tryton. The COPYRIGHT file at the top level -#of this repository contains the full copyright notices and license terms. +#This file is part of Tryton. The COPYRIGHT file at the top level of +#this repository contains the full copyright notices and license terms. "Timesheet Line" from trytond.model import ModelView, ModelSQL, fields from trytond.wizard import Wizard from trytond.backend import FIELDS +from trytond.pyson import Eval, PYSONEncoder, Date class Line(ModelSQL, ModelView): @@ -12,7 +13,7 @@ class Line(ModelSQL, ModelView): _description = __doc__ employee = fields.Many2One('company.employee', 'Employee', required=True, - select=1, domain=["('company', '=', company)"]) + select=1, domain=[('company', '=', Eval('company'))]) date = fields.Date('Date', required=True, select=1) hours = fields.Float('Hours', digits=(16, 2), required=True) work = fields.Many2One('timesheet.work', 'Work', @@ -71,7 +72,7 @@ class EnterLinesInit(ModelView): _name = 'timesheet.enter_lines.init' _description = __doc__ employee = fields.Many2One('company.employee', 'Employee', required=True, - domain=["('company', '=', company)"]) + domain=[('company', '=', Eval('company'))]) date = fields.Date('Date', required=True) def default_employee(self, cursor, user, context=None): @@ -121,13 +122,15 @@ class EnterLines(Wizard): model_data = model_data_obj.browse(cursor, user, model_data_ids[0], context=context) res = act_window_obj.read(cursor, user, model_data.db_id, context=context) - res['domain'] = str([ + date = data['form']['date'] + date = Date(date.year, date.month, date.day) + res['pyson_domain'] = PYSONEncoder().encode([ ('employee', '=', data['form']['employee']), - ('date', '=', data['form']['date']), + ('date', '=', date), ]) - res['context'] = str({ + res['pyson_context'] = PYSONEncoder().encode({ 'employee': data['form']['employee'], - 'date': data['form']['date'], + 'date': date, }) if data['form']['employee']: @@ -219,7 +222,7 @@ class OpenHoursEmployee(Wizard): model_data = model_data_obj.browse(cursor, user, model_data_ids[0], context=context) res = act_window_obj.read(cursor, user, model_data.db_id, context=context) - res['context'] = str({ + res['pyson_context'] = PYSONEncoder().encode({ 'start_date': data['form']['start_date'], 'end_date': data['form']['end_date'], }) diff --git a/work.py b/work.py index e80e2ceb99..f3e6879054 100644 --- a/work.py +++ b/work.py @@ -3,6 +3,7 @@ "Work" from trytond.model import ModelView, ModelSQL, fields from trytond.wizard import Wizard +from trytond.pyson import PYSONEncoder class Work(ModelSQL, ModelView): @@ -175,7 +176,7 @@ class OpenWork(Wizard): model_data = model_data_obj.browse(cursor, user, model_data_ids[0], context=context) res = act_window_obj.read(cursor, user, model_data.db_id, context=context) - res['context'] = str({ + res['pyson_context'] = PYSONEncoder().encode({ 'from_date': data['form']['from_date'], 'to_date': data['form']['to_date'], }) @@ -199,7 +200,7 @@ class OpenWork2(OpenWork): model_data = model_data_obj.browse(cursor, user, model_data_ids[0], context=context) res = act_window_obj.read(cursor, user, model_data.db_id, context=context) - res['context'] = str({ + res['pyson_context'] = PYSONEncoder().encode({ 'from_date': data['form']['from_date'], 'to_date': data['form']['to_date'], }) diff --git a/work.xml b/work.xml index 5b3c15a1c3..f1745cbecc 100644 --- a/work.xml +++ b/work.xml @@ -173,7 +173,7 @@ this repository contains the full copyright notices and license terms. --> Hours per Work timesheet.work form - [('parent', 'in', active_ids)] + [('parent', 'in', Eval('active_ids'))]