Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Expense Management based on Country and Datetime

By
Peter Mayer
on 2/5/16, 7:52 AM 371 views

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 = var

total_amount = fields.Float(compute='_amount', string='Total', digits_compute=dp.get_precision('Account'))

  

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 2/5/16, 7:52 AM
Seen: 371 times
Last updated: 2/11/16, 9:43 AM