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

Global discount on Customer Invoice

By
Panos
on 7/2/16, 9:16 AM 410 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:

https://www.odoo.com/forum/help-1/question/how-to-give-discount-on-the-total-of-a-sales-order-6600

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.


0
Panos
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!

Panos
on 7/4/16, 10:47 AM
0

Ermin Trevisan

--Ermin Trevisan--
3524
| 6 3 7
Walchwil, Switzerland
--Ermin Trevisan--


Ermin Trevisan
On 7/3/16, 2:07 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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 7/2/16, 9:16 AM
Seen: 410 times
Last updated: 7/3/16, 5:42 AM