Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pricelist rules total discount not carried to invoices #1109

Open
levkar opened this issue Dec 17, 2015 · 7 comments
Open

pricelist rules total discount not carried to invoices #1109

levkar opened this issue Dec 17, 2015 · 7 comments

Comments

@levkar
Copy link
Contributor

levkar commented Dec 17, 2015

When pricelist rules are used with multiple discounts, only first discount is carried to invoices. This logic is somewhat distributed into several methods and wizards in various modules. Following methods needs to be inherited and set the discount to correct value.

  1. _prepare_invoice in sale.order model
  2. _get_invoice_vals in stock.picking model
  3. _make_invoice_by_partner in purchase.order.line_invoice
  4. _prepare_invoice in purchase.order

On the other hand, there is an alternative way, which is used in sale_three_discount module of Adhoc.

https://github.com/ingadhoc/odoo-addons/blob/8.0/sale_three_discounts/

This is simply making discount field readonly and setting it to combined discount of other three. If this method is used, rest of the flow works flawlessly. Only drawback is three discounts are combined and shown as one discount in invoices. I don't think it is necessary in invoices anyway.

If you can comment on this issue, I can happily help you fixing this issue and make a PR for it.

@pedrobaeza
Copy link
Member

@anajuaristi, this is one of your modules. Please check.

@anajuaristi
Copy link
Contributor

I have just realized about this issue.
@levkar you are right. 3 discounts are shown in sales order/purchase order but there is a single discount field visible on invoice.
It means that there is no too much people using this feature, since we didn't realize about this behavior until today and noone reported before.
It would be great if you could repair it and make us a PR.

About combining them... I think it's more visual to the customer to see exactly the 3 discount that are applied in cascade instead of showing a single combined one. So even if the single field can be used to calculate subtotal or something in standar way to avoid further not needed developments, I think we should show somehow to the user the detail of the 3 applied discounts

Thank you very much!!

@levkar
Copy link
Contributor Author

levkar commented Dec 17, 2015

Ana, I agree with you that we should show three discounts. That will remain as it is right now. Only we will use another field for discount1 instead of discount field and compute discount field out of three discount fields (discount1, discount2, discount3).

I'll do the fix today and we review it again.

@anajuaristi
Copy link
Contributor

I see.. It could work.

On the other side I was speaking about the invoice.
We should translate the 3 discount to invoice. What do you think?

2015-12-17 12:20 GMT+01:00 Levent Karakaş [email protected]:

Ana, I agree with you that we should show three discounts. That will
remain as it is right now. Only we will use another field for discount1
instead of discount field and compute discount field out of three discount
fields (discount1, discount2, discount3).

I'll do the fix today and we review it again.


Reply to this email directly or view it on GitHub
#1109 (comment)
.

CEO Avanzosc, S.L http://www.avanzosc.es : Office phone / Tfono oficina:
(+34) 943 02 69 02
Ana Juaristi Olalde http://www.anajuaristi.com/: Personal phone: 677 93
42 59. User/usuario skype: Avanzosc
www.openerpsite.com

_El contenido de esta comunicación y de toda su documentación anexa es
confidencial y se dirige exclusivamente a su destinatario. El uso no
autorizado de esta información está prohibido por la legislación vigente.
Si usted no es el destinatario le rogamos nos lo indique, no comunique su
contenido a terceros y proceda a su destrucción. Disculpe las molestias que
le haya ocasionado la recepción indebida de este e-mail. Sus datos figuran
en un fichero cuyo titular es Avanzosc, S.L., a quien usted puede dirigirse
para ejercer sus derechos de acceso, rectificación, cancelación y oposición
en Klara Donea 13, 20720, Azkoitia (Gipuzkoa), Tef. 943 02 69 02 -
_administracion@avanzosc.
[email protected]

_Komunikazio honen edukia eta dokumentazio erantsia konfidentziala da eta
hartzaileak bakarrik jaso beharko luke. Indarrean dagoen legeriak debekatu
egiten du bertan eskainitako informazioa baimenik gabe erabiltzea.
Komunikazioa zuri iritsi bazaizu, baina zu ez bazara hartzailea, mesedez,
guri jakinarazi, eta jasotako informazioa ez inori jakinarazi eta suntsitu.
Barkatu okerreko email hau jasotzeak eragindako eragozpenak. Zure datuak
Avanzosc, S.L. enpresaren fitxategietan sartuta daude. Zure datuak atzitzea
eska dezakezu, bai eta, datuak zuzentzea, ezereztea eta tratamenduari aurka
egitea ere. Horretarako, enpresara jo dezakezu, helbide honetan: _Klara
Donea 13
* 20720, Azkoitia (Gipuzkoa), telefonoa: 943 02 69 02 - *
administracion@avanzosc. [email protected] _This message and all
documents attached to it are confidential and intended only for the person
or entity to which it is addressed. Any use of this information by
unauthorised persons is prohibited under current legislation. If you
received this message by error, please advise us, destroy it and refrain
from communicating its contents to third parties. We apologise for any
inconvenience receiving this email improperly may cause to you. Your
personal data are included in a file owned by Avanzosc, S.L. If you want to
exercise your rights of access, correction, erasure and objection you can
contact the Controller at _Klara Donea 13* 20720, Azkoitia (Gipuzkoa), T:
943 02 69 02 – administracion@avanzosc. [email protected]*

@levkar
Copy link
Contributor Author

levkar commented Dec 17, 2015

it is possible but it is very hard. all invoice functions using discount should be made compatible. if you search discount on account.invoice model, there are many places to fix. One big problem is that some of them are big functions and needs to get parted by monkeypatching. I have seen pedro's mrp_hook addon and reasons behind creating that addon. we recently needed to monkeypatch half of the accounting functions to add currency rate type. it is such a pain.

on the other hand maybe we can use a similar approach on invoices. It will require at least inheriting of the above methods I mentioned. We have experience on moving fields to invoice. I will think about it and propose a solution if possible.

@levkar
Copy link
Contributor Author

levkar commented Dec 17, 2015

I made this PR related to this discussion:

#1111

Now discounts plays nicely with invoice discount.

I just want to point a few things that I came up while making the fix.

  1. Offer system breaks the " amount * quantity * discount_factor = line_subtotal" formula and it has the same problem with the discount in an unsolvable manner. To my understanding an offer should be considered another order line with %100 discount. I have no idea how we can solve this problem. Maybe it's better to change offer functionality.

  2. sale.order.line.subtotal and purchase.order.line.subtotal model exists but does nothing in these modules. They might be used within another module. If not, it would be better to remove.

  3. I'm not sure if the mentioned fix at the end of purchase.py works correctly. While testing, I noticed line subtotals are still not being calculated. Default way to recalculate everything is to click calculate on sale order.

Please let me know your comments. I'll be glad to help.

@levkar
Copy link
Contributor Author

levkar commented Dec 17, 2015

Regarding multiple discounts on invoice, it is possible to add three discounts on invoice calculating the actual discount. After that we can get three discounts feeded into invoice into above methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants