addons-cm/account_invoice_triple_discount_readonly/README_DEV.md
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

61 lines
2.1 KiB
Markdown

# Account Invoice Triple Discount Readonly
## Description
This module fixes a bug in `account_invoice_triple_discount` when combined with `purchase_triple_discount`.
### Original Problem
In purchase orders, when configuring a discount 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 `discount2` and `discount3` to 0 when the computed `discount` field was included in the write (which happens when any discount is modified).
### Solution
The module overrides the `write` method of `triple.discount.mixin` to:
1. Detect if `discount1`, `discount2` or `discount3` are being explicitly modified
2. If there are explicit discounts, ignore the computed `discount` field
3. If only the `discount` field comes, maintain legacy behavior (map to `discount1` and reset the rest)
Additionally, it makes the `discount` field (total discount) **readonly** in:
- Partner form view (`res.partner`)
- Supplier info in product form (`product.supplierinfo`)
- Base mixin (`triple.discount.mixin`)
This forces users to work only with the `discount1`, `discount2` and `discount3` columns, avoiding confusion.
## Installation
1. Make sure `account_invoice_triple_discount` and `purchase_triple_discount` are installed
2. Update the module list
3. Install `account_invoice_triple_discount_readonly`
## Usage
After installation:
- The total discount field will be readonly and automatically calculated
- Users must use discount1, discount2, and discount3 fields to set discounts
- When saving, the individual discount values will be preserved correctly
## Bug Tracker
Bugs are tracked on [GitHub Issues](https://github.com/OCA/account-invoicing/issues).
In case of trouble, please check there if your issue has already been reported.
## Credits
### Contributors
* Coop Makers
### Maintainers
This module is maintained by the OCA.
## Compatibility
- Odoo 16.0
- account_invoice_triple_discount
- purchase_triple_discount