-
Notifications
You must be signed in to change notification settings - Fork 72
[IMP] account_background_post: add tests #230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 18.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import test_crear_duplicar_y_validar_facturas_masivas_cliente |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,107 @@ | ||||||||||||||||||||||||||||||||||||||||||||||
| from datetime import date | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| from odoo.tests.common import TransactionCase | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| class TestCrearDuplicarYValidarFacturasMasivasCliente(TransactionCase): | ||||||||||||||||||||||||||||||||||||||||||||||
| def setUp(self): | ||||||||||||||||||||||||||||||||||||||||||||||
| super().setUp() | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # Creación del Cliente | ||||||||||||||||||||||||||||||||||||||||||||||
| self.cliente = self.env["res.partner"].create( | ||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||
| "name": "ADHOC SA", | ||||||||||||||||||||||||||||||||||||||||||||||
| "vat": "30714295698", | ||||||||||||||||||||||||||||||||||||||||||||||
| "is_company": True, | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # 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] | ||||||||||||||||||||||||||||||||||||||||||||||
|
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] | |
| # 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
AI
Oct 17, 2025
There was a problem hiding this comment.
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, [])].
| (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
AI
Oct 17, 2025
There was a problem hiding this comment.
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
AI
Oct 17, 2025
There was a problem hiding this comment.
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.
| facturas_duplicadas = factura_duplicada_1 + factura_duplicada_2 + factura_duplicada_3 | |
| facturas_duplicadas = factura_duplicada_1 | factura_duplicada_2 | factura_duplicada_3 |
Copilot
AI
Oct 17, 2025
There was a problem hiding this comment.
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.
| facturas_a_validar = factura_base + facturas_duplicadas | |
| facturas_a_validar = factura_base | facturas_duplicadas |
Copilot
AI
Oct 17, 2025
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.