Hi guys,I'm relatively new to Odoo (2 months) and currently programming a custom module which inherits "hr.expense.line" in order to show the country and the start and end of the journey on the expense lines. Based on these informations i want to calculate the amount of expenses. I need a proper method to override the "_amount" method in "hr.expense.lines". This method should calculate the difference between the 2 datetime fields and regard the different countries. I'd also like to get the allowable expenses dynamically from a website. How is this possible in odoo(e.g. screen scraper or foreign db)? I'm thankful for any kind of help, below is my start code.
# -*- coding: utf-8 -*-
from openerp import models, fields,api
from datetime import datetime, timedelta
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
import openerp.addons.decimal_precision as dp
class spesen_model(models.Model):
_inherit = 'hr.expense.line'
x_country = fields.Selection( [('d','Deutschland'), ('s','Schweiz'),('au','Österreich')],
'Land')
x_time_begin = fields.Datetime('Anfangsdatum')
x_time_end = fields.Datetime('Enddatum')
@api.v8
@api.multi
@api.depends('x_country', 'x_time_begin', 'x_time_end')
def _amount(self):
for expense in self:
var = 0.0
if expense.x_country == 'd':
var += 100.0
elif expense.x_country == 's':
var += 170.0
elif expense.x_country == 'au':
var += 230.0
expense.total_amount = vartotal_amount = fields.Float(compute='_amount', string='Total', digits_compute=dp.get_precision('Account'))