build: configurar herramientas de verificación OCA

- Instalar pre-commit con 25 hooks configurados
- Configurar black 26.1.0 para formateo de código Python
- Configurar isort 7.0.0 para ordenación de imports
- Configurar flake8 7.3.0 con flake8-bugbear
- Configurar pylint 3.1.1 con pylint-odoo 9.1.2
- Añadir autoflake y pyupgrade para mejoras automáticas
- Configurar prettier para formateo de XML/JSON/YAML
- Crear .editorconfig para consistencia de editor
- Crear Makefile con comandos útiles
- Crear check_addon.sh para verificación rápida de addons
- Actualizar configuración de VS Code con extensiones recomendadas
- Añadir documentación completa de uso
- Aplicar formateo automático a archivos existentes
- Deshabilitar setuptools-odoo (no soporta Odoo 18.0 aún)
- Deshabilitar fix-encoding-pragma (obsoleto, usar pyupgrade)
This commit is contained in:
snt 2026-02-11 16:09:41 +01:00
parent 5b9c6e3211
commit fe137dc265
224 changed files with 18376 additions and 0 deletions

View file

@ -0,0 +1,4 @@
from . import product_price_category
from . import product_template
from . import product_pricelist
from . import product_pricelist_item

View file

@ -0,0 +1,13 @@
# Copyright 2016 Camptocamp SA
# Copyright 2023 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields
from odoo import models
class ProductPriceCategory(models.Model):
_name = "product.price.category"
_description = "Product Price Category"
name = fields.Char(required=True)

View file

@ -0,0 +1,25 @@
# Copyright 2017 Camptocamp SA
# Copyright 2023 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models
class ProductPricelist(models.Model):
_inherit = "product.pricelist"
def _get_applicable_rules_domain(self, products, date, **kwargs):
price_categ_ids = [
p.price_category_id.id for p in products if p.price_category_id
]
domain = super()._get_applicable_rules_domain(products, date, **kwargs)
if price_categ_ids:
domain.extend(
[
"|",
("price_category_id", "=", False),
("price_category_id", "in", price_categ_ids),
]
)
return domain

View file

@ -0,0 +1,74 @@
# Copyright 2017 Camptocamp SA
# Copyright 2023 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import _
from odoo import api
from odoo import fields
from odoo import models
class ProductPricelistItem(models.Model):
_inherit = "product.pricelist.item"
applied_on = fields.Selection(
selection_add=[("2b_product_price_category", "Price Category")],
ondelete={"2b_product_price_category": "set default"},
)
display_applied_on = fields.Selection(
selection_add=[("2b_product_price_category", "Price Category")],
ondelete={"2b_product_price_category": "set default"},
)
price_category_id = fields.Many2one(
comodel_name="product.price.category",
string="Price Category",
ondelete="cascade",
help="Specify a product price category if this rule only applies "
"to one price category. Keep empty otherwise.",
compute="_compute_price_category",
store=True,
readonly=False,
)
@api.depends("price_category_id")
def _compute_name(self):
result = super()._compute_name()
for item in self:
if item.applied_on == "2b_product_price_category":
item.name = _("Price Category: %s", item.price_category_id.display_name)
return result
@api.depends("display_applied_on")
def _compute_price_category(self):
"""Reset the price_category_id value if applied_on
is not price_category
"""
for rec in self:
if rec.display_applied_on != "2b_product_price_category":
rec.price_category_id = False
def _is_applicable_for(self, product, qty_in_product_uom):
res = super()._is_applicable_for(product, qty_in_product_uom)
if (
self.price_category_id
and self.price_category_id != product.price_category_id
):
return False
return res
@api.onchange("display_applied_on")
def _onchange_display_applied_on(self):
res = super()._onchange_display_applied_on()
for item in self:
if item.display_applied_on == "2b_product_price_category":
item.update(
dict(
product_id=None,
product_tmpl_id=None,
applied_on="2b_product_price_category",
product_uom=None,
categ_id=None,
)
)
return res

View file

@ -0,0 +1,14 @@
# Copyright 2016 Camptocamp SA
# Copyright 2023 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields
from odoo import models
class ProductTemplate(models.Model):
_inherit = "product.template"
price_category_id = fields.Many2one(
"product.price.category", string="Price Category", ondelete="restrict"
)