Skip to content

[IMP] account_background_post: add tests#230

Open
cav-adhoc wants to merge 1 commit intoingadhoc:18.0from
adhoc-dev:18.0-t-57795-cav
Open

[IMP] account_background_post: add tests#230
cav-adhoc wants to merge 1 commit intoingadhoc:18.0from
adhoc-dev:18.0-t-57795-cav

Conversation

@cav-adhoc
Copy link
Contributor

No description provided.

Copilot AI review requested due to automatic review settings October 17, 2025 18:22
@roboadhoc
Copy link
Contributor

Pull request status dashboard

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds a new test module to validate creating, duplicating, and mass-posting customer invoices, aiming to cover the core flow relevant to account_background_post.

  • Introduces a TransactionCase test that creates a draft invoice, duplicates it, and posts all invoices in bulk.
  • Wires the test into the test suite via tests/init.py.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
account_background_post/tests/test_crear_duplicar_y_validar_facturas_masivas_cliente.py New end-to-end test for creating, duplicating, and posting customer invoices.
account_background_post/tests/init.py Registers the new test module.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


# Paso 1: Creación de la Factura Borrador (Simulación 00:07 - 00:15)
move_line_vals = [
(0, 0, {"product_id": self.producto.id, "quantity": 1.0, "price_unit": 100.00, "name": "Línea de Servicio"})
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

El test asume 0% de impuestos pero no lo garantiza; si el producto o la compañía tienen impuestos por defecto, los montos no serán 100.00 y la aserción fallará. Propongo establecer explícitamente impuestos vacíos en la línea: agregar 'tax_ids': [(6, 0, [])].

Suggested change
(0, 0, {"product_id": self.producto.id, "quantity": 1.0, "price_unit": 100.00, "name": "Línea de Servicio"})
(0, 0, {
"product_id": self.producto.id,
"quantity": 1.0,
"price_unit": 100.00,
"name": "Línea de Servicio",
"tax_ids": [(6, 0, [])],
})

Copilot uses AI. Check for mistakes.
Comment on lines +84 to +87
self.assertTrue(
all(f.state == "posted" for f in facturas_a_validar),
"Todas las facturas deben haber pasado a estado Publicado/Validado ('posted').",
)
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

La verificación de estado 'posted' se realiza dos veces (aquí y en 100-103). Es redundante; elimina una de las dos para evitar duplicación.

Copilot uses AI. Check for mistakes.
{
"partner_id": self.cliente.id,
"move_type": "out_invoice",
"invoice_date": date.today(),
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Para respetar el contexto/zonas horarias de Odoo en pruebas, use fields.Date.context_today(self) en lugar de date.today().

Copilot uses AI. Check for mistakes.
Comment on lines +19 to +30
# Usar un producto existente o crear uno con los valores por defecto necesarios
self.producto = self.env["product.product"].search([("type", "=", "service")], limit=1)
if not self.producto:
# Crear plantilla de producto primero
template = self.env["product.template"].create(
{
"name": "Servicio de Test",
"list_price": 100.00,
"type": "service",
}
)
self.producto = template.product_variant_ids[0]
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Buscar un producto existente puede introducir flakiness (p. ej., impuestos por defecto, cuentas o políticas diferentes). Para aislar el test, cree siempre un producto específico para la prueba con 'taxes_id': [(6, 0, [])] y demás campos requeridos.

Suggested change
# Usar un producto existente o crear uno con los valores por defecto necesarios
self.producto = self.env["product.product"].search([("type", "=", "service")], limit=1)
if not self.producto:
# Crear plantilla de producto primero
template = self.env["product.template"].create(
{
"name": "Servicio de Test",
"list_price": 100.00,
"type": "service",
}
)
self.producto = template.product_variant_ids[0]
# Siempre crear un producto específico para la prueba con taxes_id vacío y demás campos requeridos
template = self.env["product.template"].create(
{
"name": "Servicio de Test",
"list_price": 100.00,
"type": "service",
"taxes_id": [(6, 0, [])],
}
)
self.producto = template.product_variant_ids[0]

Copilot uses AI. Check for mistakes.
Comment on lines +3 to +6
from odoo.tests.common import TransactionCase


class TestCrearDuplicarYValidarFacturasMasivasCliente(TransactionCase):
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Considere usar SavepointCase en lugar de TransactionCase para acelerar las pruebas cuando no se necesitan commits ni verificar efectos de transacción.

Suggested change
from odoo.tests.common import TransactionCase
class TestCrearDuplicarYValidarFacturasMasivasCliente(TransactionCase):
from odoo.tests.common import SavepointCase
class TestCrearDuplicarYValidarFacturasMasivasCliente(SavepointCase):

Copilot uses AI. Check for mistakes.
factura_duplicada_1 = factura_base.copy()
factura_duplicada_2 = factura_base.copy()
factura_duplicada_3 = factura_base.copy()
facturas_duplicadas = factura_duplicada_1 + factura_duplicada_2 + factura_duplicada_3
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Para combinar recordsets en Odoo, el operador recomendado es '|' (unión) en lugar de '+', ya que '|' elimina duplicados y es más idiomático: facturas_duplicadas = factura_duplicada_1 | factura_duplicada_2 | factura_duplicada_3.

Suggested change
facturas_duplicadas = factura_duplicada_1 + factura_duplicada_2 + factura_duplicada_3
facturas_duplicadas = factura_duplicada_1 | factura_duplicada_2 | factura_duplicada_3

Copilot uses AI. Check for mistakes.
)

# Paso 3: Validación Masiva (Simulación 00:33 - 00:40)
facturas_a_validar = factura_base + facturas_duplicadas
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Mismo criterio que arriba: use la unión de recordsets con '|' para combinar: facturas_a_validar = factura_base | facturas_duplicadas.

Suggested change
facturas_a_validar = factura_base + facturas_duplicadas
facturas_a_validar = factura_base | facturas_duplicadas

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants