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.

1

Any trick to generate interest without having to create a new module?

By
JC
on 11/24/13, 8:04 PM 1,210 views

Can we use openerp out from the box to generate interest for late payment? for example using tax feature etc...

0

JC

--JC--
807
| 5 1 8
Kuala Lumpur, Malaysia
--JC--

 

JC
On 8/17/14, 2:06 AM

To acheive this we need to create a module or change account_invoice:

Add three fields to account_invoice

'calc_increment': fields.function(_calc_increment, string = "Increment"), 
'incremented': fields.boolean('Incremented'), 
'amount_incr': fields.float('Amount Incremented'), 


Add a function called _calc_increment: 

def _calc_increment(self, cr, uid, ids, name, args, context = None): 
    res = {} 
    for invoice in self.browse(cr, uid, ids, context = context): 
        date = invoice.date_due 
        if date and date < time.strftime('%Y-%m-%d') and not invoice.incremented: 
            mount =invoice.amount_total * .10 # the interest rate ar 10% 
            self.write(cr, uid, ids, {'amount_incr': mount, 'incremented':True}, context = context) 
            res[invoice.id] = 0.0 
    return res 


Edit the_amount_all function 

def _amount_all(self, cr, uid, ids, name, args, context=None): 
    res = {} 
    for invoice in self.browse(cr, uid, ids, context=context): 

    incr = invoice.amount_incr 

    res[invoice.id] = { 
           'amount_untaxed': 0.0, 
           'amount_tax': 0.0, 
           'amount_total': 0.0 
    }

 
    for line in invoice.invoice_line: 
        res[invoice.id]['amount_untaxed'] += line.price_subtotal 
    for line in invoice.tax_line: 
        res[invoice.id]['amount_tax'] += line.amount 
        res[invoice.id]['amount_total'] = res[invoice.id]['amount_tax'] + res[invoice.id]['amount_untaxed'] + incr 
    return res 

Edit the amount_all field :


'amount_total': fields.function(_amount_all, digits_compute=dp.get_precision('Account'), string='Total', 
store={ 
'account.invoice': (lambda self, cr, uid, ids, c={}: ids, ['invoice_line'], 20), 
'account.invoice.tax': (_get_invoice_tax, None, 20), 
'account.invoice.line': (_get_invoice_line, ['price_unit','invoice_line_tax_id','quantity','discount','invoice_id'], 20), 
'account.invoice': (lambda self, cr, uid, ids, c={}: ids, ['amount_incr'],21), 
}, 
 

Add calc_increment to your view with invisible attribute... 

Good Luck
 

 

 

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

0 follower(s)

Stats

Asked: 11/24/13, 8:04 PM
Seen: 1210 times
Last updated: 3/16/15, 8:10 AM