Use PySON

This commit is contained in:
Cédric Krier committed 2010-01-20 11:03:14 +01:00
1 parent 8f62c7ba2e
commit fccfa83de8
2 files changed
+14 -8

No files matched your search

+4 -2
View File
@@ -3,13 +3,14 @@
"Service"
from trytond.model import ModelView, ModelSQL, fields
from trytond.model.cacheable import Cacheable
from trytond.pyson import Eval
class Employee(ModelSQL, ModelView, Cacheable):
_name = 'company.employee'
cost_price = fields.Function('get_cost_price', string='Cost Price',
type='numeric', digits="(16, currency_digits)",
type='numeric', digits=(16, Eval('currency_digits', 2)),
depends=['currency_digits'],
help="Hourly cost price for this Employee")
cost_prices = fields.One2Many('company.employee_cost_price', 'employee',
@@ -99,7 +100,8 @@ class EmployeeCostPrice(ModelSQL, ModelView):
_description = __doc__
_rec_name = 'date'
date = fields.Date('Date', required=True, select=1)
cost_price = fields.Numeric('Cost Price', digits="(16, currency_digits)",
cost_price = fields.Numeric('Cost Price',
digits=(16, Eval('currency_digits', 2)),
required=True, depends=['currency_digits'],
help="Hourly cost price")
employee = fields.Many2One('company.employee', 'Employee')
+10 -6
View File
@@ -2,6 +2,7 @@
#this repository contains the full copyright notices and license terms.
from trytond.model import ModelView, ModelSQL, fields
from trytond.pyson import Not, Equal, Eval
from decimal import Decimal
class TimesheetLine(ModelSQL, ModelView):
@@ -33,20 +34,23 @@ class Work(ModelSQL, ModelView):
product = fields.Many2One('product.product', 'Product',
states={
'invisible': "type!= 'task'"
'invisible': Not(Equal(Eval('type'), 'task')),
}, on_change=['product', 'party', 'hours', 'company'],
depends=['type', 'party', 'hours', 'company'])
list_price = fields.Numeric('List Price', digits="(16, currency_digits)",
list_price = fields.Numeric('List Price',
digits=(16, Eval('currency_digits', 2)),
states={
'invisible': "type!= 'task'"
'invisible': Not(Equal(Eval('type'), 'task')),
}, depends=['type', 'currency_digits'])
revenue = fields.Function('get_revenue', type='numeric',
string='Revenue', digits="(16, currency_digits)",
string='Revenue',
digits=(16, Eval('currency_digits', 2)),
states={
'invisible': "type!= 'project'"
'invisible': Not(Equal(Eval('type'), 'project')),
}, depends=['type', 'currency_digits'])
cost = fields.Function('get_cost', string='Cost', type='numeric',
digits="(16, currency_digits)", depends=['currency_digits'])
digits=(16, Eval('currency_digits', 2)),
depends=['currency_digits'])
currency_digits = fields.Function('get_currency_digits', type='integer',
string='Currency Digits', on_change_with=['company'])