Odoo Help


Sale order discount in fixed amount.

on 10/8/13, 3:14 AM 4,838 views

Now discount is entered as percentage in sales order line

How can be set sales order discount as a fixed amount. Is there any way to make this possible without editing the sale.py file.

Best you explain what you want to do a little more. Do you want a fixed percentage over price or a fixed amount over the price irrespective of total?

on 10/8/13, 6:52 AM

Overall discount for a sale order bill is possible or not in Openerp v7.0.? If it is possible then how can i add discount as an amount (willl vary on each sale order ) not as percentage..

on 10/8/13, 7:15 AM

I believe you know the solution. You will have to create a module that deduct a value from the total on the sales order. This value will then have to overwrite the current total so that is can be used on the invoice.

on 10/8/13, 8:06 AM

Any other way to implement it through Openerp interface.

on 10/8/13, 8:23 AM

I can't think of any at the moment. A work around is to create price lists with a fixed percentage across all the products and assign these to your client as required so that you get the same percentage on the total overall. But if you want something dynamic that allows you to give different discounts every time, then you will need a custom module.

on 10/8/13, 8:44 AM

Yes of course their is a way.. BUT I made this in Customer Invoice i think you can use this as a guide for your sale order.. but i will translate it to sale order line . By he way i use this in Openerp v 7

In your .py

class sale_order_line(osv.osv):
     _inherit = 'sale.order.line'
     def _amount_line(self, cr, uid, ids, field_name, arg, context=None):
       tax_obj = self.pool.get('account.tax')
       cur_obj = self.pool.get('res.currency')
       res = {}
      if context is None:
        context = {}
    for line in self.browse(cr, uid, ids, context=context):
        if line.amount_discount:
            price = **Here you will put your code on how will you compute your discount by amount**
            taxes =  **And also here.. because it will be affected based on your code in PRICE**
            res[line.id] = taxes['total']
            if line.invoice_id:
                    cur = line.invoice_id.currency_id
                    res[line.id] = cur_obj.round(cr, uid, cur, res[line.id])  
        price = line.price_unit * (1 - (line.discount or 0.0) / 100.0)
        taxes = tax_obj.compute_all(cr, uid, line.tax_id, price, line.product_uom_qty, line.product_id, line.order_id.partner_id)
        cur = line.order_id.pricelist_id.currency_id
        res[line.id] = cur_obj.round(cr, uid, cur, taxes['total'])
    return res
 _columns = {

     'amount_discount': fields.float('Discount (Amount)', digits_compute= dp.get_precision('Discount')),    
     'price_subtotal': fields.function(_amount_line, method=True, string='Subtotal', type="float",digits_compute= dp.get_precision('Account'), store=True),   
     'price_unit': fields.float('Unit Price', required=True, digits_compute= dp.get_precision('Product Price')),    
     'discount': fields.float('Discount (%)', digits_compute= dp.get_precision('Discount')),       

In your .xml

<record id="name_you_want" model="ir.ui.view">
        <field name="name">name.you.want</field>
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_order_form"/>
        <field name="arch" type="xml">
        <xpath expr="//field[@name='discount']" position="after">
                    <field name ="amount_discount"/>

I will leave to you how to compute discount by amount.. I know you can do that.. Good luck :D I hope that it will be a big help to you :D

pls post with full explain

on 11/15/13, 5:47 AM

AttributeError: "Field 'invoice_id' does not exist in object 'browse_record(sale.order.line, 32)'" This error raise while updating the total amount field

on 1/18/14, 5:39 AM
On 10/8/13, 9:16 AM


My client wanted the same feature. I have implemented 6.1 for him. I would like to show you the image of the sale order form. But I dont have enough karma to upload link or image.

But I have used a module to fulfill his requirement. That requirement seems to be common for US industries. OpenERP is more of Europe Industry Standards


hi. which module did u used for him. Is it possible to add a dynamic amount(not %) as discount for a sale order

on 10/8/13, 9:29 AM

Yes. We can. Do you want it for 6.1 or 7?

on 10/8/13, 9:31 AM

i want it for version 7.0

on 10/8/13, 9:33 AM

Sorry. I dont know if OpenERP has added that feature for 7.0. But I can do that for you. you contact me on skype: vivekrajanvits. For your question, this comment will be the final answer. What Markus said is one way of doing. another way is what I implemented for my client. But I doubt if it is available in 7.

on 10/8/13, 9:36 AM

ok thanks vivekrajan.

on 10/8/13, 9:41 AM

You are welcome. you can upvote my post if my answer helped you. I can use vote to upload links and images.

on 10/8/13, 9:43 AM

hey thanks Charles for your vote. and I am sorry that I gave you wrong skype id. it is vivekrajan.vits

on 10/8/13, 9:59 AM
Torsten Francke
On 10/8/13, 9:12 AM

The best way to solve this, add a new sale.order.line to your sale.order with a product "discount" (Product Type Consumable) and add a negative price.

So you have. MyProduct: 199€ Discount: -10€ Sum: 189€

thanks for the reply Markus.

on 10/8/13, 10:08 AM
On 3/16/16, 7:08 AM


Yes, you can do it through Price List

Odoo Consultancy
On 3/15/16, 5:55 AM


We have developed a module which allow users to apply discount (Fixed Amount, Percentage) on Sales and Customer Invoice.

The module also allow user to display the discount on Sales and Invoice report.

Once you Validate the invoice, the module generate the Journal Entries. You can track the discount on P/L report by creating a separate account for the discount which you just have to configure in the company. This account will be used to post the entries of the discount account.

Hope this module will ease everyone's life.

For now, the module is developed for v7 only and we are on the way to migrate it in v8 and v9 as well.

Download: https://apps.odoo.com/apps/modules/7.0/discount_sale_invoice/

joseph d'souza
On 10/8/13, 4:54 PM


I have developed one module which set a discount on whole sale order and customer invoice with fixed and percentage vise. when your quote will move to invoice that same discount and total will move to the invoice I think this module feature will helps you more.

you can see on : http://www.youtube.com/watch?v=RTRB0xq9Y38&feature=youtu.be

To get the module can contact me: dsouzajoseph199@gmail.com

ok i will contact you.

on 10/9/13, 2:42 AM

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 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 10/8/13, 3:14 AM
Seen: 4838 times
Last updated: 3/16/16, 7:08 AM