Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
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
_inherit = 'hr.expense.line'
x_country = fields.Selection( [('d','Deutschland'), ('s','Schweiz'),('au','Österreich')],
x_time_begin = fields.Datetime('Anfangsdatum')
x_time_end = fields.Datetime('Enddatum')
@api.depends('x_country', 'x_time_begin', 'x_time_end')
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'))
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 platform 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.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 2/5/16, 7:52 AM|
|Seen: 429 times|
|Last updated: 2/11/16, 9:43 AM|