This question has been flagged
4 Replies
9353 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

Avatar
Discard
Best Answer

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.

Avatar
Discard
Best Answer

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
Avatar
Discard
Author

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

Best Answer

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

Avatar
Discard
Author Best Answer

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

Avatar
Discard
Author

please help me

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.