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

How to automatically add a fixed amount to the invoice?

By
walid
on 6/18/13, 12:49 PM 3,138 views

Hello,

I'm starting with OpenERP and I do not know how to automatically add a fixed amount to the invoice (eg stamp duty).

Thank you for helping me

1

Borni DHIFI

--Borni DHIFI--
5102
| 6 8 9
Tunis, Tunisia
--Borni DHIFI--

Techno Functional Consultant Odoo(OpenERP) 

http://www.linkedin.com/in/borni

Skype : dhifi.borni

Borni DHIFI
On 6/18/13, 1:43 PM

Hi,

you must create a new module that allows you to change the total in invoice.

you must overwrite method _amount_all in account_invoice.

you can directly add stamp in amount but it is not a good way :

res[invoice.id]['amount_total'] = res[invoice.id]['amount_tax'] + res[invoice.id]['amount_untaxed'] +0.4

you can configure amount to stamp in company:

add field amount_stamp in res.company

to retrieve this value you can use this code :

company_pool = self.pool.get('res.company')
#get default company
comapny_id = self.pool.get('res.company')._company_default_get(cr, uid, 'res.company', context=context)
company_browse = company_pool.browse(cr, uid, comapny_id)
#get amount_stamp
res[invoice.id]['amount_total'] = res[invoice.id]['amount_tax'] + res[invoice.id]['amount_untaxed'] +company_browse.amount_stamp

Thank you I've added the 0.4 value statically, but I want a parameterizable value

walid
on 6/18/13, 2:25 PM
0
walid
On 6/19/13, 2:19 PM

Hello,

I created a new module that inherits sale.order adding field amount_stamp

class sale_order(osv.osv):
_inherit = "sale.order"
_columns = {
    'amount_stamp': fields.float('Timbre fiscal',size=64),

}

I want to change the method "_amount_all" as shown in the following code

def _amount_all(self, cr, uid, ids, field_name, arg, context=None):
    cur_obj = self.pool.get('res.currency')
    res = {}
    for order in self.browse(cr, uid, ids, context=context):
        res[order.id] = {
            'amount_untaxed': 0.0,
            'amount_tax': 0.0,
            'amount_total': 0.0,
        }
        val = val1 = 0.0
        cur = order.pricelist_id.currency_id
        for line in order.order_line:
            val1 += line.price_subtotal
            val += self._amount_line_tax(cr, uid, line, context=context)
        res[order.id]['amount_tax'] = cur_obj.round(cr, uid, cur, val)
        res[order.id]['amount_untaxed'] = cur_obj.round(cr, uid, cur, val1)
        res[order.id]['amount_total'] = res[order.id]['amount_tax'] + res[order.id]['amount_untaxed'] +res[order.id]['amount_stamp']
        res=super(sale_order, self)._amount_all(cr, uid, ids, field_name, arg, context=None)
       # res[order.id]['amount_total'] = res[order.id]['amount_untaxed'] + res[order.id]['amount_tax']
        return res

sale_order()

amount_stamp but is not considered

Thank you for helping me

please help me

walid
on 6/20/13, 6:53 AM

I don't if its already fixed, but to my opinion the line res=super(sale_order, self)._amount_all(cr, uid, ids, field_name, arg, context=None) shouldn't be there, it should be before your first for loop.

MEXYTUL, Diego Calzadilla
on 8/14/13, 2:56 AM
0
Leen Sonneveld
On 6/18/13, 6:34 PM

You should use the Delivery Costs module to add a variable or fixed amount.

0

Grover Menacho

--Grover Menacho--
2523
| 5 7 8
La Paz, Bolivia
--Grover Menacho--

Systems Engineer + MBA

Grover Menacho
On 6/19/13, 4:44 PM

Of course that are amounts that a new module can add, but do that just in the case that there is an amount that you don't want to show. You can add a product with "Service" as type of product. And when you are making the invoice just add that product with a fixed amount.

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: 6/18/13, 12:49 PM
Seen: 3138 times
Last updated: 3/16/15, 8:10 AM