Odoo Help


Global discount on Customer Invoice

on 7/2/16, 9:16 AM 1,608 views

Hello, I am using v9 and I am trying to apply global discount in customer invoices. I am trying the user solution given here:


I have created a float field called x_global_invoice_discount , I am displaying that field in the account.invoice form and I have placed the method inside the file "/addons/account/models/account_invoice.py" in the class AccountInvoice but I am getting "undifiend object 'apply.discount' in model 'account.invoice'"

If i place the code in the file "/addons/sale/sale.py" in the class AccountInvoice then no error, but nothing happens. I am tailing the log file and the onchange event doesn't trigger :/

I am new in odoo and in python as I was writing in php and java so far... some help will be much appreciated!

The goal is: The user will add all the products he wants, then he will input the discount (eg 10%) and the value of that field should be applied in the discount field in the invoice lines. Finally the order total should be updated. In a most advanced version of this the discount should be put in each customer and applied automatically in the invoice lines.

I can provide additional info and screenshots if needed.

Yasir Moozhiyan
On 3/13/18, 3:31 AM

Please refer this link. This may help you.

Visit : https://www.odoo.com/apps/modules/11.0/tis_sales_purchase_global_discount/

On 7/3/16, 5:42 AM

Thank you for your answer Ermin. I have tried quite a few modules but unfortunately the v8 and v7modules don't work on v9. The v9 module you are suggesting does not calculate the discount on the product lines also it is a paid one and I am not willing to pay 25E for such a simple task, moreover it has only 1-star rating.

I am a programmer myself but unfamiliar with python and odoo so I am asking for some help with the code :)

I did mention the modules for 8.0 as a guide to coding it yourself or you might even think about porting one of the modules to 9.0.

Ermin Trevisan
on 7/4/16, 12:17 AM

after a lot trial and error I have modified a v.8 module to work on v.9 but I am encountering a very strange bug which I cant seem to fix nor understand why it is happening. I have added some code that reads the value of the global discount and places it in the line.discount field of each product. The first time I click "update" to update the invoice lines with the new discount everything works fine. If I change the global discount again then only the 1st product discount field is updated. The other products' discount fields keep the old value. I keep banging my head on the wall with that but I can't figure it out....

I would really appreciate it if you could help me!

on 7/4/16, 10:47 AM

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: 7/2/16, 9:16 AM
Seen: 1608 times
Last updated: 3/13/18, 3:31 AM