addons-cm/account_invoice_triple_discount_readonly
snt 4a4639f13a [DOC] Actualizar documentación a estándares OCA y preparar logo CriptoMart
- Renombrar README.md a README_DEV.md en todos los addons custom
- Crear README.rst siguiendo estructura OCA oficial
- Crear directorios readme/ con fragmentos .rst (DESCRIPTION, INSTALL, CONFIGURE, USAGE, CONTRIBUTORS, CREDITS)
- Actualizar créditos: Criptomart (autor) + Elika Bilbo (financiador)
- Actualizar __manifest__.py con maintainers correctos
- Crear estructura static/description/ para logo en 5 addons
- Agregar documentación de logo (LOGO_INSTRUCTIONS.md, install_logo.sh)
- Actualizar copilot-instructions.md con referencias a OCA_DOCUMENTATION.md
- Crear docs/OCA_DOCUMENTATION.md con guía completa de estructura
- Crear docs/RESUMEN_CAMBIOS_DOCUMENTACION.md con resumen detallado

Addons actualizados:
- website_sale_aplicoop
- product_sale_price_from_pricelist
- product_pricelist_total_margin
- product_price_category_supplier
- account_invoice_triple_discount_readonly
2026-02-21 19:55:57 +01:00
..
models update pylint10, corrije authors manifest 2026-02-12 17:15:33 +01:00
readme [DOC] Actualizar documentación a estándares OCA y preparar logo CriptoMart 2026-02-21 19:55:57 +01:00
tests [TEST FIX] Resolver errores de tests en addons custom 2026-02-18 18:17:55 +01:00
views [18.0][MIG] account_invoice_triple_discount_readonly: Port to Odoo 18.0 2026-02-10 23:22:50 +01:00
__init__.py Criptomart/red-supermercados-coop#17 add account_invoice_triple_discount_readonly: fix write discount2 and dicount3 columns. Make discount (total) readonly 2025-12-04 14:01:50 +01:00
__manifest__.py [DOC] Actualizar documentación a estándares OCA y preparar logo CriptoMart 2026-02-21 19:55:57 +01:00
oca_dependencies.txt [18.0][MIG] account_invoice_triple_discount_readonly: Port to Odoo 18.0 2026-02-10 23:22:50 +01:00
README.rst [DOC] Actualizar documentación a estándares OCA y preparar logo CriptoMart 2026-02-21 19:55:57 +01:00
README_DEV.md [DOC] Actualizar documentación a estándares OCA y preparar logo CriptoMart 2026-02-21 19:55:57 +01:00

==========================================
Account Invoice Triple Discount Readonly
==========================================

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

|badge1| |badge2|

This module fixes a bug in ``account_invoice_triple_discount`` when combined with ``purchase_triple_discount``.

**Problem Solved:**

In purchase orders, when configuring discounts in the ``discount2`` or ``discount3`` columns:

* Upon saving, all discounts were accumulated in the ``discount1`` column
* The ``discount2`` and ``discount3`` fields were reset to zero
* This occurred because the original mixin's ``write`` method always reset these fields

**Solution:**

The module overrides the ``write`` method of ``triple.discount.mixin`` to:

#. Detect if ``discount1``, ``discount2`` or ``discount3`` are being explicitly modified
#. If there are explicit discounts, ignore the computed ``discount`` field
#. If only the ``discount`` field comes, maintain legacy behavior
#. Make the total ``discount`` field readonly in relevant views

**Additional Features:**

* Makes the ``discount`` field (total discount) **readonly** in:

  * Partner form view (``res.partner``)
  * Supplier info in product form (``product.supplierinfo``)
  * Purchase order lines (``purchase.order.line``)
  * Account move lines (``account.move.line``)
  * Base mixin (``triple.discount.mixin``)

* Forces users to work only with the ``discount1``, ``discount2`` and ``discount3`` columns
* Avoids confusion between computed total and individual discounts

**Table of contents**

.. contents::
   :local:

Installation
============

To install this module, you need to:

#. Ensure dependencies are installed:

   * account_invoice_triple_discount (OCA)
   * purchase_triple_discount (OCA)

#. Update the Apps list
#. Search for "Account Invoice Triple Discount Readonly"
#. Click Install

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

No additional configuration is required after installation. The module automatically:

* Makes the total discount field readonly
* Preserves individual discount values on save
* Maintains backward compatibility with existing discounts

Usage
=====

After installation:

**Working with Discounts:**

#. The total discount field will be readonly and automatically calculated
#. Always use ``discount1``, ``discount2``, and ``discount3`` fields to set discounts
#. When saving, the individual discount values will be preserved correctly

**Example:**

::

  Product: Widget
  Price: 100.00€
  Discount 1: 10%  → 90.00€
  Discount 2: 5%   → 85.50€
  Discount 3: 2%   → 83.79€

  Total discount: 16.21% (displayed, readonly)

**Before this module:**

After saving, you would see:

::

  Discount 1: 16.21%  ❌ (accumulated)
  Discount 2: 0%      ❌ (reset)
  Discount 3: 0%      ❌ (reset)

**After this module:**

After saving, you correctly see:

::

  Discount 1: 10%  ✅
  Discount 2: 5%   ✅
  Discount 3: 2%   ✅
  Total: 16.21% (readonly, calculated)

**Important:**

* Do not try to edit the total discount field (it's readonly)
* Always work with the three individual discount columns
* The total is recalculated automatically

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

Bugs are tracked on `GitHub Issues <https://github.com/Criptomart/addons-cm/issues>`_.
In case of trouble, please check there if your issue has already been reported.

Credits
=======

Authors
~~~~~~~

* Criptomart

Funding
~~~~~~~

* Elika Bilbo

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

* `Criptomart <https://criptomart.net>`_:

  * Bug fix and implementation
  * Override logic for write method

Other credits
~~~~~~~~~~~~~

This module fixes a critical bug in the interaction between OCA's ``account_invoice_triple_discount`` and ``purchase_triple_discount`` modules, ensuring discount values are preserved correctly across all document types.

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

This module is maintained by Criptomart.

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

This module is part of the `Criptomart/addons-cm <https://github.com/Criptomart/addons-cm/tree/18.0/account_invoice_triple_discount_readonly>`_ project on GitHub.