Skip to content

Commit

Permalink
Merge 8861465 into f76d71c
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurent Corron committed Oct 29, 2019
2 parents f76d71c + 8861465 commit fb872eb
Show file tree
Hide file tree
Showing 28 changed files with 1,013 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .isort.cfg
Expand Up @@ -9,4 +9,4 @@ line_length=88
known_odoo=odoo
known_odoo_addons=odoo.addons
sections=FUTURE,STDLIB,THIRDPARTY,ODOO,ODOO_ADDONS,FIRSTPARTY,LOCALFOLDER
known_third_party=
known_third_party=setuptools
94 changes: 94 additions & 0 deletions sale_discount_display_amount/README.rst
@@ -0,0 +1,94 @@
============================
Sale Discount Display Amount
============================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/sale-workflow/tree/12.0/sale_discount_display_amount
:alt: OCA/sale-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/sale-workflow-12-0/sale-workflow-12-0-sale_discount_display_amount
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/167/12.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

In standard Odoo only display the rate of the discount applied, never the
amount. It could be great to be able to tell the customer how much he spares.
This is the goal of this addons, it will show on a sale
order the total without the discount and the value of the discount.

**Table of contents**

.. contents::
:local:

Configuration
=============

To configure this module, you need to:

#. Go to Sales/Settings and check "Allow discounts on sales order lines"

Usage
=====


To use this module, you need to:

#. Go on a sale order
#. Set a discount on a line
#. The value of the discount is dislayed in the total section as well as the total without it.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale-workflow/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/sale-workflow/issues/new?body=module:%20sale_discount_display_amount%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* ACSONE SA/NV

Contributors
~~~~~~~~~~~~

* Cédric Pigeon <cedric.pigeon@acsone.eu>
* Abraham Anes <abrahamanes@gmail.com>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/sale-workflow <https://github.com/OCA/sale-workflow/tree/12.0/sale_discount_display_amount>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions sale_discount_display_amount/__init__.py
@@ -0,0 +1,3 @@
from . import models
from .hooks import pre_init_hook
from .hooks import post_init_hook
17 changes: 17 additions & 0 deletions sale_discount_display_amount/__manifest__.py
@@ -0,0 +1,17 @@
# Copyright 2018 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Sale Discount Display Amount",
"summary": """
This addon intends to display the amount of the discount computed on
sale_order_line and sale_order level""",
"version": "13.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/sale-workflow",
"depends": ["sale_management"],
"data": ["views/sale_view.xml"],
"pre_init_hook": "pre_init_hook",
"post_init_hook": "post_init_hook",
}
61 changes: 61 additions & 0 deletions sale_discount_display_amount/hooks.py
@@ -0,0 +1,61 @@
# Copyright 2018 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import logging

from odoo import SUPERUSER_ID
from odoo.api import Environment

_logger = logging.getLogger(__name__)


def pre_init_hook(cr):
_logger.info("Create discount columns in database")
cr.execute(
"""
ALTER TABLE sale_order ADD COLUMN price_total_no_discount numeric;
"""
)
cr.execute(
"""
ALTER TABLE sale_order ADD COLUMN discount_total numeric;
"""
)
cr.execute(
"""
ALTER TABLE sale_order_line ADD COLUMN price_total_no_discount
numeric;
"""
)
cr.execute(
"""
ALTER TABLE sale_order_line ADD COLUMN discount_total numeric;
"""
)


def post_init_hook(cr, registry):
_logger.info("Compute discount columns")
env = Environment(cr, SUPERUSER_ID, {})

query = """
update sale_order_line
set price_total_no_discount = price_total
where discount = 0.0
"""
cr.execute(query)

query = """
update sale_order
set price_total_no_discount = amount_total
"""
cr.execute(query)

query = """
select distinct order_id from sale_order_line where discount > 0.0;
"""

cr.execute(query)
order_ids = cr.fetchall()

orders = env["sale.order"].search([("id", "in", order_ids)])
orders.mapped("order_line")._compute_discount()
39 changes: 39 additions & 0 deletions sale_discount_display_amount/i18n/de.po
@@ -0,0 +1,39 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_discount_display_amount
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2019-07-15 13:43+0000\n"
"Last-Translator: Maria Sparenberg <maria.sparenberg@gmx.net>\n"
"Language-Team: none\n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 3.7.1\n"

#. module: sale_discount_display_amount
#: model:ir.model.fields,field_description:sale_discount_display_amount.field_sale_order__discount_total
#: model:ir.model.fields,field_description:sale_discount_display_amount.field_sale_order_line__discount_total
msgid "Discount Subtotal"
msgstr "Rabatt-Bruttobetrag"

#. module: sale_discount_display_amount
#: model:ir.model,name:sale_discount_display_amount.model_sale_order
msgid "Sale Order"
msgstr "Verkaufsauftrag"

#. module: sale_discount_display_amount
#: model:ir.model,name:sale_discount_display_amount.model_sale_order_line
msgid "Sales Order Line"
msgstr "Auftragsposition"

