diff --git a/service.py b/service.py index 76136cef36..1364b4a34a 100644 --- a/service.py +++ b/service.py @@ -9,16 +9,15 @@ 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, Eval('currency_digits', 2)), - depends=['currency_digits'], - help="Hourly cost price for this Employee") + cost_price = fields.Function(fields.Numeric('Cost Price', + digits=(16, Eval('currency_digits', 2)), depends=['currency_digits'], + help="Hourly cost price for this Employee"), 'get_cost_price') cost_prices = fields.One2Many('company.employee_cost_price', 'employee', 'Cost Prices', help="List of hourly cost price over time") - currency_digits = fields.Function('get_currency_digits', type='integer', - string='Currency Digits', on_change_with=['company']) + currency_digits = fields.Function(fields.Integer('Currency Digits', + on_change_with=['company']), 'get_currency_digits') - def get_cost_price(self, cursor, user, ids, name, arg, context=None): + def get_cost_price(self, cursor, user, ids, name, context=None): ''' Return the cost price at the date given in the context or the current date @@ -65,7 +64,7 @@ class Employee(ModelSQL, ModelView, Cacheable): break return cost - def get_currency_digits(self, cursor, user, ids, name, arg, context=None): + def get_currency_digits(self, cursor, user, ids, name, context=None): res = {} for employee in self.browse(cursor, user, ids, context=context): res[employee.id] = employee.company.currency.digits @@ -105,8 +104,8 @@ class EmployeeCostPrice(ModelSQL, ModelView): required=True, depends=['currency_digits'], help="Hourly cost price") employee = fields.Many2One('company.employee', 'Employee') - currency_digits = fields.Function('get_currency_digits', type='integer', - string='Currency Digits', on_change_with=['employee']) + currency_digits = fields.Function(fields.Integer('Currency Digits', + on_change_with=['employee']), 'get_currency_digits') def __init__(self): super(EmployeeCostPrice, self).__init__() @@ -135,7 +134,7 @@ class EmployeeCostPrice(ModelSQL, ModelView): return super(EmployeeCostPrice , self).write(cursor, user, ids, vals, context=context) - def get_currency_digits(self, cursor, user, ids, name, arg, context=None): + def get_currency_digits(self, cursor, user, ids, name, context=None): res = {} for costprice in self.browse(cursor, user, ids, context=context): res[costprice.id] = costprice.employee.company.currency.digits diff --git a/work.py b/work.py index d3a11dd9cc..33f8a6f679 100644 --- a/work.py +++ b/work.py @@ -42,19 +42,18 @@ class Work(ModelSQL, ModelView): states={ 'invisible': Not(Equal(Eval('type'), 'task')), }, depends=['type', 'currency_digits']) - revenue = fields.Function('get_revenue', type='numeric', - string='Revenue', - digits=(16, Eval('currency_digits', 2)), - states={ - 'invisible': Not(Equal(Eval('type'), 'project')), - }, depends=['type', 'currency_digits']) - cost = fields.Function('get_cost', string='Cost', type='numeric', - 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']) + revenue = fields.Function(fields.Numeric('Revenue', + digits=(16, Eval('currency_digits', 2)), + states={ + 'invisible': Not(Equal(Eval('type'), 'project')), + }, depends=['type', 'currency_digits']), 'get_revenue') + cost = fields.Function(fields.Numeric('Cost', + digits=(16, Eval('currency_digits', 2)), depends=['currency_digits']), + 'get_cost') + currency_digits = fields.Function(fields.Integer('Currency Digits', + on_change_with=['company']), 'get_currency_digits') - def get_cost(self, cursor, user, ids, name, arg, context=None): + def get_cost(self, cursor, user, ids, name, context=None): timesheet_line_obj = self.pool.get('timesheet.line') all_ids = self.search(cursor, user, [ ('parent', 'child_of', ids), @@ -90,7 +89,7 @@ class Work(ModelSQL, ModelView): return res - def get_revenue(self, cursor, user, ids, name, arg, context=None): + def get_revenue(self, cursor, user, ids, name, context=None): all_ids = self.search(cursor, user, [ ('parent', 'child_of', ids), ('active', '=', True)], context=context) + ids @@ -125,7 +124,7 @@ class Work(ModelSQL, ModelView): return res - def get_currency_digits(self, cursor, user, ids, name, arg, context=None): + def get_currency_digits(self, cursor, user, ids, name, context=None): res = {} for work in self.browse(cursor, user, ids, context=context): res[work.id] = work.company.currency.digits