Skip to content

[IMP] product_catalog_tree: add tests - #972

Closed
matiasperalta1 wants to merge 1 commit into
ingadhoc:19.0from
adhoc-dev:19.0-t-76418-mnp
Closed

matiasperalta1 wants to merge 1 commit into
ingadhoc:19.0from
adhoc-dev:19.0-t-76418-mnp

Conversation

@matiasperalta1

@matiasperalta1 matiasperalta1 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Adds tests for sale orders and customer invoices to product_catalog_tree. The module already had 3 tests, all for purchase orders with products in units. They pin the 19.0 behaviour before the migration to 20.0 (separate PR: #971).

Task: https://www.adhoc.inc/odoo/project.task/76418

What is covered

  • The catalog action puts the list view first and keeps the other views; the warehouse location filter of the order (with sale_stock).
  • The list view: editable on top, no create, js_class and the quantity field.
  • Sale orders: + adds one each time and the row shows the quantity and the price; writing the quantity sets it and zero removes the line; with several lines of the product the difference is written; a line in another unit of measure keeps its unit when + is used (2 dozens become 3 dozens, not 3 units).
  • Customer invoices: the list opens first, + and writing the quantity.
  • With no order in the context, or the model without the order, the row is empty and the buttons do nothing.

Test plan

  • odoo -i product_catalog_tree,sale_stock,purchase --test-tags /product_catalog_tree on 19.0: 13 tests, 0 failed.
  • Also on a fresh database with every module of product and sale that installs without Enterprise (54 modules; account_ux left out because its view does not load with the core of the test container): 12 tests at that moment, 0 failed. This is the stack ci/runbot-oba runs.
  • Checked that the tests fail when the code is broken on purpose: quantity not read, + adding two, list not editable, list view not first, warehouse filter removed, several lines not adjusted, invoice lines read from order_line, and the order check removed from the computation. The last one needed the test with the model but no order.
  • The same 13 tests pass on 20.0 against the migrated code ([MIG] product_catalog_tree: Migration to 20.0 #971, with child_field in the context of the 3 original tests), and fail there when the unit of measure is forced to the product one or when child_field is not passed.
  • The 19.0 order models mark the catalog update on the HTTP request, which does not exist in a test; the tests patch it only when the version is below 20.
  • 19.0 was not run with a real HTTP request or in the interface.

Copilot AI balanced review requested due to automatic review settings October 13, 2026 21:20
@roboadhoc

Copy link
Copy Markdown
Contributor

Pull request status dashboard

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

La prueba de edición no verifica que la cantidad sea el único campo editable.

1 open finding
What changed in this PR

Añade cobertura para el catálogo en ventas y facturas antes de la migración a Odoo 20.

Cambios:

  • Pruebas de acciones, cantidades, precios y unidades de medida.
  • Cobertura de contextos sin pedido y configuración de la vista lista.
File Description
product_catalog_tree/​tests/​test_product_catalog_tree.py Amplía las pruebas del catálogo para ventas y facturas.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +209 to +215
def test_the_list_is_editable_in_quantity_only_and_cannot_create(self):
view = self.env.ref("product_catalog_tree.product_view_tree_catalog")
arch = self.env["product.product"].get_view(view_id=view.id, view_type="list")["arch"]
self.assertIn('editable="top"', arch)
self.assertIn('create="false"', arch)
self.assertIn("product_list_catalog", arch)
self.assertIn('name="product_catalog_qty"', arch)
…voices

- Add TestProductCatalogTreeOrders in tests/test_product_catalog_tree.py (TransactionCase, no demo data)
- Cover the catalog action: the list comes first and the other views stay, and the warehouse location filter
- Cover the list view: editable on top, no create, js_class and the quantity field
- Cover sale orders: "+" adds one each time and the row shows quantity and price, writing the quantity sets it and zero removes the line, several lines of the product are adjusted by the difference, and a line in another unit of measure keeps its unit
- Cover customer invoices: the list opens first, "+" and writing the quantity
- Cover the empty row and the inert buttons when the context has no order
- Patch the HTTP request used by the 19.0 order models, absent in a test; not needed in 20.0

Change note: Sin cambios para quien usa el módulo. Se agregan pruebas automáticas que verifican que el catálogo en lista abra primero, sume y edite cantidades en cotizaciones y facturas, conserve la unidad de medida de una línea y filtre por el almacén de la orden.
@gal-adhoc

Copy link
Copy Markdown
Contributor

@roboadhoc r+ nobump

roboadhoc pushed a commit that referenced this pull request Oct 22, 2026
…voices

- Add TestProductCatalogTreeOrders in tests/test_product_catalog_tree.py (TransactionCase, no demo data)
- Cover the catalog action: the list comes first and the other views stay, and the warehouse location filter
- Cover the list view: editable on top, no create, js_class and the quantity field
- Cover sale orders: "+" adds one each time and the row shows quantity and price, writing the quantity sets it and zero removes the line, several lines of the product are adjusted by the difference, and a line in another unit of measure keeps its unit
- Cover customer invoices: the list opens first, "+" and writing the quantity
- Cover the empty row and the inert buttons when the context has no order
- Patch the HTTP request used by the 19.0 order models, absent in a test; not needed in 20.0

Change note: Sin cambios para quien usa el módulo. Se agregan pruebas automáticas que verifican que el catálogo en lista abra primero, sume y edite cantidades en cotizaciones y facturas, conserve la unidad de medida de una línea y filtre por el almacén de la orden.

closes #972

Signed-off-by: Guido Galetto <gal@adhoc.inc>
@roboadhoc roboadhoc closed this Oct 22, 2026
@roboadhoc
roboadhoc deleted the 19.0-t-76418-mnp branch October 22, 2026 20:10

This branch was previously deployed

1 inactive deployment
merge — ece23a4c Deployed Oct 22, 2026 by roboadhoc
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.

4 participants