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:
parent
5b9c6e3211
commit
fe137dc265
224 changed files with 18376 additions and 0 deletions
4
product_price_category/tests/__init__.py
Normal file
4
product_price_category/tests/__init__.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# Copyright 2016 Camptocamp SA
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import test_sale
|
||||
146
product_price_category/tests/test_sale.py
Normal file
146
product_price_category/tests/test_sale.py
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
# Copyright 2016 Camptocamp SA
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import Command
|
||||
from odoo.tests import Form
|
||||
from odoo.tests.common import TransactionCase
|
||||
|
||||
|
||||
class TestSale(TransactionCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
# activate advanced pricelist
|
||||
cls.env.user.write(
|
||||
{
|
||||
"groups_id": [
|
||||
Command.link(cls.env.ref("product.group_product_pricelist").id)
|
||||
]
|
||||
}
|
||||
)
|
||||
cls.tax = cls.env["account.tax"].create(
|
||||
{"name": "Unittest tax", "amount_type": "percent", "amount": "0"}
|
||||
)
|
||||
|
||||
price_category_1 = cls.env["product.price.category"].create(
|
||||
{"name": "TEST_CAT"}
|
||||
)
|
||||
price_category_2 = cls.env["product.price.category"].create(
|
||||
{"name": "TEST_CAT_2"}
|
||||
)
|
||||
|
||||
cls.pricelist = cls.env["product.pricelist"].create(
|
||||
{
|
||||
"name": "Unittest Pricelist",
|
||||
"item_ids": [
|
||||
Command.create(
|
||||
{
|
||||
"applied_on": "2b_product_price_category",
|
||||
"price_category_id": price_category_2.id,
|
||||
"compute_price": "percentage",
|
||||
"percent_price": 5,
|
||||
}
|
||||
),
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
# P1 with price_category_1
|
||||
cls.p1 = cls.env["product.product"].create(
|
||||
{
|
||||
"name": "Unittest P1",
|
||||
"price_category_id": price_category_1.id,
|
||||
"list_price": 10,
|
||||
"taxes_id": [Command.set(cls.tax.ids)],
|
||||
}
|
||||
)
|
||||
|
||||
# P2 with price_category_2
|
||||
cls.p2 = cls.env["product.product"].create(
|
||||
{
|
||||
"name": "Unittest P2",
|
||||
"price_category_id": price_category_2.id,
|
||||
"list_price": 20,
|
||||
"taxes_id": [Command.set(cls.tax.ids)],
|
||||
}
|
||||
)
|
||||
|
||||
# P3 without price category
|
||||
cls.p3 = cls.env["product.product"].create(
|
||||
{
|
||||
"name": "Unittest P3",
|
||||
"list_price": 30,
|
||||
"taxes_id": [Command.set(cls.tax.ids)],
|
||||
}
|
||||
)
|
||||
|
||||
cls.partner = cls.env["res.partner"].create({"name": "Unittest partner"})
|
||||
|
||||
cls.sale = cls.env["sale.order"].create(
|
||||
{
|
||||
"partner_id": cls.partner.id,
|
||||
"order_line": [
|
||||
Command.create(
|
||||
{
|
||||
"name": cls.p1.name,
|
||||
"product_id": cls.p1.id,
|
||||
"product_uom_qty": 1,
|
||||
"product_uom": cls.env.ref("uom.product_uom_unit").id,
|
||||
},
|
||||
),
|
||||
Command.create(
|
||||
{
|
||||
"name": cls.p1.name,
|
||||
"product_id": cls.p2.id,
|
||||
"product_uom_qty": 1,
|
||||
"product_uom": cls.env.ref("uom.product_uom_unit").id,
|
||||
},
|
||||
),
|
||||
Command.create(
|
||||
{
|
||||
"name": cls.p1.name,
|
||||
"product_id": cls.p3.id,
|
||||
"product_uom_qty": 1,
|
||||
"product_uom": cls.env.ref("uom.product_uom_unit").id,
|
||||
},
|
||||
),
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
def test_sale_without_pricelist(self):
|
||||
self.sale._recompute_prices()
|
||||
self.assertEqual(10, self.sale.order_line[0].price_total)
|
||||
self.assertEqual(20, self.sale.order_line[1].price_total)
|
||||
self.assertEqual(30, self.sale.order_line[2].price_total)
|
||||
self.assertEqual(60, self.sale.amount_total)
|
||||
|
||||
def test_sale_with_pricelist(self):
|
||||
"""Pricelist should be applied only on product with price_category_2"""
|
||||
self.sale.pricelist_id = self.pricelist
|
||||
self.sale._recompute_prices()
|
||||
self.assertEqual(10, self.sale.order_line[0].price_total)
|
||||
self.assertEqual(19, self.sale.order_line[1].price_total)
|
||||
self.assertEqual(30, self.sale.order_line[2].price_total)
|
||||
self.assertEqual(59, self.sale.amount_total)
|
||||
|
||||
def test_sale_with_pricelist_and_tax(self):
|
||||
self.tax.amount = 20
|
||||
self.sale.pricelist_id = self.pricelist
|
||||
self.sale._recompute_prices()
|
||||
self.assertEqual(12, self.sale.order_line[0].price_total)
|
||||
self.assertEqual(22.8, self.sale.order_line[1].price_total)
|
||||
self.assertEqual(36, self.sale.order_line[2].price_total)
|
||||
self.assertEqual(70.8, self.sale.amount_total)
|
||||
|
||||
def test_onchange_applied_on_price_category(self):
|
||||
pricelist_form = Form(self.pricelist)
|
||||
with pricelist_form.item_ids.edit(0) as item_form:
|
||||
self.assertTrue(item_form.price_category_id)
|
||||
item_form.display_applied_on = "1_product"
|
||||
self.assertFalse(item_form.price_category_id)
|
||||
|
||||
def test_name(self):
|
||||
item = self.pricelist.item_ids[0]
|
||||
expected_name = f"Price Category: {item.price_category_id.display_name}"
|
||||
self.assertEqual(expected_name, item.name)
|
||||
Loading…
Add table
Add a link
Reference in a new issue