addons-cm/website_sale_aplicoop/models/res_config_settings.py
snt 2a005a9d5a feat(website_sale_aplicoop): sistema de ribbons basado en stock
- Añadidos ribbons 'Sin Stock' (rojo) y 'Pocas Existencias' (amarillo)
- Nuevo campo configurable: umbral de stock bajo (default: 5.0)
- Campos computed en product.product:
  * is_out_of_stock: True cuando qty_available <= 0
  * is_low_stock: True cuando 0 < qty_available <= threshold
  * dynamic_ribbon_id: ribbon automático según nivel de stock
- Ordenamiento mejorado: productos con stock primero, sin stock al final
- Template actualizado:
  * Muestra ribbon de stock en tarjeta de producto
  * Deshabilita botón add-to-cart cuando producto sin stock
  * Cambia icono a 'fa-ban' en productos sin stock
- Vista de configuración: campo 'Low Stock Threshold' en Settings > Shop Performance
- Solo aplica a productos type='consu' (almacenables)
- Tests: 112 pasados, 0 fallos
2026-02-25 19:48:39 +01:00

48 lines
1.6 KiB
Python

from odoo import fields
from odoo import models
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"
aplicoop_pricelist_id = fields.Many2one(
"product.pricelist",
config_parameter="website_sale_aplicoop.pricelist_id",
help="Pricelist to use for Aplicoop group orders. If not set, will use website default.",
)
eskaera_lazy_loading_enabled = fields.Boolean(
string="Enable Lazy Loading",
config_parameter="website_sale_aplicoop.lazy_loading_enabled",
default=True,
help="Enable lazy loading of products in group order shop. Products will be paginated.",
)
eskaera_products_per_page = fields.Integer(
string="Products Per Page",
config_parameter="website_sale_aplicoop.products_per_page",
default=20,
help="Number of products to load per page in group order shop. Minimum 5, Maximum 100.",
)
low_stock_threshold = fields.Float(
string="Low Stock Threshold",
config_parameter="website_sale_aplicoop.low_stock_threshold",
default=5.0,
help="Products with stock below or equal to this value will show 'Low Stock' ribbon. "
"Products with stock = 0 will show 'Out of Stock' ribbon and cannot be added to cart.",
)
@staticmethod
def _get_products_per_page_selection(records):
"""Return default page sizes."""
return [
(5, "5"),
(10, "10"),
(15, "15"),
(20, "20"),
(30, "30"),
(50, "50"),
]