#. module: sale_discount_display_amount
#: model:ir.model.fields,field_description:sale_discount_display_amount.field_sale_order__price_total_no_discount
#: model:ir.model.fields,field_description:sale_discount_display_amount.field_sale_order_line__price_total_no_discount
msgid "Subtotal Without Discount"
msgstr "Bruttobetrag ohne Rabatt"
41 changes: 41 additions & 0 deletions sale_discount_display_amount/i18n/es.po
@@ -0,0 +1,41 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_discount_display_amount
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2018-10-10 12:47+0000\n"
"Last-Translator: Cédric Pigeon (ACSONE) <cedric.pigeon@acsone.eu>\n"
"Language-Team: none\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 3.1.1\n"

#. module: sale_discount_display_amount
#: model:ir.model.fields,field_description:sale_discount_display_amount.field_sale_order__discount_total
#: model:ir.model.fields,field_description:sale_discount_display_amount.field_sale_order_line__discount_total
msgid "Discount Subtotal"
msgstr "Descuento total"

#. module: sale_discount_display_amount
#: model:ir.model,name:sale_discount_display_amount.model_sale_order
#, fuzzy
#| msgid "Sales Order"
msgid "Sale Order"
msgstr "Pedido de venta"

#. module: sale_discount_display_amount
#: model:ir.model,name:sale_discount_display_amount.model_sale_order_line
msgid "Sales Order Line"
msgstr "Línea pedido de venta"

#. module: sale_discount_display_amount
#: model:ir.model.fields,field_description:sale_discount_display_amount.field_sale_order__price_total_no_discount
#: model:ir.model.fields,field_description:sale_discount_display_amount.field_sale_order_line__price_total_no_discount
msgid "Subtotal Without Discount"
msgstr "Total Sin Descuento"
37 changes: 37 additions & 0 deletions sale_discount_display_amount/i18n/es_ES.po
@@ -0,0 +1,37 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_discount_display_amount
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: es_ES\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"

#. module: sale_discount_display_amount
#: model:ir.model.fields,field_description:sale_discount_display_amount.field_sale_order__discount_total
#: model:ir.model.fields,field_description:sale_discount_display_amount.field_sale_order_line__discount_total
msgid "Discount Subtotal"
msgstr ""

#. module: sale_discount_display_amount
#: model:ir.model,name:sale_discount_display_amount.model_sale_order
msgid "Sale Order"
msgstr ""

#. module: sale_discount_display_amount
#: model:ir.model,name:sale_discount_display_amount.model_sale_order_line
msgid "Sales Order Line"
msgstr ""

#. module: sale_discount_display_amount
#: model:ir.model.fields,field_description:sale_discount_display_amount.field_sale_order__price_total_no_discount
#: model:ir.model.fields,field_description:sale_discount_display_amount.field_sale_order_line__price_total_no_discount
msgid "Subtotal Without Discount"
msgstr ""
41 changes: 41 additions & 0 deletions sale_discount_display_amount/i18n/fr.po
@@ -0,0 +1,41 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_discount_display_amount
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2018-10-10 12:38+0000\n"
"Last-Translator: Cédric Pigeon (ACSONE) <cedric.pigeon@acsone.eu>\n"
"Language-Team: none\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"
"X-Generator: Weblate 3.1.1\n"

#. module: sale_discount_display_amount
#: model:ir.model.fields,field_description:sale_discount_display_amount.field_sale_order__discount_total
#: model:ir.model.fields,field_description:sale_discount_display_amount.field_sale_order_line__discount_total
msgid "Discount Subtotal"
msgstr "Montant de la remise"

#. module: sale_discount_display_amount
#: model:ir.model,name:sale_discount_display_amount.model_sale_order
#, fuzzy
#| msgid "Sales Order"
msgid "Sale Order"
msgstr "Bons de commande"

#. module: sale_discount_display_amount
#: model:ir.model,name:sale_discount_display_amount.model_sale_order_line
msgid "Sales Order Line"
msgstr "Lignes de bon de commande"

#. module: sale_discount_display_amount
#: model:ir.model.fields,field_description:sale_discount_display_amount.field_sale_order__price_total_no_discount
#: model:ir.model.fields,field_description:sale_discount_display_amount.field_sale_order_line__price_total_no_discount
msgid "Subtotal Without Discount"
msgstr "Sous-total sans la remise"
37 changes: 37 additions & 0 deletions sale_discount_display_amount/i18n/sale_discount_display_amount.pot
@@ -0,0 +1,37 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_discount_display_amount
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: sale_discount_display_amount
#: model:ir.model.fields,field_description:sale_discount_display_amount.field_sale_order__discount_total
#: model:ir.model.fields,field_description:sale_discount_display_amount.field_sale_order_line__discount_total
msgid "Discount Subtotal"
msgstr ""

#. module: sale_discount_display_amount
#: model:ir.model,name:sale_discount_display_amount.model_sale_order
msgid "Sale Order"
msgstr ""

#. module: sale_discount_display_amount
#: model:ir.model,name:sale_discount_display_amount.model_sale_order_line
msgid "Sales Order Line"
msgstr ""

#. module: sale_discount_display_amount
#: model:ir.model.fields,field_description:sale_discount_display_amount.field_sale_order__price_total_no_discount
#: model:ir.model.fields,field_description:sale_discount_display_amount.field_sale_order_line__price_total_no_discount
msgid "Subtotal Without Discount"
msgstr ""

0 comments on commit fb872eb

Please sign in to comment.